I am checking for effectivename with...
(setq blkname (vla-get-effectivename blkobj))
... but it fails with an Automation Error. Null object ID.
when I checked the block with LIST command. All I get is:
BLOCK REFERENCE Layer: "Trapeze Hangers"
Space: Model space
Handle = 600fcc
How can I trap this error so as to not crash my code?
Solved! Go to Solution.
Solved by Lee_Mac. Go to Solution.
The 'sledgehammer' approach would be something like:
(if (not (vl-catch-all-error-p (setq bln (vl-catch-all-apply 'vla-get-effectivename (list blkobj)) ) ) ) bln )
But I'd be interested to know why the method is failing...
I am not sure I can re-create the issue. We've had a few occurrances in the past when inserting a block ended up in inserting a 'bad' block reference. The user does the insert and nothing shows up inpite of all settings saying it should (layers on and thawed, etc). I one case the user inserted a bunch of them before giving me a call. The only way I've been able to catch it is to do LIST with L (for last object added to the database) right after the user did the insert. When you do LIST command all you get is:
BLOCK REFERENCE Layer: "Trapeze Hangers"
Space: Model space
Handle = 600fcc
... nothing else! No insertion point, no X, Y or Z scale factor, no rotation angle, no other properties whatsoever.
The first time I saw this I thought it had to do with the user modeling far, far away from world origin... but I couldn't prove that.
So, I ran into this again when I was running ObjectDBX on a slug of the drawing files. This is what prompted this post.
here... I was able to find the drawing and cleaned it up leaving only the bad block.
I'd be interested in what you find.
If you do LIST on ALL... this is what you'll get
oops... do LIST on ALL... this is what you'll get... you see a grip also.
BLOCK REFERENCE Layer: "Trapeze Hangers"
Space: Model space
Handle = 11
I'd be interested in what you find.
I think how I eliminated the bad blocks was to do Erase All then remove with a window selection... the bad blocks were all that was left.
I'm not sure what causes the bad block reference, but auditing the drawing seems to fix it.
Lee