I have a similar code which runs a rule that exists in all parts referenced in a drawing. This works fine however, i would also like it to check to see if the rule exists in the part files and, if not, create the rule and then execute it.
Ideally, the iLogic rule would just be created in every related file referenced in a drawing & then run.
Any ideas?
This thread seemed pretty similar to the iLogic i was trying to create.
Thanks,
This is my code so far;
Rule that runs in Drawings level:
'Define the open document
Dim oDoc As Document
oDoc = ThisDoc.Document
'Look at all of the files referenced in the open document
Dim docFile As Document
For Each docFile In oDoc.AllReferencedDocuments
'open the indexed file
'true opens the file normaly
'false opens the file programatically without generating the graphics
ThisApplication.Documents.Open(docFile.FullFileName, True)
'run rule in the drawing document
auto = iLogicVb.Automation
auto.RunRule(docFile, "Remove Precision and mm Rule")
docFile.Save
docFile.Close
iLogicVb.UpdateWhenDone = True
Next
Rule that gets fired in all parts as a result of drawing level rule being run:
Dim oPartDoc As PartDocument
oPartDoc=ThisApplication.ActiveDocument
Dim oUserParam As UserParameter
Dim oFormat As CustomPropertyFormat
']
'*** For Each User Parameter....
'[
For Each oUserParam In oPartDoc.ComponentDefinition.Parameters.UserParameters
oUserParamName = oUserParam.Name
If oUserParamName = "G_L" Then
If oUserParam.ExposedAsProperty Then
If oUserParam.Units="mm"Then
oFormat=oUserParam.CustomPropertyFormat
oUserParam.ExposedAsProperty=True
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kTwoDecimalPlacesPrecision
oFormat.Units="mm"
oFormat.ShowUnitsString=False
oFormat.ShowLeadingZeros=True
oFormat.ShowTrailingZeros=False
End If
End If
Else
End If
Next oUserParam