Hi all,
Our models currently have a mix of 3 distictive parts;
some parts have ilogic rules in them that write parameters back to the iProperties (length, width, etc)
some parts have expressions within the iProperties that autofill from the parameters.
some parts are a bit dumb and have manually typed iProperties.
I am looking for a new rule at assembly level that will look at all the parts in that assembly and return a list of parts that have no rules or expressions within them. Is this even possible? It would be a massive time saving tool if it was.
Many thanks in anticipation!
Solved! Go to Solution.
Solved by mrattray. Go to Solution.
Superb Mike,
No need to interrogate the sub assemblies themselves but the parts beneath will need looking at. The rule name in question is "Iprops" other rules may exist in the parts but it is the "Iprops" rule that extracts info and populates the iProperties.
As for the iProperties, we populate the "Subject" field with our part dimensions. These expressions read the custom fields as normal.
I can see your plan with searching for the left most character being "=" nice, simple and effective.
Many thanks Mike.
This proved to be more challenging than I expected, but try this:
Option Explicit Sub Main() Dim oComp, oSubComp As ComponentOccurrence Dim oComps, oSubComps As ComponentOccurrences Dim oCompDoc, oSubCompDoc As Document Dim msg As Long Dim oProp As String Dim oPropSet As PropertySet oComps = ThisDoc.Document.ComponentDefinition.Occurrences For Each oComp In oComps If oComp.Suppressed = False Then If oComp.ReferencedDocumentDescriptor.ReferencedDocumentType = kAssemblyDocumentObject Then oSubComps = oComp.Definition.Occurrences For Each oSubComp In oSubComps If oSubComp.Suppressed = False Then If oSubComp.ReferencedDocumentDescriptor.ReferencedDocumentType = kAssemblyDocumentObject Then msg = MsgBox("This rule does not look at sub assemblies of sub assemblies. They will need to be checked seperately. Proceed?",vbOKCancel,"Property checker") If msg = vbCancel Then Exit Sub Else If checkRules(oSubComp) = False Then oSubCompDoc = oSubComp.Definition.Document oPropSet = oSubCompDoc.PropertySets.Item("Summary Information") oProp = oPropSet.Item("Subject").Expression If Left(oProp,1) <> "=" Then MsgBox("This component needs to be updated: " & oSubComp.Name, vbOKOnly, "Property checker") End If End If End If End If Next Else If checkRules(oComp) = False Then oCompDoc = oComp.Definition.Document oPropSet = oCompDoc.PropertySets.Item("Summary Information") oProp = oPropSet.Item("Subject").Expression If Left(oProp,1) <> "=" Then MsgBox("This component needs to be updated: " & oComp.Name, vbOKOnly, "Property checker") End If End If End If End If Next End Sub Function checkRules(oComp As ComponentOccurrence) As Boolean 'returns true if the rule in question is found Dim oAutomation As Object Dim oRule As Object Dim oRules As Object oAutomation = iLogicVb.Automation oRules = oAutomation.Rules(oComp.Definition.Document) If oRules Is Nothing Then Exit Function For Each oRule In oRules If oRule.Name = "Iprops" Then Return True Next End Function
This wont work for subs of subs. You'll have to run this on any "sub-subs" directly.
First of all, Thank you. Your time and effort is very much appreciated.
Code works well. Looking through what you have done I can grasp most of it. One part I am struggling to understand are the lines where you are asking to search the subject field for "="
Forgive my limited understanding of iLogic but If I were wanting to change the search location in the iProps from "Summary", "Subject" to "Project", "Description" how do I do this? I can't work out how or why you defined "Summary Information". This is the Summary tab on the iprops right?
If checkRules(oSubComp) = False Then oSubCompDoc = oSubComp.Definition.Document oPropSet = oSubCompDoc.PropertySets.Item("Summary Information") oProp = oPropSet.Item("Subject").Expression If Left(oProp,1) <> "=" Then MsgBox("This component needs to be updated: " & oSubComp.Name, vbOKOnly, "Property checker") End
"Summary Information" refers to the property set which contains the "Subject" field. Unfortunately, prop sets don't equate directly to the tabs on your property browser. These prop sets are super-secret double classified. For example, if you wanted to change to the "Description" property, you would have to reference the "Design Tracking Properties" prop set.
The only way I know of to figure out the property system is using this macro (it runs in the API, not iLogic):
(Make sure you open the immediate window to view the results [press ctrl+g].)
Private Sub ReadCustomProps() Dim oPropSet As PropertySet Dim oProp As Property Dim count As Integer count = 0 On Error Resume Next For Each oPropSet In ThisApplication.ActiveDocument.PropertySets Debug.Print oPropSet.DisplayName & " Count: " & oPropSet.count For Each oProp In oPropSet count = count + 1 Debug.Print count & " '" & oProp.Name & "' = '" & oProp.value & "'" Next Next Exit Sub Debug.Print Error End Sub
Can't find what you're looking for? Ask the community or share your knowledge.