+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 20
  1. #1
    Senior Member
    Using
    AutoCAD 2007
    Join Date
    Apr 2008
    Posts
    258

    Default Convert Mline To Pline

    Registered forum members do not see this ad.

    Is There Any Way Convert Multiline To Polylines?

  2. #2
    Junior Member
    Using
    AutoCAD 2008
    Join Date
    Jun 2008
    Posts
    14

    Default

    I don't know how to do it directly, but you can always use EXPLODE. Then select a segment and use PEDIT. It asks if you want to convert to a pline. Say "yes" the use JOIN to get all the pieces back together.
    Should work, but does anyone have a more direct way that could eliminate the need to select each segment individually?
    --DM

  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,184

    Default

    Perhaps :

    Code:
    (defun c:m2p (/ vlst ovar ent ss elast)
      (setq vlst '("CMDECHO" "PEDITACCEPT")
        ovar (mapcar 'getvar vlst))
      (if (and (setq ent (car (entsel "\nSelect Multi-Line...")))
           (eq "MLINE" (cdadr (entget ent))))
        (progn
          (mapcar 'setvar vlst '(0 1))
          (command "_explode" ent) (setq ss (ssadd))
          (mapcar '(lambda (x) (ssadd x ss)) (Ent_List_to_End ent))
          (setq elast (entlast))
          (command "_pedit" "_M" ent ss elast "" "_J" "" ""))
        (princ "\n<!> No Multi-Line Selected <!>"))
      (mapcar 'setvar vlst ovar)
      (princ))
    
    (defun Ent_List_to_End(ent / a)
      (reverse
        (if(setq a(entnext ent))
           (cons ent(Ent_List_to_End a)))))
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

  4. #4
    Senior Member
    Using
    AutoCAD 2007
    Join Date
    Apr 2008
    Posts
    258

    Default

    Thanks Lee Mac For Your Help As I Expect From You ALWAYS
    And Thank You Also Drainmasta Really I Want Lisp Routine To Do That And Lee Mac Make It


    Thanks Again Guys For Your Help

  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,184

    Default

    No probs, happy to help Mr Man
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

  6. #6
    Junior Member
    Using
    AutoCAD 2008
    Join Date
    Dec 2009
    Posts
    17

    Default lee mac great man

    u r a great man lee thank u thank u thank u for this code it is too useful..

  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,184

    Default

    Quote Originally Posted by aryanarch View Post
    u r a great man lee thank u thank u thank u for this code it is too useful..
    You're welcome
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

  8. #8
    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,184

    Default

    This is probably better:

    Code:
    (defun c:m2p (/ *error* EntNext_to_End DOC ELST ENT I MSS OV SS UFLAG VL)
      ;; MLine to PLine  ~  Lee Mac  ~  04.01.10
    
      (defun *error* (msg)
        (and ov    (mapcar (function setvar) vl ov))
        (and uflag (vla-EndUndoMark doc))
        (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
            (princ (strcat "\n** Error: " msg " **")))
        (princ))
    
      (defun EntNext_to_End (ent / a)
        (if (setq ent (entnext ent))
          (cons ent (EntNext_to_End ent)))) 
    
      (setq vl '("CMDECHO" "PEDITACCEPT" "QAFLAGS")
            ov  (mapcar (function getvar) vl) ss (ssadd))
    
      (mapcar (function setvar) vl '(0 1 0))
    
      (if (setq i -1 mss (ssget "_:L" '((0 . "MLINE"))))
        (progn
          (setq uFlag (not (vla-StartUndoMark
                             (setq doc (vla-get-ActiveDocument
                                         (vlax-get-acad-object))))))
    
          (while (setq ent (ssname mss (setq i (1+ i))))
            (setq eLst (entlast) ss (ssadd))
    
            (vl-cmdf "_.explode" ent)
    
            (mapcar (function (lambda (x) (ssadd x ss)))
                    (EntNext_to_End eLst))
    
            (vl-cmdf "_.pedit" "_M" ss "" "_J" "" "")
            (setq ss nil))
    
          (setq uFlag (vla-EndUndoMark doc))))
    
      (mapcar (function setvar) vl ov)
      (princ))
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

  9. #9
    Forum Newbie
    Using
    Land Desktop 2009
    Join Date
    Oct 2010
    Posts
    6

    Default

    Hey Lee, I was wondering if you could help me out too. I'm looking for a similar lisp to the one you wrote but with a little extra. I tried to combine yours with another lisp I found and had some success but I still can't figure out how to finish it off. I'm trying to draw an Mline, have it explode and made into a polyline, and then put the polylines created on 2 or 3 specific layers. I'm up to the point where I have your lisp make the polylines and they end up on a single layer that was made current at some point in the lisp, but I can't figure out how to select certain lines to bring to a new current layer. or something like that.

  10. #10
    Forum Newbie
    Using
    Land Desktop 2009
    Join Date
    Oct 2010
    Posts
    6

    Default

    Registered forum members do not see this ad.

    Here's your edited code I was working with:

    Code:
    (defun c:mlb ( / *error* vl ov LastEntity ent ss currlay)
      ;; © Lee Mac  ~  19.06.10
        
    
    (setq currlay (getvar "clayer"))
    (SETQ lr1 (TBLSEARCH "LAYER" "P-SD-CL-L"))	
    (IF (= LR1 NIL)	
    (COMMAND "LAYER" "MAKE" "P-SD-CL-L" "COLOR" "BYLAYER" "" ""))
    (command "layer" "set" "P-SD-CL-L" "" "")
    
        ;;Sco'S COMMENTS - SETS LAYER FOR NEW OBJECTS, IF MISSING, CREATES IT.
    
      (defun *error* ( msg )
        (mapcar 'setvar vl ov)
        (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
            (princ (strcat "\n** Error: " msg " **")))
        (princ))
    
       
    
      (setq vl '("CMDECHO" "PEDITACCEPT" "QAFLAGS")
            ov (mapcar 'getvar vl))
    
      (setq LastEntity (entlast))
    
       
    
      (command "_.mline" "ST" "B")
      (while (= 1 (logand 1 (getvar 'CMDACTIVE)))
        (command pause))
        (prompt "pick")
    
        
    
      (if (not (equal LastEntity (setq ent (entlast))))
        (progn
          (mapcar 'setvar vl '(0 1 5))
    
       
          
          (vl-cmdf "_.explode" ent "")
    
       
    
    
    
          (setq ss (ssadd))
          (mapcar '(lambda ( e ) (ssadd e ss)) (LM:EntnexttoEnd ent))
    
          (vl-cmdf "_.pedit" "_M" ss "" "_J" "" "")))
    
         (mapcar 'setvar vl ov)
         (princ)
    (I hope I didn't mess it up too bad)

    So I'm using a 3 line Mline with one in the center and 2 offset .5 either side. I have all brought on to the P-SD-CL-L layer. At the end I was want to select the 2 outer lines and bring them onto a new layer (P-SD-L), but leave the center on P-SD-CL-L. I kept trying to change current layer again and then select 2 previous but I just couldn't figure it out.

    Any help would be greatly appreciated.

Similar Threads

  1. Can I convert an oval to a pline?
    By pico in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 6th Jun 2007, 03:28 am
  2. Why can't I convert this to one single pline?
    By CADIDAC in forum AutoCAD 3D Modelling & Rendering
    Replies: 23
    Last Post: 27th Feb 2007, 03:11 pm
  3. mline
    By comcu in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 26th Jan 2007, 03:08 pm
  4. convert spline to pline
    By wanni in forum AutoCAD Beginners' Area
    Replies: 1
    Last Post: 10th Nov 2005, 04:04 am
  5. Convert Spline to Pline
    By f700es in forum AutoCAD Drawing Management & Output
    Replies: 10
    Last Post: 19th Feb 2004, 01:31 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