Hi,
Is there a way to select attributes from a block if I pick a point inside the block? Please help
Thanks
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
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
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
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
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.
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