+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 30
  1. #1
    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
    19,347

    Default Polyline Vertex Question

    Registered forum members do not see this ad.

    Hi Guys,

    Hope you are all having a great Christmas, and have a equally good New Year.

    Just a quick question, which I am sure can be answered in minutes.

    When looking at a problem posted on here recently (about marking points on a golf course...), I was thinking how I would approach the problem, and thought about using the vertices of a user-drawn polyline.

    To experiment, I drew myself a polyline (attached), and performed an entget operation on it to see what it would return.

    This is the result:

    Code:
    ((-1 . <Entity name: 7ef62ed8>) 
    (0 . "LWPOLYLINE")  <<--- Entity Type
    (330 . <Entity name: 7ef53cc0>)
    (5 . "2DC3")
    (100 . "AcDbEntity") 
    (67 . 0) 
    (410 . "Model")  <<--- Tab Name
    (8 . "3")  <<--- Layer Name
    (100 . "AcDbPolyline") 
    (90 . 4) 
    (70 . 0) 
    (43 . 0.0) 
    (38 . 0.0)
    (39 . 0.0) 
    (10 0.0 0.0)  <<--- First Vertex (Start Point)
    (40 . 0.0)   <<--- Starting Thickness for First Segment
    (41 . 0.0)  <<--- Ending Thickness for First Segment
    (42 . 0.0) 
    (10 10.0 0.0)   <<--- Second Vertex
    (40 . 0.0)
    (41 . 0.0) 
    (42 . 0.0)
    (10 10.0 10.0)  <<--- Third Vertex
    (40 . 0.0)
    (41 . 0.0) 
    (42 . 0.0) 
    (10 0.0 10.0)  <<--- Fourth Vertex (End Point)
    (40 . 0.0)
    (41 . 0.0) 
    (42 . 0.0)
    (210 0.0 0.0 1.0))
    These coordinates correspond to the various vertices on my attached drawing. But my question is, how does one obtain these values through LISP?

    My initial assumption would be something of the form:

    Code:
    (defun c:test (/ ent Vertex)
        (setq ent (entget (car (entsel))))
        (setq Vertex (cdr (assoc 10 ent)))
        (princ)
    ) ;_  end defun
    But how would one retrieve the next vertex, and every other vertex after that? How do you cycle through the different entries for the DXF code 10?

    Many thanks for any advice and help provided
    Attached Images
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

  2. #2
    Super Member ASMI's Avatar
    Using
    AutoCAD 2008
    Join Date
    Nov 2005
    Location
    Oceanus Procellarum, Moon
    Posts
    1,427

    Default

    Try in command line:

    Click polyline to get DXF list:

    Code:
    Command: (setq plDxf(entget(car(entsel))))
    
    Select object: ((-1 . <Entity name: 7efa3368>) (0 . "LWPOLYLINE") (330 . 
    <Entity name: 7efa1cf8>) (5 . "1AD") (100 . "AcDbEntity") (67 . 0) (410 . 
    "Model") (8 . "0") (100 . "AcDbPolyline") (90 . 4) (70 . 0) (43 . 0.0) (38 . 
    0.0) (39 . 0.0) (10 0.0 0.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 10.0 0.0) (40 
    . 0.0) (41 . 0.0) (42 . 0.0) (10 10.0 10.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) 
    (10 0.0 10.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (210 0.0 0.0 1.0))
    Remove all non 10 groups:

    Code:
    Command: (setq lst10(vl-remove-if '(lambda(x)(/= 10(car x)))plDxf))
    ((10 0.0 0.0) (10 10.0 0.0) (10 10.0 10.0) (10 0.0 10.0))
    Remove first member of each list"

    Code:
    Command: (setq verLst(mapcar 'cdr lst10))
    ((0.0 0.0) (10.0 0.0) (10.0 10.0) (0.0 10.0))
    Or at once:

    Code:
    Command: (mapcar 'cdr(vl-remove-if '(lambda(x)(/= 10(car x)))(entget(car(entsel)))))
    ((0.0 0.0) (10.0 0.0) (10.0 10.0) (0.0 10.0))

  3. #3
    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
    19,347

    Default

    Thank you for your reply, ASMI - I have learnt a lot from it.

    But, I note that this would only work for this example - for instance, if I had vertices with co-ordinates:

    (1.0 5.0 0.0)
    (2.0 6.0 0.0)
    (3.0 7.0 0.0)

    How would I deal with this situation?

    Is there not a generic function for dealing with multiple occurences of the same DXF group code?

    Thanks for your help ASMI, much appreciated.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

  4. #4
    Super Member ASMI's Avatar
    Using
    AutoCAD 2008
    Join Date
    Nov 2005
    Location
    Oceanus Procellarum, Moon
    Posts
    1,427

    Default

    It will work with every lwpolyline.

  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
    19,347

    Default

    Ahh, Sorry, I misread you last post - when you removed the DXF 10 code. Sorry!

    And thanks for your help!
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

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

  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
    19,347

    Default

    Thanks lpseifert,

    Thats very interesting!
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

  8. #8
    Forum Deity David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    2,531

    Default

    Code:
    (defun massoc (key alist / x nlist)
      (foreach x alist
        (if (eq key (car x))
            (setq nlist (cons (cdr x) nlist))))
      (reverse nlist))
    This will return a list of values for the key in alist. It was made to deal with just such a scenario.

    You would have to do some extra coding for every other one etc.

    -David
    R12 (Dos) - A2K

  9. #9
    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
    19,347

    Default

    Excellent David,

    Simple and effective. Nice one

    Thanks
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

  10. #10
    Senior Member
    Using
    AutoCAD 2008
    Join Date
    Dec 2009
    Posts
    200

    Default

    Registered forum members do not see this ad.

    I might be missing something here, but would it be possible to take the points taken from the polyline and save them as pt1, pt2, pt3.... so they can be used in another command?

Similar Threads

  1. Increase vertex of 3dmesh
    By MR MAN in forum AutoCAD 3D Modelling & Rendering
    Replies: 6
    Last Post: 11th Sep 2008, 03:20 pm
  2. add vertex z or elevation to points
    By gvlisnas in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 4th Aug 2007, 11:14 pm
  3. reading from vertex files
    By gib65 in forum AutoCAD 3D Modelling & Rendering
    Replies: 5
    Last Post: 1st Feb 2007, 06:35 am
  4. Viewing 3DSolid vertex
    By LeoRoncetti in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 2nd May 2006, 01:14 am
  5. newb! question - join polyline then fillet
    By pdlefief in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 10th Apr 2006, 09:32 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