Message 1 of 10
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I'm currently working on an assembly that contain over 300 parts.
Almost each of those parts contain a derived component.
I need to include a parameter in each derived components in all parts.
So I'm trying to write an iLogic rule that I will run from the assembly and will include that specific parameter in each derived components of all parts.
I'm using this rue that I found on DevBlog. It's working perfectly if I run it from the specific part that contain the derived component but I can't find the proper way to run it from my main assembly.
'If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then ' MsgBox("Make a Part Document the active document") 'End If Dim oDerPart As PartDocument oDerPart = ThisApplication.ActiveDocument Dim oDerPartComp As DerivedPartComponent If oDerPart.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Count < 1 Then MsgBox("No Derived Part Components in this part") End If oDerPartComp = oDerPart.ComponentDefinition.ReferenceComponents.DerivedPartComponents(1) Dim oDerivedPartDef As DerivedPartUniformScaleDef oDerivedPartDef = oDerPartComp.Definition Dim oDerEntity As DerivedPartEntity For Each oDerEntity In oDerivedPartDef.Parameters If (oDerEntity.ReferencedEntity.Name = "BLADE_ATTACK_ANGLE") Then oDerEntity.IncludeEntity = True Exit For End If Next 'Set Definition back, so DerivedPart Document is updated oDerPartComp.Definition = oDerivedPartDef
This is my try to run it from the assembly but it's not doing anything...
Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition Dim oOccurrence As ComponentOccurrence Dim oDoc As Document = ThisDoc.Document Dim oCompDef As Inventor.ComponentDefinition = oDoc.ComponentDefinition Dim oCompOcc As Inventor.ComponentOccurrence On Error Resume Next For Each oOccurrence In oCompDef.Occurrences Parameter.Quiet = True ' **** CHANGE TO DO **** ' INCLUDE A DERIVED COMPONENT PARAMETER Dim oDerPartComp As DerivedPartComponent oCompOcc = oOccurrence.Definition oDerPartComp = oCompOcc.ComponentDefinition.ReferenceComponents.DerivedPartComponents(1) Dim oDerivedPartDef As DerivedPartUniformScaleDef oDerivedPartDef = oDerPartComp.Definition Dim oDerEntity As DerivedPartEntity For Each oDerEntity In oDerivedPartDef.Parameters If (oDerEntity.ReferencedEntity.Name = "BLADE_ATTACK_ANGLE") Then oDerEntity.IncludeEntity = True Exit For End If Next 'Set Definition back, so DerivedPart Document is updated oDerPartComp.Definition = oDerivedPartDef ' **** END **** On Error Resume Next Next InventorVb.DocumentUpdate()
I hope that someone will be able to correct my code!
Best regards
Solved! Go to Solution.