Reference key of point

Reference key of point

Anonymous
Not applicable
538 Views
3 Replies
Message 1 of 4

Reference key of point

Anonymous
Not applicable

Hello Everyone,

 

I am using the select event to select entities on a component, but when I select on a point of an edge, it is not a point type. I would like to get the reference key to that point, how can I do that? Please help me in this case! 🙂

 

2020-07-17_18h10_29.png

 

Thank you

0 Likes
Accepted solutions (1)
539 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

It's most likely a Vertex object, instead of an actual Point object.

Try defining the object you selected as a Vertex, that should allow you to get the ReferenceKey.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

WCrihfield
Mentor
Mentor
Accepted solution

 

A code like this should work:

 

Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oObj As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartVertexFilter, "Select A Vertex.")
If oObj Is Nothing Then
	MsgBox("Selection was canceled. Exiting.", vbOKOnly, " ")
	Return
End If
If oObj.Type.ToString <> "67120432" Then
	MsgBox("Item selected was not a Vertex. Exiting.", vbOKOnly, " ")
	Return
End If
Dim oVertex As Vertex = oObj
Dim oRefKey() As Byte
Dim oKeyContext As Integer = 1
Try
	oVertex.GetReferenceKey(oRefKey)
Catch oEx As Exception
	MsgBox("The GetReferenceKey Sub failed." & vbCrLf & _
	"The Error Message is as follows:" & vbCrLf & _
	oEx.Message & vbCrLf  & vbCrLf & _
	"And the Source was as follows:" & vbCrLf & _
	oEx.Source & vbCrLf & vbCrLf & _
	"And the StackTrace was as follows:" & vbCrLf & _
	oEx.StackTrace, vbOKOnly + vbExclamation, " ")
End Try

 

Although, in some of my tests, it returned the following error message.

GetReferenceKey Error Message.png

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 4

Anonymous
Not applicable

Yah, thanks for your help. Let me try from my side with your solution.

0 Likes