broncos15 Posted November 19, 2015 Posted November 19, 2015 So I have been trying to make a lisp routine that would allow the user to select an object and have it print the dxf information. My code is as follows: ;used AutoCAD About Obtaining Entity Information as starting point. (defun C:PRINTDXF ( / ct ent entl) (setq ent (ssget "_+.:E:S")) ; Set ent to selected entity. (setq entl (entget ent)) ; Set entl to association list of last entity. (setq ct 0) ; Set ct (a counter) to 0. (textpage) ; Switch to the text screen. (princ "\nentget of selected entity:") (repeat (length entl) ; Repeat for number of members in list: (print (nth ct entl)) ; Output a newline, then each list member. (setq ct (1+ ct)) ; Increments the counter by one. ) (princ) ; Exit quietly. ) The code isn't working correctly, but it works if I use entlast instead of ssget. I need to be able to select an object though. I get the following error "; error: bad argument type: lentityp " What is my mistake with ssget? Quote
David Bethel Posted November 19, 2015 Posted November 19, 2015 (ssget) returns a PICKSET that you must extract the members ENAMEs. (setq en (ssname ss 0)) for a single slection (entlast) returns 1 ENAME. (entget) works with ENAMEs only. -David Quote
Tharwat Posted November 19, 2015 Posted November 19, 2015 Compare these mods to yours. (defun C:PRINTDXF (/ ent) (if (setq ent (ssget "_+.:E:S")) (progn (princ "\nentget of selected entity:") (foreach x (entget (ssname ent 0)) (print x) ) (textpage) ) ) (princ) ) Quote
broncos15 Posted November 19, 2015 Author Posted November 19, 2015 Compare these mods to yours. (defun C:PRINTDXF (/ ent) (if (setq ent (ssget "_+.:E:S")) (progn (princ "\nentget of selected entity:") (foreach x (entget (ssname ent 0)) (print x) ) (textpage) ) ) (princ) ) Tharwat, that worked like a charm. I hadn't realized I needed to use ssname with the ssget, but that is really good to know. David, your mod worked on my original code as well, and that is good information for me to know. Thank you both! Quote
Tharwat Posted November 19, 2015 Posted November 19, 2015 You are welcome . As David described earlier , you need to retrieve the name of the selection set with the function ssname as I used it in my previous example otherwise the entlast would get the last entity in the drawing. Good luck. Quote
iconeo Posted November 19, 2015 Posted November 19, 2015 Doesn't Lee Mac have an elist.lsp? I think it's on his website. It'll do much the same I think... Quote
BIGAL Posted November 20, 2015 Posted November 20, 2015 Why not just use Entsel this is for a single entity selection, the other for all the VL answers dumpit.lsp, it uses entsel. ;;; Dump all methods and properties for selected objects ; ;;;===================================================================; ;;; DumpIt ; ;;;-------------------------------------------------------------------; ;;;===================================================================; (defun C:DumpIt ( / ent) (while (setq ent (entsel)) (vlax-Dump-Object (vlax-Ename->Vla-Object (car ent)) T ) ) (textpage) (princ) ) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.