Linking Parameters in iLogic with variable names

Linking Parameters in iLogic with variable names

Anonymous
Not applicable
1,342 Views
5 Replies
Message 1 of 6

Linking Parameters in iLogic with variable names

Anonymous
Not applicable

So I have an iLogic rule for linking parameters of a sub-assembly. The idea is that there is a skeleton that all of the parts in the sub-asm are referenced to and the sub-asm file controls the skeleton. This is used as a template to create a final panel. Using assistant, I want to copy, rename the files for manufacturing purposes all while maintaining the links. The script was written really basic..

Parameter("Top BP Template_Skeleton:1", "WIDTH") = WIDTH
Parameter("Top BP Template_Skeleton:1", "HEIGHT") = HEIGHT

Parameter("Alum Top BP Template:1", "WIDTH") = Parameter("Top BP Template_Skeleton:1", "WIDTH")
Parameter("Alum Top BP Template:1", "HEIGHT") = Parameter("Top BP Template_Skeleton:1", "HEIGHT")

Parameter("Galv Top BP Template:1", "WIDTH") = Parameter("Top BP Template_Skeleton:1", "WIDTH")
Parameter("Galv Top BP Template:1", "HEIGHT") = Parameter("Top BP Template_Skeleton:1", "HEIGHT")

Parameter("327 Top BP Template:1", "LENGTH") = Parameter("Top BP Template_Skeleton:1", "WIDTH")

 How can this be modified so that no matter what I change the name to, It will recognize the file name and update the rule?

0 Likes
Accepted solutions (1)
1,343 Views
5 Replies
Replies (5)
Message 2 of 6

Justin.B.
Enthusiast
Enthusiast

By iterating through each component occurrence in the assembly, you can set everything without needing to know the names of each component. Let the for-loop provide the names of each element as it finds them, and feed that into the Parameter() function you're already using.

 

Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In ThisApplication.ActiveDocument.ComponentDefinition.Occurrences

Parameter(oOccurrence.Name, "WIDTH") = WIDTH
Parameter(oOccurrence.Name, "HEIGHT") = HEIGHT Next

 

0 Likes
Message 3 of 6

Anonymous
Not applicable

Thanks for the response! Its simple and works, but the only thing I have is that it is made up of 2D components (HxW) and 1D components (W). Is there an exception I can write to ignore the missing parameters?

 

 

0 Likes
Message 4 of 6

Justin.B.
Enthusiast
Enthusiast
Accepted solution

Missing parameters will throw an error, and you can tell it to just ignore those and move on to the next loop.

Dim oOccurrence As ComponentOccurrence
On Error Resume Next
For Each oOccurrence In ThisApplication.ActiveDocument.ComponentDefinition.Occurrences Parameter(oOccurrence.Name, "WIDTH") = WIDTH
Parameter(oOccurrence.Name, "HEIGHT") = HEIGHT Next

Generally speaking, errors are useful and you should handle them rather than ignoring them, but for a short script like this where you can clearly anticipate what the errors will be it's a quick fix.

Message 5 of 6

Anonymous
Not applicable

Thanks, appreciate the help. Does exactly what I need it to do.

0 Likes
Message 6 of 6

aronmatheus
Advocate
Advocate
0 Likes