Looping through object properties

Looping through object properties

drouthierXAHY9
Participant Participant
577 Views
2 Replies
Message 1 of 3

Looping through object properties

drouthierXAHY9
Participant
Participant

Hi guys and gals!

 

Long time listener (4 months) first time caller! 

I'm looking to loop through an object, obtain its' property names and values, and then write those properties to a file. Using the forums and Goggle searches, I pasted the enclosed code together. 

When I save the rule, it throws an error, "Error on Line 30 : Type 'oCircOccPattern' is not defined." oCircOccPattern is determined and passed from the Sub Main() area of the rule.

The error searches state that it is because the object type is determined at runtime. I tried passing the known object directly but it throws the same error. 

 

Any help is greatly appreciated!

 

SyntaxEditor Code Snippet

Sub circularPattern (oCircOccPattern As CircularOccurrencePattern)
strPath = (ThisDoc.PathAndFileName(False) & ".txt")
Dim fso As Object
fso = CreateObject("Scripting.FileSystemObject")
Dim oFile As Object
oFile = FSO.CreateTextFile(strPath)


Dim myType As Type = GetType(oCircOccPattern)
        Dim properties As System.Reflection.PropertyInfo() = myType.GetProperties()
        For Each p As System.Reflection.PropertyInfo In properties
            ofile.writeline (p.Name)
        Next p

oFile.Close
fso = Nothing
oFile = Nothing 
End Sub

 

0 Likes
578 Views
2 Replies
Replies (2)
Message 2 of 3

NachoShaw
Advisor
Advisor

Are you trying to loop through the components of the circular pattern? If so, your code isnt doing that. Can you can be more specific about what you are trying to do?

 

From your code, it appears that you are trying to get the properties of the circular pattern itself which would be incorrect. You would need to loop through the occurrences in the pattern and get the iProperties from there (if thats your intention)

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


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.


0 Likes
Message 3 of 3

drouthierXAHY9
Participant
Participant

Negative. I'm looking to loop through the object properties, to obtain the assembly properties. I'm not looking to get the iProperties of any of the pattern elements.

 

in the CircularOccurrencePattern, I am looking to get:

.angleOffset

.axisEntity

.axisEntityNaturalDirection

etc

 

0 Likes