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

Point Selection

6 REPLIES 6
Reply
Message 1 of 7
shemt
430 Views, 6 Replies

Point Selection

Hi, 

 

Is there a way to select attributes from a block if I pick a point inside the block? Please help

 

Thanks

6 REPLIES 6
Message 2 of 7
Hallex
in reply to: shemt

Try this way

'' code snip

 Dim pno As New PromptNestedEntityOptions(vbLf & "Select attribute >>")
 Dim nres As PromptNestedEntityResult = ed.GetNestedEntity(pno)
 If nres.Status <> PromptStatus.OK Then
  Return
 End If
 Dim id As ObjectId = nres.ObjectId
 Dim ent As Entity = DirectCast(tr.GetObject(id, OpenMode.ForRead), Entity)
 ed.WriteMessage(vbLf & "Object type seleted" & vbTab & "{0}", ent.GetRXClass().DxfName)
 Dim pnt As Point3d = nres.PickedPoint
 ed.WriteMessage(vbLf & "Picked corner point X={0}" & vbTab & "Y={1} Z={2}", pnt.X, pnt.Y, pnt.Z)
 '---> Do your mojo here

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 3 of 7
shemt
in reply to: Hallex

Hi,

 

Thanks for the reply.

 

I'm actually looking to edit an attribute in a block that contains 2 closed rectangular polylines, and one attribute each inside each rectangle. When the user picks anywhere inside the rectangle, it should detect that particular attribute in the block. I couldn't think of a solution to it. Is it possible to get the area around the picked point, detect the rectangle, and then detect the attribute in the rectangle? For this to work, should the block be exploded programatically?

 

Thanks

Message 4 of 7
Hallex
in reply to: shemt

Using the code I've posted above you could rich at

attribute directly just cast the entity as AttributeReference

and change value of this attribute

You can find a ton of code in this forum regarding

the work with attributes as well btw

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 5 of 7
shemt
in reply to: shemt

Thanks for the code. But that works only if there is a value in the attribute. That's why I'm looking to get the point and the area around the point to find any attributes inside a rectangle.

 

Thanks

Message 6 of 7
chiefbraincloud
in reply to: shemt

My first suggestion would be to use GetNestedEntity and have the user select the Polyline, as opposed to the AttributeReference.  I suppose you could have both cases covered, so if there is a value the user can select the attribute or the polyline.

 

Once you know the polyline that was selected, it would be relatively easy to figure out which AttributeReference was inside it.  Much simpler math than trying to find the polyline from a point picked inside it.

Dave O.                                                                  Sig-Logos32.png
Message 7 of 7
shemt
in reply to: chiefbraincloud

The IsPointInside() is what I was exactly looking for!That works fine, but sadly only when the block's rotation angle is 180 degree. If I manually change the rotation angle to 180, it works fine. What could be the reason.

 

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