Jump to content

Recommended Posts

Posted

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?

Posted

(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

Posted

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)
)

Posted
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!
Posted

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.

Posted

Doesn't Lee Mac have an elist.lsp? I think it's on his website. It'll do much the same I think...

Posted

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) 
)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...