Jump to content

Recommended Posts

  • Replies 49
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    22

  • CadTechJGC184

    19

  • automicro

    4

  • CmdrDuh

    3

Posted

are we to assume that the polyline is in a roundish type shape? If not, how do you purpose to locate the center? What you want is actually pretty easy, make sure the polyline is closed, get the area, do some math to find a circle of the same area, use the centroid of the polyline area, and locate the circle.

Posted

I must have been bored... no error checking and not extensively tested, kinda slow

Using CmdrDuh's idea...

(defun c:test (/ ss1 num cnt ename obj rp ar rad)
 (vl-load-com)
 (setq ss1 (ssget '((0 . "*polyline")))
   num (sslength ss1)
   cnt 0)
 (repeat num
   (setq ename (ssname ss1 cnt))
   (setq obj (vlax-ename->vla-object ename))
   (vlax-put-property obj 'Closed 1)
   (vl-cmdf "region" ename "")
   (setq obj (vlax-ename->vla-object (entlast)))
       (setq ar (vlax-get-property obj 'Area)
     rp (vlax-safearray->list (vlax-variant-value (vlax-get-property obj 'Centroid)))
     rad (sqrt (/ ar pi))
     )
   (entdel (entlast));remove this line if you want to keep original
   (vl-cmdf "circle" rp rad)
 (setq cnt (1+ cnt))
 )
 (princ)
)        

Posted

I was just thinking out loud, HAHA, but thanks for making it a reality

Posted

Great LISP for quickly typed one, - nice one Larry.

 

Not to be critical, but I would only make a few aesthetic changes:

 

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:test  [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] ss obj rp ar rad[b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ss [b][color=RED]([/color][/b][b][color=BLUE]ssget[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]0[/color][/b] [b][color=#ff00ff]"*POLYLINE"[/color][/b][b][color=RED])[/color][/b]
                           [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]getvar[/color][/b] [b][color=#ff00ff]"CTAB"[/color][/b][b][color=RED])[/color][/b]
                             [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]410[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]getvar[/color][/b] [b][color=#ff00ff]"CTAB"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
                             [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]67[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] [b][color=#009900]1[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]getvar[/color][/b] [b][color=#ff00ff]"TILEMODE"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]foreach[/color][/b] x [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]vlax-ename->vla-object[/color][/b]
                [b][color=RED]([/color][/b][b][color=BLUE]vl-remove-if[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]listp[/color][/b]
                  [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]cadr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]ssnamex[/color][/b] ss[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]vlax-put-property[/color][/b] x [b][color=DARKRED]'[/color][/b]Closed [b][color=#009900]1[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]vl-cmdf[/color][/b] [b][color=#ff00ff]"_region"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-vla-object->ename[/color][/b] x[b][color=RED])[/color][/b] [b][color=#ff00ff]""[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] obj [b][color=RED]([/color][/b][b][color=BLUE]vlax-ename->vla-object[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entlast[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
           ar  [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-property[/color][/b] obj [b][color=DARKRED]'[/color][/b]Area[b][color=RED])[/color][/b]
           rp  [b][color=RED]([/color][/b][b][color=BLUE]vlax-safearray->list[/color][/b]
                 [b][color=RED]([/color][/b][b][color=BLUE]vlax-variant-value[/color][/b]
                   [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-property[/color][/b] obj [b][color=DARKRED]'[/color][/b]Centroid[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
           rad [b][color=RED]([/color][/b][b][color=BLUE]sqrt[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] ar pi[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]vla-delete[/color][/b] obj[b][color=RED])[/color][/b] [i][color=#990099]; -> Remove to Keep Original[/color][/i]
     [b][color=RED]([/color][/b][b][color=BLUE]vl-cmdf[/color][/b] [b][color=#ff00ff]"_circle"[/color][/b] rp rad[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n<!> Nothing Selected <!>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

Posted

Lee, how did you get your code to be color coded?

Posted

Incredibly good, this savings me lots of jobs.

Thanks to lpseifert and Lee Mac

 

But he discovered that many of polylines is double stored above each other

Is there a simple way to remove double elements stored?

 

 

What a coincidence you both seem to enjoy motorcycles

I myself drive BMW F800GS:)

Posted
But he discovered that many of polylines is double stored above each other

Is there a simple way to remove double elements stored?

Maybe OVERKILL?

Posted
Incredibly good, this savings me lots of jobs.

Thanks to lpseifert and Lee Mac

 

But he discovered that many of polylines is double stored above each other

Is there a simple way to remove double elements stored?

 

I would recommend OVERKILL from Express Tools - that'll be a much better than anything I could write for you.

 

 

What a coincidence you both seem to enjoy motorcycles

I myself drive BMW F800GS:)

 

Great looking bike - bit on the tall side, but a smooth ride. :D

Posted
I would recommend OVERKILL from Express Tools - that'll be a much better than anything I could write for you.

 

Thanks for the tip.

Your program works very well, thanks once again.

 

 

 

 

Great looking bike - bit on the tall side, but a smooth ride. :D

 

Is fun to drive even on gravel.

Have gravel tires & GPS with very delaljerad map

To investigate the small roads and terrain

Posted

Sorry did not understand that it was an AutoCAD

commando, thought you meant something else

But now I know, thanks for the tip

Posted

OVERKILL isn't supplied with standard AutoCAD, but is in the Express Tools.

Posted

OK OK OK, does this lisp make a polyline out of a circle? I'm confused! I get this way alot! hahaha

 

Thanks

Posted

This LISP takes a Polyline, closes it, converts it to a region, finds the area and centroid of the region and creates a circle of radius (sqrt (/ pi)) and with the centroid as the centre. It then deletes the region.

Posted

WOW... that's a powerful lisp. can you then take that circle and turn it into a wipeout? I've never been able to turn a circle into a wipeout. I have so many ideas for lisp routines. i just have no clue how to create one. lol

Posted

You need to select a closed polyline for a wipeout, so no, that LISP would not work...

Posted

Maybe this though:

 

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:cwipe [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] vlst ovar seg i cEnt cObj iPt ptLst[b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] vlst [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#ff00ff]"CMDECHO"[/color][/b] [b][color=#ff00ff]"OSMODE"[/color][/b][b][color=RED])[/color][/b]
       ovar [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]getvar[/color][/b] vlst[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]setvar[/color][/b] vlst [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] seg [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] pi [b][color=#009900]100[/color][/b][b][color=RED])[/color][/b] i [b][color=#009900]-1[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cEnt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entsel[/color][/b] [b][color=#ff00ff]"\nSelect Circle for Wipeout: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
          [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=#ff00ff]"AcDbCircle"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ObjectName[/color][/b]
                             [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cObj [b][color=RED]([/color][/b][b][color=BLUE]vlax-ename->vla-object[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]<=[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] Par [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] seg [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] i [b][color=RED]([/color][/b][b][color=BLUE]1+[/color][/b] i[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] [b][color=#009900]2[/color][/b] pi[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] iPt [b][color=RED]([/color][/b][b][color=BLUE]vlax-curve-getPointatParam[/color][/b] cObj Par[b][color=RED])[/color][/b]
             ptLst [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] iPt ptLst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]command[/color][/b] [b][color=#ff00ff]"_pline"[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]command[/color][/b] ptLst[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]command[/color][/b] [b][color=#ff00ff]"_C"[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]command[/color][/b] [b][color=#ff00ff]"_wipeout"[/color][/b] [b][color=#ff00ff]"_P"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entlast[/color][/b][b][color=RED])[/color][/b] [b][color=#ff00ff]"_Y"[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]entdel[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [i][color=#990099]; Remove to keep Circle[/color][/i]
   [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n<!> No Circle Selected <!>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]setvar[/color][/b] vlst ovar[b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
            
         

Posted

thanks LeeMac,

 

I will try this whe I get to work today.

Posted

That code uses 200 segments, but you can increase/decrease this if necessary.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...