TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Mark on September 14, 2005, 10:25:38 AM
-
How do you get the 'true' name of a Dynamic Block?
-
(vla-get-EffectiveName (vlax-ename->vla-object (car (entsel "\nSelect Dynamic Block: "))))
Peter Jamtgaard P.E.
-
Thats hittin below the belt, c'mon now.
AutoCAD 2002 = N/A
*AutoCAD 2006 = DXF Group Code -1
*Denotes the inability to fully process request based on insufficient resources, processor has determined best possible answer based on availability of internal memory.
-
:-o
Where did that come from D?
-
<conjures up best Jeff Spicoli impression> "Dude, that was my skull... heh, heh, I'm so wasted!"
-
_LIST
_PROPERTIES
_BEDIT
AxPROPS
.. are a couple that come to mind ..
-
Peter came up with the answer but if you all notice it took an Engineer to answer my question.
I recently took a trek to research that bit of info to pen this beut. RIB (http://www.theswamp.org/forum/index.php?topic=6810.0) :mrgreen:
-
You can also link between them using xdata
Peter Jamtgaard ...
; Written By: Peter Jamtgaard copr 2005
; Extraction of Dynamic Block Real Name from
; Anonymous block entity using Xdata
; Syntax (getrealname (car (entsel)))
(defun GetRealName (objSelection /
lstEntity
lstXdata
entBlockReference
objBlockReference
objSelection
strBlockName
strHandle
)
(if (= (type objSelection) 'ENAME)
(setq objSelection (vlax-ename->vla-object objSelection))
)
(if (wcmatch (vla-get-objectname objSelection)
"AcDbBlockReference,AcDbMInsertBlock"
)
(progn
(setq strBlockName (vla-get-name objSelection))
(if (and (= (substr strBlockName 1 1) "*")
(setq objBlockReference (vla-item
(vla-get-blocks
(vla-get-activedocument
(vlax-get-acad-object)))
(vla-get-name objSelection)))
(setq lstEntity (entget (vlax-vla-object->ename objBlockReference)
(list "AcDbBlockRepBTag")))
(setq lstXdata (assoc -3 lstEntity))
(setq strHandle (cdr (assoc 1005 (cdadr lstXdata))))
(setq entBlockReference (handent strhandle))
)
(setq strBlockName (vla-get-name
(vlax-ename->vla-object entBlockReference)))
)
)
)
strBlockName
)
Here is a bit more code for dynamic blocks :-P
(defun GetDynamicBlockPropertyList (objSelection / lstProperties)
(if (and (vlax-property-available-p objSelection "IsDynamicBlock")
(= (vla-get-IsDynamicBlock objSelection) :vlax-true)
(setq lstProperties (errortrap '(vlax-safearray->list
(variant-value
(vla-GetDynamicBlockProperties objSelection)
)
)
)
)
)
(progn
(print lstProperties)
(mapcar '(lambda (x)(cons (vla-get-propertyname X)(variant-value (vla-get-value X)))) lstProperties)
)
)
)