Jump to content

Entget/Dump a graphical object


Grrr

Recommended Posts

Hi guys,

I don't have any questions, just wanted to share some of my work.

I think it would ease/comfort alot of ya (coders) for your daily job (if you haven't already written such developed version by yourselfs :) ).

; Dump/Entget a graphical object (entsel behaviour), with options
; author: Grrr (thanks to Lee Mac & Tharwat that I've reached such level of coding)
(defun C:test ( / *error* SysVarLst R o m )
(setvar 'errno 0)

(defun *error* ( msg )
	(mapcar '(lambda ( n v / ) (setvar n v)) (mapcar 'car SysVarLst) (mapcar 'cadr SysVarLst))
	(if (not (member msg '("Function cancelled" "quit / exit abort")))
		(princ (strcat "\nError: " msg))
	)
	(princ)
)

(setq SysVarLst
	(mapcar '(lambda ( a b / ) (list a (getvar a) b))
		(list "CLIPROMPTLINES" "CMDECHO" "PDMODE") ; PDMODE, because sometimes is hard to (entsel) a point with PDMODE of 0 value
		(list 1 0 3) ; the new intended values
	)
)

(while (/= 52 (getvar 'errno))
	(mapcar '(lambda ( n v / ) (setvar n v)) (mapcar 'car SysVarLst) (mapcar 'caddr SysVarLst))
	(initget "Entget Dump eXit")
	(if (not m) (setq m "Entget"))
	(setq R (entsel (strcat "\nSelect entity or [Entget/Dump/eXit] <\"" m "\">: ")))
	(cond
		((member (getvar 'errno) '( 7 ))
			(princ "\nMissed, try again! ") ; non-nil return, stay in loop
			(setvar 'errno 0)
		)
		((and (not (listp R))(member (strcase R) '("E" "ENTGET")))
			(if (not (= m "Entget")) (setq m "Entget"))
		)
		((and (not (listp R))(member (strcase R) '("D" "DUMP")))
			(if (not (= m "Dump")) (setq m "Dump"))
		)
		((and (not (listp R))(member (strcase R) '("X" "EXIT")))
			(princ "\nI hope this routine helped! ")
			(mapcar '(lambda ( n v / ) (setvar n v)) (mapcar 'car SysVarLst) (mapcar 'cadr SysVarLst))
			(setvar 'errno 52)
			(vl-cmdf "_.textscr")
		)
		(R
			(cond
				((= (strcase m) "ENTGET")
					(if (= (type (car R)) 'ENAME)
						(progn
							(princ "\n******************** ENTGET RESULTS: ********************")
							(foreach x (entget (car R)) (princ "\n")(print x))
							(princ "\n******************** END OF RESULTS ********************")
						)
					)
				)
				((= (strcase m) "DUMP")
					(if (= (type (setq o (vlax-ename->vla-object (car R)))) 'VLA-OBJECT)
						(progn
							(princ "\n******************** DUMP RESULTS: ********************")
							(vlax-dump-object o T)
							(princ "\n******************** END OF RESULTS ********************")
						)
					)
				)
			); cond 
		)
		(T ; if user pressed enter
			(princ "\nBye, user! ")
			(setvar 'errno 52)
			(mapcar '(lambda ( n v / ) (setvar n v)) (mapcar 'car SysVarLst) (mapcar 'cadr SysVarLst))
			(vl-catch-all-apply (quote textscr) (list))
		)
	); cond
); while go

(princ)
);| defun |; (vl-load-com) (princ)

Link to comment
Share on other sites

Very cool Grr! The only thing I might add (that I have added to mine), is to have the option of diving further into a specific property value (like TrueColor, or basically everything in Civil 3D). I do this by prompting the user after the dump to enter a property value to dive further into if they would like.

Link to comment
Share on other sites

Very cool Grr! The only thing I might add (that I have added to mine), is to have the option of diving further into a specific property value (like TrueColor, or basically everything in Civil 3D). I do this by prompting the user after the dump to enter a property value to dive further into if they would like.

 

Thanks, broncos15!

Your idea sounds very nice, however I'm still green on "exploring" entities (using the entnext/entget, vanilla lisp stuff).

The visual lisp approach with objects and collections seems way easier (maybe because there aren't any associated DXF group codes I need to translate and understand myself).

However my plan is first to make a "map" of the ACAD object model, similar to this: http://www.afralisp.net/reference/autocad-object-model.php or atleast find a better/newer one (as you can see that there is no "TrueColor" aswell).

Link to comment
Share on other sites

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