- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear Community,
I need to implement routine which after event trigger “After Open Document” stores current Representation View of assembly in custom iProperty then switch to Default Representation View. Then “Before Save Document” event trigger restoring the original Representation View of the assembly.
To do so I wrote 3 iLogic rules:
Rule 1 – checking if custom property exists, if not creating it with empty value. Reading current Rep View and store as string in the custom property.
Dim PropertyName1 As String = "RepView"
oCustomPropertySet = ThisApplication.ActiveDocument.PropertySets.Item("Inventor User Defined Properties")
'look for custom iproperty and try to use it
Try
oProp = oCustomPropertySet.Item(PropertyName1)
Catch
' iproperty not found , create and assign value
oCustomPropertySet.Add("", PropertyName1)
End Try
Dim odoc As Document
Dim ocompdef As ComponentDefinition
Dim paramNames As String() = {"x" }
odoc = ThisApplication.ActiveDocument
ocompdef = odoc.ComponentDefinition
'current rep view read
x = ocompdef.RepresentationsManager.ActiveDesignViewRepresentation.Name
odoc.PropertySets.Item("Inventor User Defined Properties").Item("RepView").Value = x
Rule 2 – changing Rep View to Default.
Dim odoc As Document
Dim ocompdef As ComponentDefinition
odoc = ThisApplication.ActiveDocument
ocompdef = odoc.ComponentDefinition
''change rep view to Default
Try
ocompdef.RepresentationsManager.DesignViewRepresentations.Item("Default").Activate
Catch
MessageBox.Show("This viewrep does not exist", "Error")
End Try
Rule 3 – restoring original Rep View.
Dim odoc As Document
Dim ocompdef As ComponentDefinition
Dim paramNames As String() = {"y" }
odoc = ThisApplication.ActiveDocument
ocompdef = odoc.ComponentDefinition
''change rep view to original
y = odoc.PropertySets.Item("Inventor User Defined Properties").Item("RepView").Value
Try
ocompdef.RepresentationsManager.DesignViewRepresentations.Item(y).Activate
Catch
MessageBox.Show("This viewrep does not exist", "Error")
End Try
Following external rules executed manually in sequence Rule 1, Rule 2, Rule 3 work well. When I try to assign Event Trigger to each of them, so that Rule 1 and Rule 2 to be triggered “After Open Document” and Rule 3 to be triggered “Before Save Document” the routine fails. The effect is that I receive Default value in custom iProperty and assemblies don’t come back to original Rep View, just staying in Default Rep View.
I tried to bypass it somehow by creating dummy external rule which triggers the rules and combine Rule 1 and Rule 2 in single rule without success.
Because I am rather novice in writing iLogic rules please support me and correct if I am wrong. I would like to understand why the rules triggered manually in proper sequence works but automatically not.
Thank you in advance.
Best regards
Krzysztof
Solved! Go to Solution.