- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone.
I have some code that converts selected linear entities to multilines. I intended to do the conversion in two ways, depending on a certain condition:
• if the entities are already selected then the program will convert them to multilines.
• if there are no selected entities, then the entsel function is started, and the loop is running for transforming picked entities.
Here's the code:
(defun c:Convert2MLine ( / ss teller en ent PtLst )
(setq ss (ssget "_I" '((0 . "LINE,LWPOLYLINE"))))
(setq teller 0)
(if ss
(repeat (sslength ss)
(setq en (ssname ss teller))
(setq ent (entget en))
(if (= "LINE" (cdr (assoc 0 ent)))
(setq PtLst (list (cdr (assoc 10 ent)) (cdr (assoc 11 ent))))
)
(if (= "LWPOLYLINE" (cdr (assoc 0 ent)))
(setq PtLst (LM:MAssoc 10 ent))
)
(command "_MLINE" (foreach pt PtLst (command pt)))
(entdel en)
(setq teller (1+ teller))
)
(while
(setvar 'errno 0)
(progn
(while
(progn
(setvar 'errno 0)
(setq en (car (entsel "\nPick a polyline: ")))
(cond
( (= 7 (getvar 'errno))
(princ "\nMissed, try again.")
)
( (= 'ename (type en))
(if (/= (cdr (assoc 0 (entget en))) "LWPOLYLINE")
(princ "\nInvalid object selected.")
)
)
)
)
)
)
(if (= "LINE" (cdr (assoc 0 ent)))
(setq PtLst (list (cdr (assoc 10 ent)) (cdr (assoc 11 ent))))
)
(if (= "LWPOLYLINE" (cdr (assoc 0 ent)))
(setq PtLst (LM:MAssoc 10 ent))
)
(command "_MLINE" (foreach pt PtLst (command pt)))
(entdel en)
)
)
(princ)
)
(defun LM:MAssoc ( key lst / pair return )
(while (setq pair (assoc key lst))
(setq return (cons (cdr pair) return) lst (cdr (member pair lst)))
)
(reverse return)
)
Now I have achieved that only the first part of the program is executed correctly if the entities were already selected before the command was run. That is, only ssget works, but entsel does not work.
I would like to ask for help to implement the following features in this routine:
1. Correct execution program using entsel method (if the entities were not previously selected before starting the command).
2. If possible, expand the list of objects available for conversion to multilines, namely, I would like the following objects to be available for conversion: AcDbLine, AcDbPolyline, AcDb2dPolyline, AcDb3dPolyline.
3. The most important point. The ability to get the multilines that were created as entities that can be manipulated. That is, roughly speaking, I need to return the created multilines as a set of entities so that can later change their properties using vla methods.
I hope I didn't express my thoughts too chaotically.
Any help would be greatly appreciated.
Thank you in advance!
Solved! Go to Solution.