iLogic rule run from a part wont do work on an assembly it creates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I frequently make a "master" part with multiple bodies that i export into separate parts, and I then insert those part into an assembly. I then import another library part into the assembly.
I have made an iLogic rule for this and it works fine.
My problem is I want to have this rule also apply some mates/flush between some of the objects in the assembly, so things end up in the right place automatically.
I have managed to make a rule that can do this if I have the assembly open, but if I trigger it from the above mentioned rule to make the whole thing automated it will not run because i get the error message:
Error in rule: MoveLid, in document: 4321-013-001.ipt ThisAssembly: This document "4321-013-001.ipt" is not an assembly.
The rule I'm using:
Sub Main() Dim casename As String = "peli1660" 'Dim casename As String = RuleArguments("name") Dim asm As AssemblyDocument asm = ThisApplication.ActiveDocument Dim oOccurrence As ComponentOccurrence For Each oOccurrence In asm.ComponentDefinition.Occurrences If Not TypeOf oOccurrence.Definition Is VirtualComponentDefinition Then If oOccurrence.Name.Contains("Lokk") oOccurrence.Grounded = False Constraints.AddFlush(oOccurrence.Name+"Mate1", oOccurrence.Name, "XY Plane", {casename+":1", "Lokk:1" }, "XY Plane", ) Constraints.AddFlush(oOccurrence.Name+"Mate2", oOccurrence.Name, "YZ Plane", {casename+":1", "Lokk:1" }, "YZ Plane", ) Constraints.AddFlush(oOccurrence.Name+"Mate3", oOccurrence.Name, "XZ Plane", {casename+":1", "Lokk:1" }, "XZ Plane", ) End If End If Next End Sub
"Constraints.AddFlush..." is the line(s) that cause troubles.
Is there a way to make this work if I start the whole thing from a part file?