Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Fail to get textual names of Browser Node types with ToString in iLogic

Maxim-CADman77
Advisor

Fail to get textual names of Browser Node types with ToString in iLogic

Maxim-CADman77
Advisor
Advisor

I'd like to know how can I get textual names for types of Browser Nodes presented in Part's browser (Model Tab).

When I add "ToString" after the Type query I still get numeric value like:

BrwsrNodeType_ToString_Issue.png

The iLogic code I'm using is:

Dim oIPT As PartDocument=ThisDoc.Document
Dim MsgBody As String
For Each oNode In oIPT.BrowserPanes("PmDefault").TopNode.BrowserNodes
	If oNode.Visible Then
		MsgBody &= oNode.BrowserNodeDefinition.Label & vbCrLf
		If Not oNode.NativeObject Is Nothing Then
			MsgBody &= "       Type : " & oNode.NativeObject.Type.ToString & vbCrLf
		End If
	End If
Next
MsgBox (MsgBody,,"Node types are:")
Exit Sub

The issue described was reproduced in Inventor 2020.2.1

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Reply
Accepted solutions (1)
573 Views
2 Replies
Replies (2)

JhoelForshav
Mentor
Mentor

Hi @Maxim-CADman77 

Are you looking for something like this? :slightly_smiling_face:

 

Sub Main
	Dim oIPT As PartDocument = ThisDoc.Document
	Dim MsgBody As String
	For Each oNode In oIPT.BrowserPanes("PmDefault").TopNode.BrowserNodes
		If oNode.Visible Then
			MsgBody &= oNode.BrowserNodeDefinition.Label & vbCrLf
			If Not oNode.NativeObject Is Nothing Then
				MsgBody &= "       Type : " & GetObjectEnum(oNode.NativeObject.Type.ToString) & vbCrLf
			End If
		End If
	Next
	MsgBox(MsgBody, , "Node types are:")
	Exit Sub
End Sub

Function GetObjectEnum(oValue)

	Dim oEnumType As EnumType
	oEnumType = ThisApplication.TestManager.GetEnumType("ObjectTypeEnum")
	oEnumType.Value = 0
	Dim oName As String
	Dim index As Integer
	index = 0
	Do While index < oEnumType.Count

		If oEnumType.Value = oValue
			oName = oEnumType.ValueName
			Exit Do
		End If
		oEnumType.MoveNext


		index = index + 1
	Loop
	Return oName
End Function

ObjectType.PNG

0 Likes

Maxim-CADman77
Advisor
Advisor
Accepted solution

Thank for the suggestion, but I also got the single-line solution (https://forums.autodesk.com/t5/inventor-customization/api-return-enumerator-name-instead-of-numeric-...).

 

InstedOf:

oNode.NativeObject.Type.ToString

 

The

[Enum].GetName(GetType(ObjectTypeEnum), oNode.NativeObject.Type)

 

...should be used.

Please vote for Inventor-Idea Text Search within Option Names

0 Likes