How to get Enumerator name from its value?

How to get Enumerator name from its value?

j.pavlicek
Collaborator Collaborator
3,033 Views
4 Replies
Message 1 of 5

How to get Enumerator name from its value?

j.pavlicek
Collaborator
Collaborator

Hello, for testing purposes I'd like to know what type I've got. Typically it's stored in object properties as ObjectTypeEnum and an Integer is provided as property value. But it's tedious to look for each value in a help page.

 

There must be easier way...



Inventor 2022, Windows 10 Pro
Sorry for bad English.
0 Likes
Accepted solutions (1)
3,034 Views
4 Replies
Replies (4)
Message 2 of 5

j.pavlicek
Collaborator
Collaborator
Accepted solution

And this is solution:

Enum.GetName Method

 

Usage:

Dim EnumTest As Object = oDrawingCurve.ModelGeometry.Type
Dim sStr As String
sStr = [Enum].GetName(GetType(ObjectTypeEnum), EnumTest)


Inventor 2022, Windows 10 Pro
Sorry for bad English.
Message 3 of 5

_dscholtes_
Advocate
Advocate

@j.pavlicek This is for C# in .Net only, right? This might be handy to mention, since there are multiple languages being discussed here (e.g. iLogic, VBA). For your next post / question, please mention the language you are programming in.
 

0 Likes
Message 4 of 5

j.pavlicek
Collaborator
Collaborator

Hello, @_dscholtes_ i filled category "iLogic" (=vb.net) and thought it's enough.



Inventor 2022, Windows 10 Pro
Sorry for bad English.
0 Likes
Message 5 of 5

_dscholtes_
Advocate
Advocate

@j.pavlicek My apologies. I didn't notice you mentioned iLogic in one of the tags.

Anyway, nice piece of code. May come in handy for debugging. I tested the following in a drawing document:

Dim oDrawingCurve As DrawingCurve
oDrawingCurve = ThisApplication.ActiveEditDocument.sheets(1).drawingviews(1).drawingcurves.item(1)

MessageBox.Show(oDrawingCurve.ModelGeometry.Type,"before")
'shows: 67120176

Dim EnumTest As Object = oDrawingCurve.ModelGeometry.Type
Dim sStr As String
sStr = [Enum].GetName(GetType(ObjectTypeEnum), EnumTest)

MessageBox.Show(sStr, "after")
'shows: kEdgeObject

  

0 Likes