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

Run iLogic from Assembly to affect all parts

I'm trying to quickly format parameters in parts with an external iLogic script from the assembly level.

I can run this script at the part level

Imports Inventor.UnitsTypeEnum

Dim oParams As Parameters
oParams=ThisDoc.Document.ComponentDefinition.Parameters

Dim oUserParams As UserParameters
oUserParams=oParams.UserParameters

'Look for Frame Gen Parameter and format it
Try
Dim oParam As Parameter
'Enter the name of Paramter here
Dim MyParam As String = "G_L"
oParam = oUserParams(MyParam)
oParam.ExposedAsProperty = True
'format Custom Parameter
Dim oFormat As CustomPropertyFormat
oFormat = oUserParams(MyParam).CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Units="ft"
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision
oFormat.ShowUnitsString = False
oFormat.ShowLeadingZeros = False
oFormat.ShowTrailingZeros = False

Catch
End Try

 

But when i add it to other scripts i've found to run from the Assembly level nothing happens....

 

 

Imports Inventor.UnitsTypeEnum

Dim openDoc As Document
openDoc = ThisDoc.Document
Dim docFile As Document
If openDoc.DocumentType = 12291 Then
For Each docFile In openDoc.AllReferencedDocuments

If docFile.DocumentType = 12290 Then

 

Dim oParams As Parameters
oParams=ThisDoc.Document.ComponentDefinition.Parameters

Dim oUserParams As UserParameters
oUserParams=oParams.UserParameters

'Look for Frame Gen Parameter and format it
Try
Dim oParam As Parameter
'Enter the name of Paramter here
Dim MyParam As String = "G_L"
oParam = oUserParams(MyParam)
oParam.ExposedAsProperty = True
'format Custom Parameter
Dim oFormat As CustomPropertyFormat
oFormat = oUserParams(MyParam).CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Units="ft"
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision
oFormat.ShowUnitsString = False
oFormat.ShowLeadingZeros = False
oFormat.ShowTrailingZeros = False

Catch
End Try

End If
Next
Else
MessageBox.Show("You must have a valid Assembly document open before using this code!", "File Type Mismatch!",MessageBoxButtons.OK,MessageBoxIcon.Exclamation)
End If 

Any ideas?

thanks!!!