Get list of properties / methods from given object

Get list of properties / methods from given object

omartin
Advocate Advocate
1,548 Views
6 Replies
Message 1 of 7

Get list of properties / methods from given object

omartin
Advocate
Advocate

For example, when searching the docs for a particular object you get a list of its properties and methods, or when intelli-sense kicks in you get the list of properties and methods.

How can I get similar results? I was guessing reflection would work but I keep getting null reference. I am guessing because all the objects are automation interfaces??

Was my reply Helpful ? send a Kudos or accept as solution
0 Likes
Accepted solutions (1)
1,549 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable

You can only drive one mate at a time. what you need to look into is either animation in Inventor studio, or the presentation environment. Note that the presentation environment is usually used for assembly instructions, but with a bit of imagination, you can use it 

 

Studio: https://www.youtube.com/watch?v=__EjxKIsy9E

Presentation: https://www.youtube.com/watch?v=fED0c-AioHk

0 Likes
Message 3 of 7

JhoelForshav
Mentor
Mentor

Hi @omartin 

Are you looking for a way to print out a list of all Properties/Methods in an Object with iLogic?

Try this rule as an example of how to do this:

 

Sub Main
	Dim oDoc = ThisDoc.Document
	GetObjectInfo(oDoc)
End Sub

Sub GetObjectInfo(ByRef oObj As Object)

Dim oPropsString As String = "Properties:"
Dim oMethodsString As String = "Methods:"

Dim oProps As System.Reflection.PropertyInfo() = oObj.GetType.GetProperties
Dim oMethods As System.Reflection.MethodInfo() = oObj.GetType.GetMethods

For Each oProp As System.Reflection.PropertyInfo In oProps
	oPropsString = oPropsString & vbCrLf & oProp.Name
Next
For Each oMethod As System.Reflection.MethodInfo In oMethods
	oMethodsString = oMethodsString & vbCrLf & oMethod.Name
Next

MsgBox(oPropsString)
MsgBox(oMethodsString)

End Sub

In this example I write out the properties and methods for the Document in whih the rule is ran, but you could use the sub for any object 🙂

Message 4 of 7

robertast
Collaborator
Collaborator

@JhoelForshav 

Well, you never cease to amaze. First this:

https://knowledge.autodesk.com/support/inventor/learn-explore/caas/simplecontent/content/ilogic-tool... 

Now this. 🙂 (need to add a separator to the message - the whole message will not fit on the screen)

Already half of the "macro recording" and created 🙂

Message 5 of 7

omartin
Advocate
Advocate
	Dim oDoc As DrawingDocument = ThisDoc.Document
	Dim dl As DrawingViewLabel
	Dim ds As Sheet
	ds = oDoc.Sheets(1)
	dl = ds.DrawingViews(1).Label	
	GetObjectInfo(dl)

Hey@JhoelForshav thx for the RE:. You have the idea down, eventually I want to be able to run one the commands from the list.

I was working in visual studio but good to know ilogic as well.  I used the above to try and pass a drawing view label but i get no properties and looks like a generic list for the methods

Untitled.png 

Was my reply Helpful ? send a Kudos or accept as solution
0 Likes
Message 6 of 7

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @omartin 

You're right... GetType returns System.__ComObject for DrawingViewLabel 😞

 

I found another way to get the Properties though:

Sub GetObjectInfo(ByRef oObj As Object)
Dim oPropsString As String = "Properties:"
Dim oProps As System.ComponentModel.PropertyDescriptorCollection = System.ComponentModel.TypeDescriptor.GetProperties(oObj)
For Each oProp As System.ComponentModel.PropertyDescriptor In oProps
	oPropsString = oPropsString & vbCrLf & oProp.Name
Next
MsgBox(oPropsString)
End Sub

But no success on the methods so far.

Message 7 of 7

omartin
Advocate
Advocate

Thx @JhoelForshav  😁 i never would have looked in here: System.ComponentModel.PropertyDescriptorCollection.

howd you find it hahah that should be good enough seems like most of the commands i was looking for are properties

Was my reply Helpful ? send a Kudos or accept as solution