Hi, I am trying to create a function or class can be used with the MdiActiveDocument and also with the external Database. In order words the function or class should be able to access current Document and also non-opened Databases.
My difficulty is accessing the non-opened drawings and utilizing the SelectionSet to select blocks with SelectionFilter like I could do with a MdiActiveDocument.
I would like to know if what I am trying to do is even possible, or would I have physically open the drawing to have the ability to utilize SelectionSet and filters.
Thank you in advance,
>> I would like to know if what I am trying to do is even possible
No, as the SelectionSet is part if the Editor-Namespace it's only available for drawings in the editor.
To get the same functionality in drawings not opened in the editor you have to scan through the blocktables (ModelSpace and Layouts).
One help to that is that the ObjectID allready knows the DXF-Name of the object so it is not necessary to open each object (via transaction or via open). So to scan for Lines you can use
if myObjectId.ObjectClass.DxfName = "LINE" then
The other option to look for BlockReferences is to find the BlockTableRecord with the name you look for and then use
tBlockTabRec.GetBlockReferenceIds(directOnly As Boolean, forceValidity As Boolean)
to get the ObjectID's from all references inserted in the drawing.
- .alfred -
Try setting the HostApplicationServices.WorkingDatabase property to the database you want to do the filtered selection on just before you call GetSelection), and immediately set that same property to the active document's database as soon as GetSelection() returns.
Thank you DiningPhilosopher and Alfred,
I ended useing something very similar to your proposal: Database.CurrentSpaceId. Then just iterate all block in that space for the block name. That worked very well.
Again, thank you both very much.
I just learned something, thank you for the tip! (even my pessimistic feeling if that works really save raises up, but I will test).
Thx, - alfred -