NirantarVidyarthee Posted September 10 Share Posted September 10 (edited) There is a function in VLisp - (vlax-ename->vla-object) - that converts an entity name to vla Object. Thus (vlax-ename->vla-object (tblobjname "layer" "0")) correctly returns a layer object #<VLA-OBJECT IAcadLayer 000000002abcbb08> (vlax-ename->vla-object (tblobjname "style" "standard")) also correctly returns a text style object #<VLA-OBJECT IAcadTextStyle 000000002abcbdd8> but (vlax-ename->vla-object (tblobjname "block" "b1")) behaves differently and returns entity #<VLA-OBJECT IAcadEntity 000000002b08aea8> and not IAcadBlock object as expected. We have to use (vlax-ename->vla-object (cdr (assoc 330 (entget (tblobjname "block" "b1")))) ) to get the value of Block (definition) object #<VLA-OBJECT IAcadBlock 0000000033f12c18> I am curious to know the reason of this 'non-standard' behavior. I believe it has something to do with how AutoCAD internally stores the blocks. Can anybody explain why and how this happens? Edited September 10 by NirantarVidyarthee Quote Link to comment Share on other sites More sharing options...
Steven P Posted September 10 Share Posted September 10 I don't worry too much about this, a lot of the odd things that happen in LISP are historical and can be traced to the development of Autocad from it's initial release to the current version. Many of these are retained for backwards compatibility. So yes, the difference is how the data is stored and recorded, I am not an expert at what the difference is and why but I would suspect that the first 2, layer and style are not object definitions. block is the whole object definition ad contains layer and style as necessary. CAD is off today so I can't confirm but maybe you could check if say a line, circle, or text requires the last method Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 10 Share Posted September 10 Because the tblobjname function returns an AcDbBlockBegin object for the Block Symbol Table so as to facilitate iterating over the block components (until an AcDbBlockEnd object is encountered); the AcDbBlockBegin class is derived from the AcDbEntity class, hence the equivalent ActiveX interface object is an IAcadEntity object. You can also observe this through the DXF data for the entities - tblobjname will return a BLOCK entity of class AcDbBlockBegin which is derived from the AcDbEntity base class: ( (-1 . <Entity name: 20458ff8900>) (0 . "BLOCK") (330 . <Entity name: 20458ff88a0>) (5 . "3C0") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbBlockBegin") (70 . 0) (10 0.0 0.0 0.0) (-2 . <Entity name: 20458ff88b0>) (2 . "test") (1 . "") ) The parent entity is a BLOCK_RECORD entity of class AcDbBlockTableRecord which is derived from the AcDbSymbolTableRecord base class: ( (-1 . <Entity name: 20458ff88a0>) (0 . "BLOCK_RECORD") (5 . "3BA") (102 . "{ACAD_XDICTIONARY") (360 . <Entity name: 20458ff88e0>) (102 . "}") (330 . <Entity name: 20458fef810>) (100 . "AcDbSymbolTableRecord") (100 . "AcDbBlockTableRecord") (2 . "test") (360 . <Entity name: 20458ff8900>) (340 . <Entity name: 0>) (102 . "{BLKREFS") (331 . <Entity name: 20458ff8920>) (102 . "}") (70 . 4) (280 . 1) (281 . 0) ) 3 Quote Link to comment Share on other sites More sharing options...
NirantarVidyarthee Posted September 11 Author Share Posted September 11 Thank you both. Its clear now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.