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

Finding XRef entities using SelectionFilter

9 REPLIES 9
Reply
Message 1 of 10
Anonymous
1504 Views, 9 Replies

Finding XRef entities using SelectionFilter

Is it possible using a SelectionFilter of TypeValues to find entities located
in an XRef?

Thanks
9 REPLIES 9
Message 2 of 10
chiefbraincloud
in reply to: Anonymous

If you want to (for example) programmatically select all BlockReferences named George inside xref XBG1, then I don't think you can do that. You would have to Open the Xref and loop through it's objects to find the ones you need.

If you want the user to select something specific from an xref, then you can use the Editor......

Ok, I just had to go look at my code to get the function name right, and discovered that there is no filter option or AddAllowedClass method for GetNestedEntity, so that won't work either. You would prompt for a certain type of nested entity, but then you would have to check the selected Item(s) to make sure they were the right type. However, in the GetSelection overloads, there is one that takes a filter, and the PromptSelectionOptions contains a pair of booleans for AllowSubSelections and ForceSubSelections. That might work, but I'm not sure. I'll give it a try if I get a chance.

Actually this whole thing applies to something I've been wanting to do to allow a function I already have to work with Xrefs, so I might be able to squeeze it in.
Dave O.                                                                  Sig-Logos32.png
Message 3 of 10
Anonymous
in reply to: Anonymous

Hello chiefbraincloud,

Thanks for the quick reply.

I'm currently using a filter for the Editor.SelectAll method (no user interaction).

I was looking into PromptSelectionOptions also but haven't figured out if
it will work yet. (I've been a MicroStation programmer for years which has
a much easier API for finding things so this has been a little frustrating)

What I'm actually doing is writing subassemblies for Civil3D that can target
objects by finding them by symbology instead of manually having to target
everything. I'm finding entities in the file that is active but get no results
for XRef entities.


> If you want to (for example) programmatically select all
> BlockReferences named George inside xref XBG1, then I don't think you
> can do that. You would have to Open the Xref and loop through it's
> objects to find the ones you need.
>
> If you want the user to select something specific from an xref, then
> you can use the Editor......
>
> Ok, I just had to go look at my code to get the function name right,
> and discovered that there is no filter option or AddAllowedClass
> method for GetNestedEntity, so that won't work either. You would
> prompt for a certain type of nested entity, but then you would have to
> check the selected Item(s) to make sure they were the right type.
> However, in the GetSelection overloads, there is one that takes a
> filter, and the PromptSelectionOptions contains a pair of booleans for
> AllowSubSelections and ForceSubSelections. That might work, but I'm
> not sure. I'll give it a try if I get a chance.
>
> Actually this whole thing applies to something I've been wanting to do
> to allow a function I already have to work with Xrefs, so I might be
> able to squeeze it in.
>
Message 4 of 10
chiefbraincloud
in reply to: Anonymous

It would appear that none of the Editor.Select... methods with no user interaction will do this.

Most of the Editor.Get... methods have an overload to accept PromptEntityOptions or PromptSelectionOptions, but all require user input.

So you would have to either:
1) Progammatically Open the Xref file into the Editor and use the Editor.Select Methods

2) Open the Xref by objectid. Editor commands not available because the xref Database is not open in the editor, so you'd have to loop all the objects inside it looking for the things you want.

3) Prompt the User for the Selection using Editor.GetSelection, using your filter and PromptSelectionOptions set to Allow Subent Selection.

I am curious what would happen if you set the Options to ForceSubentitySelection, set your filter to (using my example) all BlockRefs named George, and window selected the whole drawing, or even just type 'all' at the selection prompt.
Dave O.                                                                  Sig-Logos32.png
Message 5 of 10
Anonymous
in reply to: Anonymous

{quote}

Is it possible using a SelectionFilter of TypeValues to find entities
located
in an XRef?

{quote}

No, you can't.

The methods of the Editor class operate only on the active document. Even if
you opened the xref in the editor, you would still have to make it the
active document, something you should probably avoid, because opening files
in the editor can complicate things even further (unanticipated prompts
and/or messages that may appear when the file is opened, code that runs
automatically when the file opens, etc.).

You don't need selection filtering for what you're doing. You can manually
scan the xref database (which you can get from the GetXrefDatabase() method
of the BlockTableRecord that represents the xref in the referencing
database).

If the objects are all in the same space (e..g, model space), then you open
its BlockTableRecord in the xref database, and just scan its entities.

Depending on what you're after, you can use the ObjectClass property of each
entity's ObjectId to filter against objects of a given type, which
eliminates the need to open every object. When you find an object of the
type you're looking for, then you just open it and query its properties to
see if it meets your criteria.

There's really nothing all that complicated about it, and you can also use
LINQ to simplify the query part.

You can find a few examples showing the use of LINQ to find entities in this
newsgroup.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

"Michael Robertson" wrote in message
news:6309778@discussion.autodesk.com...
Is it possible using a SelectionFilter of TypeValues to find entities
located
in an XRef?

Thanks
Message 6 of 10
Anonymous
in reply to: Anonymous

Hello Tony,
I thought I may need to scan the BTR to find what I needed but didn't know
if the built in Autocad selection methods may run faster than me scanning
through all the records via .NET.

I'm actually working on some Civil3D subassemblies that target entities
based on symbology and xdata (instead of manually creating targets) so the
search code will run many times depending on the length of my corridor.

Do you by any chance know if the Intersectswith methods work with objects
that are in the active file & xrefs? ie Detecting the intersection between
a line in my active file and an xref?

Thanks.

> {quote}
>
> Is it possible using a SelectionFilter of TypeValues to find entities
> located
> in an XRef?
> {quote}
>
> No, you can't.
>
> The methods of the Editor class operate only on the active document.
> Even if you opened the xref in the editor, you would still have to
> make it the active document, something you should probably avoid,
> because opening files in the editor can complicate things even further
> (unanticipated prompts and/or messages that may appear when the file
> is opened, code that runs automatically when the file opens, etc.).
>
> You don't need selection filtering for what you're doing. You can
> manually scan the xref database (which you can get from the
> GetXrefDatabase() method of the BlockTableRecord that represents the
> xref in the referencing database).
>
> If the objects are all in the same space (e..g, model space), then you
> open its BlockTableRecord in the xref database, and just scan its
> entities.
>
> Depending on what you're after, you can use the ObjectClass property
> of each entity's ObjectId to filter against objects of a given type,
> which eliminates the need to open every object. When you find an
> object of the type you're looking for, then you just open it and query
> its properties to see if it meets your criteria.
>
> There's really nothing all that complicated about it, and you can also
> use LINQ to simplify the query part.
>
> You can find a few examples showing the use of LINQ to find entities
> in this newsgroup.
>
> AcadXTabs: MDI Document Tabs for AutoCAD
> Supporting AutoCAD 2000 through 2010
> http://www.acadxtabs.com
>
> Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");
>
> "Michael Robertson" wrote in
> message
> news:6309778@discussion.autodesk.com...
> Is it possible using a SelectionFilter of TypeValues to find entities
> located
> in an XRef?
> Thanks
>
Message 7 of 10
Anonymous
in reply to: Anonymous

Almost all methods of entities work regardless of whether they're in the active document or not.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

"Michael Robertson" wrote in message news:6310487@discussion.autodesk.com...
Hello Tony,
I thought I may need to scan the BTR to find what I needed but didn't know
if the built in Autocad selection methods may run faster than me scanning
through all the records via .NET.

I'm actually working on some Civil3D subassemblies that target entities
based on symbology and xdata (instead of manually creating targets) so the
search code will run many times depending on the length of my corridor.

Do you by any chance know if the Intersectswith methods work with objects
that are in the active file & xrefs? ie Detecting the intersection between
a line in my active file and an xref?

Thanks.

> {quote}
>
> Is it possible using a SelectionFilter of TypeValues to find entities
> located
> in an XRef?
> {quote}
>
> No, you can't.
>
> The methods of the Editor class operate only on the active document.
> Even if you opened the xref in the editor, you would still have to
> make it the active document, something you should probably avoid,
> because opening files in the editor can complicate things even further
> (unanticipated prompts and/or messages that may appear when the file
> is opened, code that runs automatically when the file opens, etc.).
>
> You don't need selection filtering for what you're doing. You can
> manually scan the xref database (which you can get from the
> GetXrefDatabase() method of the BlockTableRecord that represents the
> xref in the referencing database).
>
> If the objects are all in the same space (e..g, model space), then you
> open its BlockTableRecord in the xref database, and just scan its
> entities.
>
> Depending on what you're after, you can use the ObjectClass property
> of each entity's ObjectId to filter against objects of a given type,
> which eliminates the need to open every object. When you find an
> object of the type you're looking for, then you just open it and query
> its properties to see if it meets your criteria.
>
> There's really nothing all that complicated about it, and you can also
> use LINQ to simplify the query part.
>
> You can find a few examples showing the use of LINQ to find entities
> in this newsgroup.
>
> AcadXTabs: MDI Document Tabs for AutoCAD
> Supporting AutoCAD 2000 through 2010
> http://www.acadxtabs.com
>
> Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");
>
> "Michael Robertson" wrote in
> message
> news:6309778@discussion.autodesk.com...
> Is it possible using a SelectionFilter of TypeValues to find entities
> located
> in an XRef?
> Thanks
>
Message 8 of 10
chiefbraincloud
in reply to: Anonymous

"the search code will run many times depending on..."

I realise there may be situations where this is just not possible, but you should try (try, try, try) to get ID's for all of the objects you are interested in on the first pass. Then you don't have to go through the whole Xref many times, but rather you might have to go through your much smaller collection many times. (You might be able to code it so you only have to go through your collection once as well)

As far as the intersect with question, I don't have any code that does it (with nested ents), but I think once you have an open reference to the lines it should work. If not, you can always create a temporary copy to intersect with.
Dave O.                                                                  Sig-Logos32.png
Message 9 of 10
Anonymous
in reply to: Anonymous

Hello chiefbraincloud,
The Civil3D software originally had no way to store information for a complete
road run (you had to run all your code at EVERY cross section), supposedly
with 2010 I'll be able to store my found entities once and only have to detect
if they exist with intersection at each cross section.

Thanks for you help and Happy New Year.

> "the search code will run many times depending on..."
>
> I realise there may be situations where this is just not possible, but
> you should try (try, try, try) to get ID's for all of the objects you
> are interested in on the first pass. Then you don't have to go
> through the whole Xref many times, but rather you might have to go
> through your much smaller collection many times. (You might be able to
> code it so you only have to go through your collection once as well)
>
> As far as the intersect with question, I don't have any code that does
> it (with nested ents), but I think once you have an open reference to
> the lines it should work. If not, you can always create a temporary
> copy to intersect with.
>
Message 10 of 10
Anonymous
in reply to: Anonymous

Hello Tony,
Thanks for you help and Happy New Year!

> Almost all methods of entities work regardless of whether they're in
> the active document or not.
>
> AcadXTabs: MDI Document Tabs for AutoCAD
> Supporting AutoCAD 2000 through 2010
> http://www.acadxtabs.com
>
> Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");
>
> "Michael Robertson" wrote in
> message news:6310487@discussion.autodesk.com...
>
> Hello Tony,
>
> I thought I may need to scan the BTR to find what I needed but didn't
> know
>
> if the built in Autocad selection methods may run faster than me
> scanning
>
> through all the records via .NET.
>
> I'm actually working on some Civil3D subassemblies that target
> entities based on symbology and xdata (instead of manually creating
> targets) so the search code will run many times depending on the
> length of my corridor.
>
> Do you by any chance know if the Intersectswith methods work with
> objects that are in the active file & xrefs? ie Detecting the
> intersection between a line in my active file and an xref?
>
> Thanks.
>
>> {quote}
>>
>> Is it possible using a SelectionFilter of TypeValues to find entities
>> located
>> in an XRef?
>> {quote}
>> No, you can't.
>>
>> The methods of the Editor class operate only on the active document.
>> Even if you opened the xref in the editor, you would still have to
>> make it the active document, something you should probably avoid,
>> because opening files in the editor can complicate things even
>> further (unanticipated prompts and/or messages that may appear when
>> the file is opened, code that runs automatically when the file opens,
>> etc.).
>>
>> You don't need selection filtering for what you're doing. You can
>> manually scan the xref database (which you can get from the
>> GetXrefDatabase() method of the BlockTableRecord that represents the
>> xref in the referencing database).
>>
>> If the objects are all in the same space (e..g, model space), then
>> you open its BlockTableRecord in the xref database, and just scan its
>> entities.
>>
>> Depending on what you're after, you can use the ObjectClass property
>> of each entity's ObjectId to filter against objects of a given type,
>> which eliminates the need to open every object. When you find an
>> object of the type you're looking for, then you just open it and
>> query its properties to see if it meets your criteria.
>>
>> There's really nothing all that complicated about it, and you can
>> also use LINQ to simplify the query part.
>>
>> You can find a few examples showing the use of LINQ to find entities
>> in this newsgroup.
>>
>> AcadXTabs: MDI Document Tabs for AutoCAD
>> Supporting AutoCAD 2000 through 2010
>> http://www.acadxtabs.com
>> Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");
>>
>> "Michael Robertson" wrote in
>> message
>> news:6309778@discussion.autodesk.com...
>> Is it possible using a SelectionFilter of TypeValues to find entities
>> located
>> in an XRef?
>> Thanks

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