Would like to use assembly driven by iLogic to create "variations" of the assembly, Vault, perform copy design, and have the iLogic rules in the copied design still work.
As near as I can tell, an ilogic statement such as:
Parameter("main_dp:1", "main_dp_ht") = case_ht-.25
actually addresses the file main_dp.ipt
Thus, if during the copy design process I name the new file main_dp_new.ipt (so I can generate unique file names in the Vault), when I run the rule in the copied design I get an error telling me the component cannot be found. I tried doing the copy design without the "update part number" checked, but that does not work so I can only conclude as per above that the actual file name is being referenced, not the part number.
Is there a way to "alias" the reference to the part number instead of the file name, or something similar, so the rule will work in the copied design?
Thanks
Mike
Solved! Go to Solution.
Solved by MjDeck. Go to Solution.
Hi Mike, I had the same problem, my solution is below. It just gets the part from the base view. If you have more views of other parts etc you can change the view item number to the one you want or cycle through the views and match via view name or some other property. Just add the code to your ilogic.
Option Explicit
Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oView As DrawingView
Dim oRefDoc As Document
oDoc = ThisDoc.Document
oSheet = oDoc.ActiveSheet
oView = oSheet.DrawingViews.Item(1) ' Item 1 is the base view
oRefDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument ' Gets the views referenced assembly
' Checks value of parameter to see value
If oRefDoc.ComponentDefinition.Parameters.Item("NAME_OF_PARAMETER_HERE").Value = "0" Then
' Do Something
End If
Regards, Matt.
Matt,
You can simplify your code in Inventor 2011 and later:
oRefDoc = ThisDrawing.ModelDocument ' will give you the first referenced document it finds.
oRefDoc = ActiveSheet.View("VIEW1").ModelDocument ' gives you the document for a particular view.
Mike,
Matt's solution is for a drawing. But it looks like your rule is running in an assembly.
In order for rules that use component names work after you copy an assembly, you have to change the component names in the assembly Model browser. This will stabilize the names. The default is for the component name to be the same as the file name. But you can edit the name manually:
You can change the name once, and then immediately change it back to the original. After you change it, the name won't change when the filename changes. So in your copy, it will remain as main_dp:1 instead of changing to main_dp_new:1. Since the component name remains unchanged, the iLogic rule can still find it.
There's a disadvantage to this method: you might want to be able to see the current file name in the assembly Model browser. But this is the most straightforward method to fix the problem.
We have a couple of standard designs that we do this for. Some things to note if you're doing this with Copy Design.
1. Create an assembly or drawing that references all the components that need to be copied for the design. We have found that that just referencing the final assembly doesn't always work because of parts that may be suppressed are not included during the check process. So it helps to have a file that can reference all possible parts at once.
2. Rename all components in assemblies to a fixed name if they are going to be referred to from a rule. This avoids having to do anything fancy when the actual files are copied and renamed after a copy design. In our case the file, component names, and part numbers are all different. There's rules that go and set the new part numbers on affected parts but the rules refers to each part using a fixed component name.
3. Make sure users don't delete 'unused' components if they ever want to run rules again. Along with this make sure users are on the (iLogic) level of detail.
Just a few things to keep in mind.
This is what actually worked. As long as you "touch" the name, it will stabilize - I don't know why this works, but it does survive the copy design process.
Thanks!
Mike
Sorry about that, For some reason i was thinking about IDW's 😛
Thanks Mike, I'll have to use that code, I usually use vb.net and forget about the iLogic built in code.
Cheers, Matt.
Can't find what you're looking for? Ask the community or share your knowledge.