+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17
  1. #1
    Full Member
    Using
    AutoCAD 2010
    Join Date
    Jun 2012
    Posts
    99

    Default Coverting a series of lines to a polyline

    Registered forum members do not see this ad.

    How can I convert a series of line sgments to a polyline, or draw them as a pline by modifying the following code:
    Code:
     
    (setq p1(cadr (car l)))
    (while (/= l nil)
    (setq l(cdr l)) 
    (setq p2(cadr (car l))) 
    (command "line"  "_NON" p1 "_NON" p2 "") 
    (setq p1 p2) 
    )
    Thanking in advance,
    Aloy

  2. #2
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,586

    Default

    Try this code, if you need to make the pline closed hit "CL" at the end
    Code:
     
    (defun C:demo()
    (setq osm (getvar "osmode")) 
    (setvar "osmode" 0) 
    (command "._pline")
    (while (= 1 (logand 1 (getvar "cmdactive")))
    (command pause))
    (setvar "osmode" osm) 
    (princ) 
    )
    ~'J'~
    The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)

  3. #3
    Full Member
    Using
    AutoCAD 2010
    Join Date
    Jun 2012
    Posts
    99

    Default

    Hi Fixo,
    The code you gave works fine on it own just like pline in autoCad. What I need is, to extract the point from the list, l ,when prompted to give the point.
    Regards,
    Aloy

  4. #4
    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,705

    Default

    Query the DXF data of the resultant polyline.
    Lee Mac Programming

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

    Just another Swamper

  5. #5
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,586

    Default

    Try instead
    Code:
     
    (defun C:demo(/ closed osm ptlist)
    (setq osm (getvar "osmode")) 
    (setvar "osmode" 0)
    (setq ptlist [ your points ])
    (setq closed T ;|or nil if open|;)
    (command "._pline")
    (mapcar 'command ptlist)
    (if closed 
    (command "CL")
    (command "")
    (setvar "osmode" osm)
    (princ)
    )
    The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)

  6. #6
    Senior Member
    Discipline
    Structural
    Using
    AutoCAD 2011
    Join Date
    Sep 2011
    Location
    Baia Mare, Romania
    Posts
    136

    Default

    aloy,
    From your code, the list must be something like ((a (x y z)) (b (u v w)) ...
    In this case, this code will draw a Polyline instead of Lines.
    Code:
    (command "PLINE")
    (foreach x l
      (command "_non" (cadr x))
      )
    (command "")

  7. #7
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,932

    Default

    Quote Originally Posted by aloy View Post
    How can I convert a series of line sgments to a polyline
    One thing that hasn't been mentioned yet, is to use the PEDIT Command on a Selection Set, example:

    Code:
    (defun c:FOO (/ ss)
      (if (setq ss (ssget "_:L" '((0 . "LINE"))))
        (command "._pedit" "multiple" ss "" "y" "")
        (prompt "\n** Nothing selected ** ")
        )
      (princ)
      )
    ... You can tailor this how you like, if you wanted to join the lines, etc..

    HTH
    Last edited by BlackBox; 24th Jul 2012 at 01:40 am.
    "Potential has a shelf life." - Margaret Atwood

  8. #8
    Full Member
    Using
    AutoCAD 2010
    Join Date
    Jun 2012
    Posts
    99

    Default

    Stefan,
    Thanks a lot. Fantastic.
    Regards,
    Aloy

  9. #9
    Full Member
    Using
    AutoCAD 2010
    Join Date
    Jun 2012
    Posts
    99

    Default

    Hi RenderMan,
    It does not work. It asks to select and at the end does not convert. If you like I can post the list to draw the lines and you may try.
    Regards,
    Aloy

  10. #10
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,932

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by aloy View Post
    Quote Originally Posted by RenderMan View Post
    Quote Originally Posted by aloy View Post
    How can I convert a series of line sgments to a polyline
    One thing that hasn't been mentioned yet, is to use the PEDIT Command on a Selection Set
    Hi RenderMan,
    It does not work. It asks to select and at the end does not convert. If you like I can post the list to draw the lines and you may try.
    To reiterate... The function prompts the user for a Selection Set of lines that already exist within the drawing (and not a list of points), then converts the a valid Selection Set to Polylines. This function does not accept any arguments (i.e., a list of points).

    You've mentioned different tasks in this thread; this offering is by no means an answer for each of them.
    "Potential has a shelf life." - Margaret Atwood

Similar Threads

  1. a series of polyline in between two bounding polyline
    By souvik in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: 14th May 2012, 01:18 pm
  2. HELP! Want to draw a series of 45 degrees lines between 2 points
    By mrbradley1 in forum AutoLISP, Visual LISP & DCL
    Replies: 23
    Last Post: 31st Mar 2011, 10:48 am
  3. How do you calculate total lengths of a series of poly lines?
    By furiouscow in forum AutoCAD General
    Replies: 3
    Last Post: 15th Jan 2011, 04:26 pm
  4. How do I turn a polyline into a series of polygons?
    By StaticFriction in forum AutoCAD General
    Replies: 15
    Last Post: 20th Jul 2007, 02:28 pm
  5. polyline(arrays series problem)
    By stary7 in forum AutoLISP, Visual LISP & DCL
    Replies: 0
    Last Post: 21st Sep 2006, 10:23 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