- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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!!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Red text in your code returns the reference of the top assembly document (that owns the rule), while you need in the part document. As the top assembly does not have those parameters nothing happens.
Dim openDoc As Document = ThisDoc.Document
If openDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
For Each docFile As Document In openDoc.AllReferencedDocuments
If docFile.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
Dim oParams As Parameters = ThisDoc.Document.ComponentDefinition.Parameters <--- mistake
Dim oUserParams As UserParameters = oParams.UserParameters
'Look for Frame Gen Parameter and format it
Try
Dim oParam As Inventor.Parameter
'Enter the name of Paramter here
..........................
..........................
..........................
So please try this line in the following form:
Dim oParams As Inventor.Parameters = docFile.ComponentDefinition.Parameters
Hope this helps.
Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report