Hi there.
I am trying to create an external rule to check if parameters do exist and if not create it, and I fail to understand the correct steps and proceudres to follow to make it happen. I am tying to keep it very simple. I have two text parameters:
SetComments: This is used to set the iPoroperties Comments value with in part rule stating: iProperties.Value("Summary", "Comments") = SetComments
FileType: This is used to get the file sub type into a user parameter so that I can display it on a Form. the current in part rule is: File_Tipe = iProperties.Value("Project", "File)
But I don't want to go through all my parts and manually add these rules and user parameter to each and every part.
Ideally, I would like it to be controlled via External rule, then I only have to set the rule up once and just run it from there.
Solved! Go to Solution.
Solved by J-Camper. Go to Solution.
I think this will do what you're looking for:
Sub Main
'set active document parameters
Dim paramNames As String() = {"FillComments", "FileType" }
For i As Integer = 0 To paramNames.Count-1
Call Formatting(ThisApplication.ActiveDocument, paramNames(i))
Next
Call LinkiProperties(ThisApplication.ActiveDocument,paramNames)
'handle assembly occurrences
If ThisApplication.ActiveDocumentType = kAssemblyDocumentObject
For Each oOcc As ComponentOccurrence In ThisApplication.ActiveDocument.ComponentDefinition.Occurrences.AllLeafOccurrences
For i As Integer = 0 To paramNames.Count-1
Call Formatting(oOcc.Definition.Document, paramNames(i))
Next
Call LinkiProperties(oOcc.Definition.Document,paramNames)
Next
End If
End Sub
Sub Formatting(oDoc As Document, name As String)
Try
param = oDoc.ComponentDefinition.Parameters.Item(name)
Catch
param = oDoc.ComponentDefinition.Parameters.UserParameters.AddByValue(name, "filler", kTextUnits)
End Try
End Sub
Sub LinkiProperties(oDoc As Document, allStrings As String())
oDoc.PropertySets.Item("Inventor Summary Information").Item("Comments").Value = oDoc.ComponentDefinition.Parameters.Item(allStrings(0)).Value ' "<" & allStrings(0) & ">"
oDoc.ComponentDefinition.Parameters.Item(allStrings(1)).Value = oDoc.PropertySets.Item("Design Tracking Properties").Item("Document SubType Name").Value
End Sub
You can run from part or assembly and if run in an assembly it will run through all occurrences in the assembly
Can't find what you're looking for? Ask the community or share your knowledge.