This worked for one assembly but I have a circular pattern nested within a linear pattern in another assembly and its not working correctly. its giving me this message below:
Error Message:
Error in rule: Orientation, in document: Tray Stack, Bottom_HC3.iam
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
More Info
System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor.OccurrencePatterns.get_Item(Object Index)
at LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
I have attached a screenshot of the model tree structure. The "rotational pattern" is the one I want to switch within the "Linear Pattern"
Here is the code:
SyntaxEditor Code Snippet
trigger = OrientationNumeric
Dim oDoc = ThisDoc.Document
Dim oDef As AssemblyComponentDefinition
oDef = oDoc.ComponentDefinition
Dim oPattern As CircularOccurrencePattern
oPattern = oDef.OccurrencePatterns.Item("Rotational Pattern")
If OrientationNumeric = 0 Then
oPattern.AxisEntityNaturalDirection = False
Else
oPattern.AxisEntityNaturalDirection = True
End If