Author Topic: Create Lwpolyline from selection  (Read 3157 times)

0 Members and 1 Guest are viewing this topic.

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Create Lwpolyline from selection
« on: October 11, 2011, 09:09:27 AM »

I have a need for a routine to select an "Mpolygon" and based on the selection have it create a "LwPolyline" out of it via automated, not by user selection. So the end result would be an exact copy (per say) of the object except now it's a "LwPolyline.
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Create Lwpolyline from selection
« Reply #1 on: October 11, 2011, 09:21:20 AM »
What is an 'MPolygon' ?

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Create Lwpolyline from selection
« Reply #2 on: October 11, 2011, 09:26:59 AM »
dunno, but it sounds special
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Create Lwpolyline from selection
« Reply #3 on: October 11, 2011, 09:40:56 AM »
dunno, but it sounds special

Seeing as it starts with the letters 'MP' .. :lol:

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Create Lwpolyline from selection
« Reply #4 on: October 11, 2011, 09:42:53 AM »

I am sorry guys, this is a AutoCAD MAP function.
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Create Lwpolyline from selection
« Reply #5 on: October 11, 2011, 09:55:22 AM »
Seeing as it starts with the letters 'MP' .. :lol:

prolly rides to school on the short bus
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

didier

  • Newt
  • Posts: 48
  • expatriι
Re: Create Lwpolyline from selection
« Reply #6 on: October 17, 2011, 05:50:31 AM »
Coucou

you can "explode" the "MPOLYGON"
it becomes a polyline.

please, excuse my bad English.

amicalement
eternal beginner ...
my english is not fluent ...

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Create Lwpolyline from selection
« Reply #7 on: October 17, 2011, 06:30:15 AM »
Hi,

Quote
What is an 'MPolygon' ?
Quote
dunno, but it sounds special

You can see here that MPolygons which are MAP entities can be supported by AutoCAD (Vanilla).
The LISP routine is only a simple example, in reply #10, you can find a little .NET DLL where the PL2MPG command is defined. This command will convert polylines (2d) and circles into Mpolygons.
« Last Edit: October 17, 2011, 06:58:57 AM by gile »
Speaking English as a French Frog

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Create Lwpolyline from selection
« Reply #8 on: October 17, 2011, 06:39:23 AM »
gile, I think you forgot to add the hyperlink to your post  :wink:

EDIT: Thanks for updating :)
« Last Edit: October 17, 2011, 06:59:23 AM by Lee Mac »

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Create Lwpolyline from selection
« Reply #9 on: October 17, 2011, 07:00:15 AM »
Oopsss !
Repared.
Speaking English as a French Frog

kraz

  • Guest
Re: Create Lwpolyline from selection
« Reply #10 on: October 18, 2011, 07:23:24 AM »
In my short english, you mean mpolygon convert into lwpolyline...right?
if you want to that, here are my convert prog.
Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:mp2lwp( / v8 sn ss i sl vtx pl)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun GetMPolyVtx (ent / v11 x y xylist v10s v nx ny)
  (defun mPolyVtx(Ent / AA X vtxlist)
    (setq VtxList '())
    (IF (= "MPOLYGON" (CDR (ASSOC 0 Ent)))
       (mapcar '(lambda (x) (if (= 10 (car x)) (setq VtxList (append VtxList (list (cdr x))) ) ) ) Ent)
       (PROGN
        (SETQ AA (ENTGET(ENTNEXT (CDR (ASSOC -1 Ent)))))
        (WHILE (/= "SEQEND" (CDR (ASSOC 0 AA)))
         (setq VtxList (append VtxList (list (cdr (ASSOC 10 AA)))))
         (SETQ AA (ENTGET(ENTNEXT (CDR (ASSOC -1 AA)))))
        )
      )
    );IF
     VtxList
  )
  (setq v11 (cdr (assoc 11 ent)));;mpolygon center point
  (setq x (car v11))
  (setq y (cadr v11))
  (setq xylist (list))
  (setq v10s (mpolyvtx ent))
  (foreach v v10s
    (setq x1 (car v) y1 (cadr v))
    (setq nx (+ x x1) ny (+ y y1))
    (setq xylist (append xylist (list (list nx ny 0))))
  )
  xylist
)
(defun make_pline (pte_list lay color cls / pl_source ptelen cnt ptele pte_list ptes epl8 epl62 )
 (setq pl_source (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 67 0)
                 (cons 62 color) (cons 8 lay) (cons 100 "AcDbPolyline")))
 (setq ptelen (length pte_list)
       cnt 0)
 (setq pl_source (append pl_source (list (cons 90 ptelen))))
 (if (or (eq cls "c")(eq cls "C")(eq cls "1")(eq cls 1))
  (progn
   (setq cls 1)
   (setq pl_source (append pl_source (list (cons 70 cls))))
  )
 )
 (while (< cnt ptelen)
   (setq ptele (car pte_list)
         pte_list (cdr pte_list)
        ptes (cons 10 ptele)
        pl_source (append pl_source (list ptes))
         cnt (+ cnt 1)
  )
 );;while end
 (entmake pl_source)
 (entlast)
);entmake_pline
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (princ "\n SELECT MPOLYGON >> ")
 (setq ss (ssget (list (cons 0 "MPOLYGON")))
       sl (sslength ss)
       i 0
 )
 (repeat sl
  (setq sn (ssname ss i)
        i (1+ i)
        vtx (cdr (getmpolyvtx (entget sn)))
        vtx (append vtx (list (nth 0 vtx)))
        v8 (cdr (assoc 8 (entget sn)))
        pl (make_pline vtx v8 256 "c")
  )
  (entdel sn)
 );repeat end
 (princ "\n...COMPLETE...")(princ)
)
« Last Edit: October 18, 2011, 09:19:39 AM by CAB »

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
Re: Create Lwpolyline from selection
« Reply #11 on: October 20, 2011, 12:40:59 PM »

Quote
In my short english, you mean mpolygon convert into lwpolyline...right?
if you want to that, here are my convert prog.

Yes, and Thank you. This works perfect.
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Create Lwpolyline from selection
« Reply #12 on: October 20, 2011, 12:54:32 PM »
Just explode it.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox