.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Utilizing SelectionSet on non-opened drawings

4 REPLIES 4
Reply
Message 1 of 5
junoj
443 Views, 4 Replies

Utilizing SelectionSet on non-opened drawings

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,

 

-Jay

4 REPLIES 4
Message 2 of 5
Alfred.NESWADBA
in reply to: junoj

Hi,

 

>> 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 -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 5
DiningPhilosopher
in reply to: junoj

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.

Message 4 of 5
junoj
in reply to: junoj

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.

 

-Jay

Message 5 of 5

Hi,

 

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 -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost