+ Reply to Thread
Page 1 of 5 1 2 3 ... LastLast
Results 1 to 10 of 50
  1. #1
    Junior Member automicro's Avatar
    Using
    Map 3D 2009
    Join Date
    Mar 2009
    Location
    Sweden
    Posts
    18

    Default Polyline to circle

    Registered forum members do not see this ad.

    Perhaps i have to post this here?

    http://www.cadtutor.net/forum/showth...922#post231922

    Can some one expert help me to develop a Lisp routine?
    I think is not easy to do that.

    /automicro

  2. #2
    Senior Member CmdrDuh's Avatar
    Computer Details
    CmdrDuh's Computer Details
    Computer:
    HP workstation xw8200
    RAM:
    2gig, soon to be 4
    Monitor:
    Dual 21s
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    AZ, USA
    Posts
    396

    Default

    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.
    Everyone has a Photographic memory, some just don't have film

  3. #3
    Forum Deity
    Using
    Civil 3D 2008
    Join Date
    Sep 2006
    Location
    Pittsburgh, PA, USA
    Posts
    3,581

    Default

    I must have been bored... no error checking and not extensively tested, kinda slow
    Using CmdrDuh's idea...
    Code:
    (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)
    )

  4. #4
    Senior Member CmdrDuh's Avatar
    Computer Details
    CmdrDuh's Computer Details
    Computer:
    HP workstation xw8200
    RAM:
    2gig, soon to be 4
    Monitor:
    Dual 21s
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    AZ, USA
    Posts
    396

    Default

    I was just thinking out loud, HAHA, but thanks for making it a reality
    Everyone has a Photographic memory, some just don't have film

  5. #5
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,816

    Default

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

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

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

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  6. #6
    Senior Member CmdrDuh's Avatar
    Computer Details
    CmdrDuh's Computer Details
    Computer:
    HP workstation xw8200
    RAM:
    2gig, soon to be 4
    Monitor:
    Dual 21s
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    AZ, USA
    Posts
    396

    Default

    Lee, how did you get your code to be color coded?
    Everyone has a Photographic memory, some just don't have film

  7. #7
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,816

    Default

    I wrote a LISP to write a file with the [ color] tags in
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  8. #8
    Junior Member automicro's Avatar
    Using
    Map 3D 2009
    Join Date
    Mar 2009
    Location
    Sweden
    Posts
    18

    Default

    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

  9. #9
    Super Moderator fuccaro's Avatar
    Using
    AutoCAD 2006
    Join Date
    Nov 2002
    Location
    Romania, Marosvasarhely
    Posts
    3,540

    Default

    Quote Originally Posted by automicro View Post
    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?
    It's nice to be nice, but sometimes is nicer to be evil!.
    Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.

  10. #10
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,816

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by automicro View Post
    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.


    Quote Originally Posted by automicro View Post
    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.
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

Similar Threads

  1. Can't Extrude Circle Along 3D Polyline
    By Bill Tillman in forum AutoCAD 3D Modelling & Rendering
    Replies: 11
    Last Post: 26th Mar 2009, 01:35 pm
  2. Make Circle As Polyline
    By MR MAN in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 8
    Last Post: 28th Oct 2008, 01:33 pm
  3. Iintersecting polyline with a circle
    By BIGAL in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 10th Mar 2006, 03:10 am
  4. Extruding Circle along polyline
    By dreamer in forum AutoCAD 3D Modelling & Rendering
    Replies: 2
    Last Post: 9th May 2005, 10:12 pm
  5. Line from inner circle to outer circle
    By jocaan in forum AutoCAD Beginners' Area
    Replies: 6
    Last Post: 11th Mar 2004, 09:28 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts