ilogic rule to drive parts causing issues with other rules
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a very simple assembly with three parts. I have a form set up that can drive the depth, height and length. I then have a rule (that I copied from another user, shown below) that will push those numbers to the other parts and drive their sizes. I also have a number that drives the location of a hole from the left side of the part. This all works awesome and I can enter the numbers and everything updates properly (picture).
There is a pipe coupling beneath the hole. When I add a new rule that drives the model state to turn off the hole and the coupling and then add a multi-value parameter to add the "Yes/No" button to the form, the original rule to push the parameters to the parts has an error (specifically line 55). From my (very limited) understanding/testing, I believe the multi-value parameter is confusing it, as the ilogic doesn't know how to push that to the other parts. I am not sure if there is a way to exclude that parameter or if there is another way of doing what I want. I am quite a novice when it comes to the ilogic stuff... so I am doing a lot of staring and head scratching.
Public Sub Main()
CopyUserParams()
End Sub
Private Sub CopyUserParams()
If ThisDoc.Document.DocumentType <> Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox("The active document must be an assembly.")
Return
End If
Dim asmDoc As Inventor.AssemblyDocument = ThisDoc.Document
For Each refDoc As Inventor.Document In asmDoc.AllReferencedDocuments
' Look for part documents.
If refDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject Then
Dim partDoc As Inventor.PartDocument = refDoc
Dim refDocUserParams As UserParameters = partDoc.ComponentDefinition.Parameters.UserParameters
' Add the assembly parameters to the part.
For Each asmUserParam As UserParameter In asmDoc.ComponentDefinition.Parameters.UserParameters
' Check to see if the parameter already exists.
Dim checkParam As UserParameter = Nothing
Try
checkParam = refDocUserParams.Item(asmUserParam.Name)
Catch ex As Exception
checkParam = Nothing
End Try
If checkParam Is Nothing Then
' Create the missing parameter.
refDocUserParams.AddByExpression(asmUserParam.Name, asmUserParam.Expression, asmUserParam.Units)
Else
' Update the value of the existing parameter.
checkParam.Expression = asmUserParam.Expression
End If
Next
End If
Next
iLogicVb.UpdateWhenDone = True
End Sub