Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get the 2DPoint co-ordinate vallues in textboxes

Status
Not open for further replies.

NaWin55

Mechanical
Mar 21, 2020
97
0
0
IN
Hi everyone
I have this issue getting the values of co-Ordinates to text boxes
i need to get the horizontal(X) and Vertical(Y) values to the textboxes

here is the userform
selectpoint_absmrm.jpg


Here is the image with points
points_gdh66v.jpg


When i click on any point(those points 2d Sketch points Not wireframe points)
i need to get the hpizontal and vertical values of the picked point

here is the code i have done but dont know how to proceed further
Private Sub SelectPnt_Click()
Set oSelPoint = CATIA.ActiveDocument.Selection
oSelPoint.Clear

Dim vertexFilter(0) As Variant
vertexFilter(0) = "Vertex"

Dim vertexStatus As String
vertexStatus = oSelPoint.SelectElement2(vertexFilter, "Select Anyobject", False)

If (vertexStatus = "Cancel") Then
MsgBox "User Cancelled"
Else
opart.InWorkObject = oSelPoint.Item(1).Value

Dim osketch As Sketch
Set osketch = opart.InWorkObject

MsgBox opart.InWorkObject.Name

Dim ofact2d As Factory2D
Set ofact2d = osketch.OpenEdition

Dim oPoint As point2D
oPoint.GetCoordinates

End If

End Sub
what's the solution for this

Thanks
 
Replies continue below

Recommended for you

Using this code i am able to get the coordinate values
Exclude the commented line
Private Sub SelectPnt_Click()
Set oSelPoint = CATIA.ActiveDocument.Selection
oSelPoint.Clear

Dim vertexFilter(0) As Variant
vertexFilter(0) = "Vertex"

Dim vertexStatus As String
vertexStatus = oSelPoint.SelectElement2(vertexFilter, "Select Anyobject", False)

If (vertexStatus = "Cancel") Then
MsgBox "User Cancelled"
Else
oPart.InWorkObject = oSelPoint.Item(1).Value

Dim oSketch As Sketch
' Set oSketch = oPart.InWorkObject
' MsgBox oPart.InWorkObject.Name

' Dim sel1 As Selection
' Set sel1 = CATIA.ActiveDocument.Selection

' Set osketch = oSelPoint.Item(1).Value
'
' Dim oPoint2D
' Set oPoint2D = oSelPoint.Item(1).Value
' oSelPoint.Clear
'
' Dim oPoint2d1
' Dim oCoord(1)
' Dim p As Integer
' For p = 2 To oSketch.GeometricElements.Count
' MsgBox osketch.GeometricElements.Item(p).Name
' If oPoint2D.Name <> oSketch.GeometricElements.Item(p).Name Then
' Set oPoint2D = oSketch.GeometricElements.Item(p)
' End If
' Next
' oPoint2D.GetCoordinates oCoord
' HBox.Value = oCoord(0)
' VBox.Value = oCoord(1)
Dim TheSPAWorkbench As Workbench
Set TheSPAWorkbench = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench")

' Set osel = oDoc.Selection
Dim oPoint2D
Set oPoint2D = oSelPoint.Item(1).Value

Dim TheMeasurable
Set TheMeasurable = TheSPAWorkbench.GetMeasurable(oPoint2D)

Dim oCoord(2)
TheMeasurable.GetPoint oCoord

HBox.Value = oCoord(0)

VBox.Value = oCoord(1)

End If

End Sub

now i want change the location of point by changing the value from the boxes
when i click on update point the macro should detec the values from the textboxes and change the location of the point

that i am struggling

any solutions
 
You need to use part parameters where X,Y,Z is lenght , just replace lenght value with value from your box .
Roughly : If update point = true then lengthX.Value = HBox.Value
 
Status
Not open for further replies.
Back
Top