.NET

Reply
Mentor
Hugh_Compton
Posts: 711
Registered: ‎04-21-2006
Message 1 of 6 (302 Views)
Accepted Solution

Read An Object Properties Of An Object In An XRef By Selection

302 Views, 5 Replies
07-03-2012 09:30 AM

 

Is it possible to select an object for reading in an XRef?  If so could someone post an example?

 

Thanks

 

PS I think it has something to do with  Editor.SelectNestedEntity() but it is the end of a long day and I can't fathom it out :smileysad:

Dim PrNestOps As New PromptNestedEntityOptions("Pick Nested Entity")
PrNestOps.AllowNone = False
PrNestOps.UseNonInteractivePickPoint = False
'set that to true and supply a point to NonInteractivePickPoint if you want to get an entity at a known point without prompting the user
Dim pner As PromptNestedEntityResult = acdocs.MdiActiveDocument.Editor.GetNestedEntity(PrNestOps)
If pner.Status = PromptStatus.OK Then
Dim nestedID As ObjectId = pner.ObjectId 'this is the id of the most deeply nested object at the picked point
Dim pickpt As Point3d = pner.PickedPoint
Dim ParentIds As New ObjectIdCollection(pner.GetContainers) 'this is the Ids of all the container objects
'... do what you need to do
End If

 

*Expert Elite*
chiefbraincloud
Posts: 753
Registered: ‎02-13-2008
Message 2 of 6 (293 Views)

Re: Read An Object Properties Of An Object In An XRef By Selection

07-03-2012 01:03 PM in reply to: Hugh_Compton
Dim PrNestOps As New PromptNestedEntityOptions("Pick Nested Entity")
PrNestOps.AllowNone = False
PrNestOps.UseNonInteractivePickPoint = False
'set that to true and supply a point to NonInteractivePickPoint if you want to get an entity at a known point without prompting the user
Dim pner As PromptNestedEntityResult = acdocs.MdiActiveDocument.Editor.GetNestedEntity(PrNestOps)
If pner.Status = PromptStatus.OK Then
	Dim nestedID As ObjectId = pner.ObjectId 'this is the id of the most deeply nested object at the picked point
	Dim pickpt As Point3d = pner.PickedPoint
	Dim ParentIds As New ObjectIdCollection(pner.GetContainers) 'this is the Ids of all the container objects
	'... do what you need to do
End If

 

Dave O.                                                                  Sig-Logos32.png
Mentor
Hugh_Compton
Posts: 711
Registered: ‎04-21-2006
Message 3 of 6 (275 Views)

Re: Read An Object Properties Of An Object In An XRef By Selection

07-04-2012 07:44 AM in reply to: Hugh_Compton

 

Fantastic reply, works brilliantly.  Thanks Chief!

*Expert Elite*
chiefbraincloud
Posts: 753
Registered: ‎02-13-2008
Message 4 of 6 (265 Views)

Re: Read An Object Properties Of An Object In An XRef By Selection

07-05-2012 01:13 AM in reply to: Hugh_Compton

No problem...

 

You should also note, if you haven't already discovered it, that if the selected object is a Polyline2d or Polyline3d type, then the "most deeply nested object" returned by pner.ObjectId will be a Vertex2d or Vertex3d object.  So, in the code I have where I was looking for something that derives from Curve, I had to check for that, and get the parent of the Vertex to get the Curve I was looking for.

 

Also, It is appreciated, by both the answerers, and the future searchers, if you mark a post as a solution when your problem is solved.

Dave O.                                                                  Sig-Logos32.png
Mentor
Hugh_Compton
Posts: 711
Registered: ‎04-21-2006
Message 5 of 6 (263 Views)

Re: Read An Object Properties Of An Object In An XRef By Selection

07-05-2012 01:20 AM in reply to: Hugh_Compton

 

Good advice, I've been using it on Sold3D objects with great success so far. 

*Expert Elite*
chiefbraincloud
Posts: 753
Registered: ‎02-13-2008
Message 6 of 6 (260 Views)

Re: Read An Object Properties Of An Object In An XRef By Selection

07-05-2012 01:57 AM in reply to: Hugh_Compton

Glad to help...  And thanks for marking the solution.  It's not an ego thing, I couldn't care less about my "solutions Authored" stats, it's just that I, and I'm sure other people like me, have an RSS feed of this forum, and I at least "look" at every single post.  It helps if I can open a post and see that it has been solved, then I know I don't need to look at it any further, unless I intend to learn from it.

 

Then there is the other side, where I am am searching this forum or any other, I'm more likely to look at threads that show a solution, than threads that don't.

 

Dave O.                                                                  Sig-Logos32.png
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!