Select a point and print its coortinates in text boxes

Select a point and print its coortinates in text boxes

Anonymous
Not applicable
474 Views
5 Replies
Message 1 of 6

Select a point and print its coortinates in text boxes

Anonymous
Not applicable
I looked in all the relative topics but i couldn't find help.Can somebody help me?I made a select event so as to pick a point; that works ok.My problem is that i want its coordinates to appear in 2 text boxes. My try is:
Private Sub oSelectPoint_OnSelect(ByVal JustSelectedEntities As ObjectsEnumerator, _
ByVal SelectionDevice As SelectionDeviceEnum, _
ByVal ModelPosition As Point, _
ByVal ViewPosition As Point2d, _
ByVal View As View)

Dim oSelectedEnt As ObjectsEnumerator
Set oSelectedEnt = oSelectPoint.SelectedEntities
If TypeOf oSelectedEnt.Item(1) Is Point Then
Dim oPoint As Point
Set oPoint = oSelectedEnt.Item(1)
End If
txtX.Text = oPoint.X
txtY.Text = oPoint.Y
End Sub
What is wrong about it?
0 Likes
475 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
What kind of point are you selecting? There are several different types of
entities that can define a point within Inventor; work points, vertices of a
solid, sketch points, hole centers, etc. Depending on how you have the
selection filter set up you will be selecting one of these entities. From
an entity you can use its Geometry property to get the geometric definition
of the entity. In the case of these objects you will get a Point or Point2d
object back. Your code should then function correctly.

You code could look something like:

If TypeOf JustSelectedEntities.Item(1) Is Vertex Then
Dim oVertex As Vertex
Set oVertex = JustSelectedEntities.Item(1)

Dim oPoint As Point
Set oPoint = oVertex.Geometry

txtX.Text = oPoint.X
txtY.Text = oPoint.Y
txtZ.Text = oPoint.Z
End If
--
Brian Ekins
Autodesk Inventor API

wrote in message news:[email protected]...
I looked in all the relative topics but i couldn't find help.Can somebody
help me?I made a select event so as to pick a point; that works ok.My
problem is that i want its coordinates to appear in 2 text boxes. My try is:
Private Sub oSelectPoint_OnSelect(ByVal JustSelectedEntities As
ObjectsEnumerator, _
ByVal SelectionDevice As SelectionDeviceEnum, _
ByVal ModelPosition As Point, _
ByVal ViewPosition As Point2d, _
ByVal View As View)

Dim oSelectedEnt As ObjectsEnumerator
Set oSelectedEnt = oSelectPoint.SelectedEntities
If TypeOf oSelectedEnt.Item(1) Is Point Then
Dim oPoint As Point
Set oPoint = oSelectedEnt.Item(1)
End If
txtX.Text = oPoint.X
txtY.Text = oPoint.Y
End Sub
What is wrong about it?
0 Likes
Message 3 of 6

Anonymous
Not applicable
It doesn't work....My selection filter is kAllPointEntities and it works. I can select all the points that i want, basically vertex an work points. So at the procedure that I want to show its coordinates I separate cases. I attach me project if you want to have a look. Thank you very much in advance!
0 Likes
Message 4 of 6

Anonymous
Not applicable
Also, I forgot to ask you if the selected point is a WorkPoint we cannot find/show its coordinates?Thanks and again!
0 Likes
Message 5 of 6

Anonymous
Not applicable
Attached is a modified version of your program. The property to get the
position of the a WorkPoint or Vertex is the Point property instead of the
Geometry property. For a sketch point it is the Geometry property. You
should also be aware that the sketch point will return the coordinates in
sketch space. I added code to the program to get the position of the sketch
point in model space.
--
Brian Ekins
Autodesk Inventor API
0 Likes
Message 6 of 6

Anonymous
Not applicable
Thank you!!! Now I understand what was going wrong...
0 Likes