Hello,
I am using AutoCAD 2022.
I am checking if there is any lisp available to fetch layer information from selected polylines and create a table showing the layer names (related to selected polylines only).
Thanks in advance to all the subject matter experts.
Solved! Go to Solution.
Solved by ВeekeeCZ. Go to Solution.
Solved by ВeekeeCZ. Go to Solution.
Solved by sandeep.kumarPKH3F. Go to Solution.
Solved by ВeekeeCZ. Go to Solution.
Dataextraction command is perfect for this.
It opens up a wizard where you can choose to select objects
Choose create new and click Next then give it a name like Pline and click Save
Then choose the option to Select Objects in current drawing and click on the button right next to it
Select the Plines on the screen and hit return when done
click Next 2x
Then for Category only check General & Property only check Layer
Click Next button and you should now see the Plines you've selected and the Layer they're on
You can remove the Count column by unchecking Show count column and click Next
Lastly select Insert data extraction Table into drawing and click Next
You may have to zoom in really tight to see the Table.
Thanks Paulli,
I basically want to eliminate some of the steps from data extraction command.
I need that it should automatically fetch layer information from the selected polylines and place a table with the layer information in the drawing.
I am not sure if we could use script to meet this requirement otherwise we need a lisp.
Possibly this simple lisp could do that.
(vl-load-com) (defun c:Layerlist ( / s i y l) (if (setq s (ssget '((0 . "*POLYLINE")))) (progn (repeat (setq i (sslength s)) (setq y (cdr (assoc 8 (entget (ssname s (setq i (1- i))))))) (if (not (vl-position y l)) (setq l (cons y l)))) (entmake (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") (cons 10 (getpoint "\nPlace the list: ")) (cons 40 (getvar 'textsize)) (cons 1 (strcat "LAYERLIST: " (apply 'strcat (mapcar '(lambda (x) (strcat (chr 10) x)) (vl-sort l '<))))))))) (princ) )
Ok then.
(vl-load-com) (defun c:Layerlist ( / s i y l) (if (setq s (ssget '((0 . "*POLYLINE")))) (progn (repeat (setq i (sslength s)) (setq y (cdr (assoc 8 (entget (ssname s (setq i (1- i))))))) (if (not (vl-position y l)) (setq l (cons y l)))) (command "_mleader" "_h" pause pause (strcat "LAYERLIST: " (apply 'strcat (mapcar '(lambda (x) (strcat (chr 10) x)) (vl-sort l '<))))))) (princ) )
Well, it works for me. You can try to remove "_h" from the code.
Also, you might need to add another pause - it's depending on your style preference.
If neither works, post screenshots of your mleader style dialog - the second and third tabs.
Just a suggestion, whilst the code does a sort now should it reflect the layers in the drawn order ? Water Gas Elec Telecomms, more like the multi plines I am used to.
(setq s (ssget "F" (list pt1 pt2) '((0 . "*POLYLINE"))))
The pt1 pt2 are pick points for the direction of selection then layers will be in select order.
@ВeekeeCZ , I am facing an issue with the layerlist lisp. It is working fine for few numbers of layers, but when number of layers are more, it is only printing the leader in the model space and layer names are only showing up at the command bar history.
Could you please help me to fix it.
Thanks
ALWAY post a sample drawing.
Try this if it fixes it.
(vl-load-com) (defun c:Layerlist ( / s i y l) (if (setq s (ssget '((0 . "*POLYLINE")))) (progn (repeat (setq i (sslength s)) (setq y (cdr (assoc 8 (entget (ssname s (setq i (1- i))))))) (if (not (vl-position y l)) (setq l (cons y l)))) (command "_mleader" pause pause "") (if (> (getvar 'cmdactive) 0) (progn (command) (alert "ERROR: Wrong workflow setting of the MLEADER command.\n\nGoto the MLEADER command and adjust the setting to specify an Arrowhead or Landing first.")) (setpropertyvalue (entlast) "MText/Contents" (strcat "LAYERLIST: " (apply 'strcat (mapcar '(lambda (x) (strcat (chr 10) x)) (vl-sort l '<)))))))) (princ) )
Can't find what you're looking for? Ask the community or share your knowledge.