Author Topic: Best way to get a list of block names defined in an objectdbx document?  (Read 2298 times)

0 Members and 1 Guest are viewing this topic.

mkweaver

  • Bull Frog
  • Posts: 352
I need to get a list of block definitions which have attributes contained in an objectdbx document.

I know I can iterate the database and find block insertions and from those check to see that they have attributes, but I don't want to exclude defined blocks which are not inserted.

I'm hoping to avoid iterating the block definition.

Any suggestions welcome.

Mike

JohnK

  • Administrator
  • Seagull
  • Posts: 10669
Code: [Select]
(vlax-for x
 (setq dbxdoc-block-collection (vla-get-blocks $dbxdoc$))
 (if  <something>
  <blah, blah>
 )
)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

T.Willey

  • Needs a day job
  • Posts: 5251
I didn't see a way to test if a block definition has attribute with ActiveX, but it seems like you can with dxf codes.  Look at code 70, and see if bit 2 is set.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

JohnK

  • Administrator
  • Seagull
  • Posts: 10669
;   HasAttributes (RO) = -1
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

T.Willey

  • Needs a day job
  • Posts: 5251
;   HasAttributes (RO) = -1
Block Definition, not Block Reference.

Quote
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00c2eb8c>
;   BlockScaling = 0
;   Comments = ""
;   Count (RO) = 4
;   Document (RO) = #<VLA-OBJECT IAcadDocument 072f8dd4>
;   Explodable = -1
;   Handle (RO) = "C3"
;   HasExtensionDictionary (RO) = 0
;   IsDynamicBlock (RO) = 0
;   IsLayout (RO) = 0
;   IsXRef (RO) = 0
;   Layout (RO) = AutoCAD.Application: The property is not available in current state
;   Name = "Det-Bub"
;   ObjectID (RO) = 2127741080
;   ObjectName (RO) = "AcDbBlockTableRecord"
;   Origin = (0.0 0.0 0.0)
;   OwnerID (RO) = 2127629320
;   Path = AutoCAD.Application: Not applicable
;   Units = 1
;   XRefDatabase (RO) = AutoCAD.Application: No database
; Methods supported:
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

JohnK

  • Administrator
  • Seagull
  • Posts: 10669
Ahh, i see. Yes, go for DXF codes then.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

mkweaver

  • Bull Frog
  • Posts: 352
Ahh, i see. Yes, go for DXF codes then.

But, can I get the DXF codes for on object in an objectdbx document?

jbuzbee

  • Swamp Rat
  • Posts: 851
Yes
(vlax-vla-object->ename dbxdoc)

I do this all the time for working with dictionaries.  If there was just a vla-has function . . .  :x
James Buzbee
Windows 8

T.Willey

  • Needs a day job
  • Posts: 5251
If there was just a vla-has function . . .  :x
Kind of round-about, but I have done it like

Code: [Select]
(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-Item (list ColObj Name)))
 .... doesn't exist
 .... does exist
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

mkweaver

  • Bull Frog
  • Posts: 352
Yes
(vlax-vla-object->ename dbxdoc)

I do this all the time for working with dictionaries.  If there was just a vla-has function . . .  :x

. . .
Well, doesn't that open up a whole new world.

I've been working with vlisp since Autodesk first made it available for purchase, and never tried that on an objectdbx object.  This solves several problems all at once.

Thanks,
Mike

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Best way to get a list of block names defined in an objectdbx document?
« Reply #10 on: April 15, 2008, 04:37:27 PM »
Quote
Kind of round-about, but I have done it like

Yep, when theres absolutely no other way.  I find that whole error catching thing messy . . .

Interesting thing is most of the AEC type libraries that ship with ADT / Architecture have a has method for the different collections.
James Buzbee
Windows 8