(defun c:dump ( / blocks )
(defun sub ( blk / subblk )
(vlax-for ob blk
(if (and
(= (vla-get-ObjectName ob) "AcDbBlockReference")
(setq efName (vlax-get ob
(if (vlax-property-available-p ob 'EffectiveName)
'EffectiveName
'Name
)
)
)
(setq subblk (vla-item blocks efName))
(= (vla-get-IsXref subblk) :vlax-false)
)
(progn
(vlax-dump-object ob)
(sub subblk)
)
nil
)
)
)
(setq blocks (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))))
(vlax-for b blocks
(if (and (= (vla-get-IsXref b) :vlax-false)
(= (vla-get-IsLayout b) :vlax-false)
(/= (substr (vla-get-Name b) 1 1) "*")
)
(progn
(vlax-dump-object b)
(sub b)
)
)
)
(princ)
)
(defun scan ( blk / )
(vlax-for i blk
(checkscale i)
(scan i)
)
)
(vlax-for itm (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object)))
(scan itm)
)
checkscale
tests the scale and modifies it when necessary.So there is no need for recursion? I think I get it. Only one level deep needs is enough because the nested block, with nested blocks in it, will also be in the vla-get-blocks list.Yes exactly, there's only one list of block definitions in the drawing. Even if a block is placed within another's definition, it doesn't mean the nested block is removed from the drawing's block-list.
Thanks.
Note though that it would iterate over each version of a DB, since a change in a property would make an anonymous block with the same EffectiveName as the original. Thus you might want to check on this.
(vlax-put-property obj 'XEffectiveScaleFactor 1.0)
Command: LS
LIST 1 found
BLOCK REFERENCE Layer: "0"
Space: Model space
Handle = 25d
Block Name: "test2"
Anonymous Name: "*U5"
at point, X=2291.9786 Y=1127.8018 Z= 0.0000
X scale factor: 1.0000
Y scale factor: 1.0000
rotation angle: 0
Z scale factor: 1.0000
InsUnits: Millimeters
Unit conversion: 1.0000
Scale uniformly: No
Allow exploding: Yes
Distance1: 1142.0613
Angle1: 27
Now I wrote this lisp into the command line:Command: (vlax-for blk (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))) (vlax-dump-object blk))
; IAcadModelSpace: A special Block object containing all model space entities...
; Name = "*Model_Space"...
; IAcadPaperSpace: A special Block object containing all the entities in the active paper space layout...
; Name = "*Paper_Space"...
; IAcadBlock: A block definition containing a name and a set of objects...
; Name = "*Paper_Space0"...
; IAcadBlock: A block definition containing a name and a set of objects...
; Name = "test2"[/color]...
; IAcadBlock: A block definition containing a name and a set of objects...
; Name = "*U5"...
Note the last 2 blocks are actually the same definition, only the 2nd is the version of test2 where the parameter has changed. Also note that the Block Definition object does not have an EffectiveName property, only Block References do.I only wish Autodesk did not create a unitless cad system back then....Actually, since I'm now in Revit nearly full-time, I'm not too sure if it's a bad thing. Revit internally draws every thin in feet. Even if the project units are set to be mm (or even inches) it's still saved as feet. That means each and every dimension and each time you enter a distance it gets converted from feet to the project units and back. In some cases this causes in-accurate dimensions, due to the floating-point errors involved with saving fractional numbers, small though they may be they compound on top of each other.