Object Browser for Inventor

Object Browser for Inventor

breinkemeyer
Enthusiast Enthusiast
1,525 Views
3 Replies
Message 1 of 4

Object Browser for Inventor

breinkemeyer
Enthusiast
Enthusiast

This is probably a reach, but I do lot's of work for both Inventor and Solid Edge.  In SE we have a tool called Spy (see attachment) that is invaluable for programming.   Does anything exist in the Inventor world?

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

JelteDeJong
Mentor
Mentor
Accepted solution

I think you have several otions.

1: In the VBa editor you can press F2

JelteDeJong_0-1633550132893.png

for the object browser. (VBa is obsolete in my opinion and is not installed anymore by default with Inventor. but you will get exactly what you are asking for.)

2: The "Programing/API Help" is good in my opinion.

JelteDeJong_1-1633550327980.png

3: you can download the object model tree as PDF "Poster"

JelteDeJong_2-1633550805364.png

4: If you are working in Visual studio and you have made a reference to the "Autodesk.Inventor.Interop.dll" then you can use the object browser from Visual Studio.

JelteDeJong_3-1633550938617.png

 

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 4

Michael.Navara
Advisor
Advisor

I'm using following VBA macro for this. You need to display Locals window in VBA editor and run this method.

You can see in Locals

  • First selected object 
  • All selected objects
  • Application
  • Active document
  • Active edit document (Edited part in assembly context)
  • Active edit object (Active sketch for example)

Now you can expand all of them and look what is inside

For quick info what is selected I print to Immediate window type of first selected object. For this you need to implement conversion function (ObjectTypeEnumToString). This function is too big to paste here, but you can generate the code using iLogic.

 

michaelnavara_0-1633598940783.png

 

Spy function (VBA)

Public Sub Spy()
    Dim SelectedObject As Variant
    Dim Selection As ObjectCollection
    
    Dim app As Inventor.Application
    Set app = ThisApplication
    
    Dim ActiveDoc As Document
    Set ActiveDoc = app.ActiveDocument
    
    Dim EditedDoc As Document
    Set EditedDoc = app.ActiveEditDocument
    
    Dim ActiveObject As Variant
    Set ActiveObject = app.ActiveEditObject
    
MainCode:
    On Error GoTo ErrLine1
    Set SelectedObject = ActiveDoc.SelectSet.Item(1)
    Set Selection = app.TransientObjects.CreateObjectCollection(ActiveDoc.SelectSet)
    Debug.Print ObjectTypeEnumToString(SelectedObject.Type)

    Stop
    Exit Sub
    
ErrLine1:
    Debug.Print "<No Selection>"
    Set SelectedObject = ThisApplication
   
    Stop
End Sub

 

 

ObjectTypeEnumToString function stub (VBA)

Function ObjectTypeEnumToString(t As ObjectTypeEnum) As String
   Select Case t
      Case kEdgeCollectionObject: ObjectTypeEnumToString = "kEdgeCollectionObject": Exit Function
...
   End Select
End Function

 

ObjectTypeEnumToString code generator (iLogic)

This function creates full code and set them to the system clipboard. Then you can just paste the code to VBA module

Dim code As New System.Text.StringBuilder
Dim ote = ThisDoc.Document.Type
Dim oteType As Type = ote.GetType()
code.AppendLine("Function ObjectTypeEnumToString(t as ObjectTypeEnum) As String")
code.AppendLine("   Select Case t")
For Each value In [Enum].GetValues(oteType)
	Dim name = [Enum].GetName(oteType, value)
	code.AppendFormat("      Case {0}: ObjectTypeEnumToString = ""{1}"": Exit Function{2}", value, name, vbCrLf)
Next
code.AppendLine("   End Select")
code.AppendLine("End Function")
System.Windows.Forms.Clipboard.SetText(code.ToString())
MsgBox("Code is in clipboard", Title :="ObjectTypeEnumToString")

 

I hope it helps 

Message 4 of 4

breinkemeyer
Enthusiast
Enthusiast

Thanks guys.  Using Visual studio here working in c#

0 Likes