Message 1 of 2
Copying Derived Parent's iProprties without using ActiveDocument.DocumentType
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Currently using the following rule to copy iProperties from Parent to Child for Derived Parts. (Copied from another forum post years ago).
If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then MessageBox.Show("Make a Part Document the active document,Exiting", "iLogic") Else Dim oDerDoc As PartDocument oDerDoc = ThisApplication.ActiveDocument 'Look for Derived part components If oDerDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Count < 1 Then MessageBox.Show("No Derived Part Components in this part", "iLogic") ElseIf oDerDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Count > 1 Then MessageBox.Show("More than one Derived Part Components in this part,Exiting!", "iLogic") Else ' Set a reference to the part component definition Dim oDerCompDef As PartComponentDefinition oDerCompDef = oDerDoc.ComponentDefinition 'Get a reference to derived part components in this part Dim oDerComps As DerivedPartComponents oDerComps = oDerCompDef.ReferenceComponents.DerivedPartComponents 'Get a reference to derived part component Dim oDerComp As DerivedPartComponent oDerComp = oDerComps(1)'1st component 'MessageBox.Show(oDerComp.Name, "iLogic") ' Get the Reference document. Dim oRefDoc As Document oRefDoc = oDerComp.ReferencedDocumentDescriptor.ReferencedDocument 'Creates the iProperty in the derived part and assigns the iProperty value of the refDoc iProperties.Value("Summary", "Title") = iProperties.Value(oRefDoc.DisplayName, "Summary", "Title") iProperties.Value("Project", "Description") = iProperties.Value(oRefDoc.DisplayName, "Project", "Description") iProperties.Value("Project", "Part Number") = ThisDoc.FileName(False) 'MessageBox.Show("iProperty Copied from Parent to Child", "Success") End If End If
While this works fine when working on the individual ipt, it runs into problems when located in an assembly and either trying to regen all rules at the assembly or editing the part in place and running the rule.
Our current workflow is to open each individual ipt and run the rule to update the iProperties. This is not a good workflow.
I don't know enough about iLogic to rewrite the code in a way that works. Any Suggestions?