Rename circular pattern elements with ilogic

Rename circular pattern elements with ilogic

rlileikis
Participant Participant
990 Views
2 Replies
Message 1 of 3

Rename circular pattern elements with ilogic

rlileikis
Participant
Participant

Hello. I am making  water tank. It is made by using steel plate.  I am using circular pattern of the steel plate. To get different height of the tank, i am using different number of the patterns above each other. To change diameter of the tank, i am adjusting circular pattern (by adding or removing extra steel plates)

Later i will use ilogic rule, to make hole in different plates. I need to have constant name of the plates if i want that my rule would be runing. 

Everytime am i getting different names of the plate then i am adjusting diameter of the tank.

How i can write the rule in iLogic, to keep the name of the plates constant? I have 7 circular patterns (Ras1, Ras2.....Ras7). Pattern Ras1 looks like that:

Ras1

   -Element:1

       -Steel plate:1

   -Element:2

       -Steel plate:16

   -Element:3

       -Steel plate:560

   -Element:4

       -Steel plate:609

I would like to have like that:

Ras1

   -Element:1

       -Ras1:1

   -Element:2

       -Ras1:2

   -Element:3

       -Ras1:3

   -Element:4

       -Ras1:4

The same would be with other patterns (Ras2, Ras3......)

I found information about renaming in forum too. But in that example, Logic rule are changing names of all elements in all patterns at the same time. I would like to change names in  pattern 1 (Ras1) first. Later i would like to change name of elements in pattern 2 (Ras2) and so on....

0 Likes
Accepted solutions (1)
991 Views
2 Replies
Replies (2)
Message 2 of 3

dutt.thakar
Collaborator
Collaborator
Accepted solution

@rlileikis 

 

Try this code and see if it works. This code will iterate through all the patterns you have in your assembly and change the name of occurrences inside the element from the pattern name. Make sure you run this code in the end once you are done with exchanging components. In the below code I am assuming that, there is only one occurrence inside the pattern element, which means you are only patterning one component in one pattern and not multiple. This one will also change in all patterns at once but it will reindex and start from 1 when it switches from one pattern to another, so you will always get first element starts with ":1" in each of your pattern.

 

 

Dim oDef As AssemblyComponentDefinition = ThisApplication.ActiveDocument.ComponentDefinition

Dim oPattern As OccurrencePattern 

For Each oPattern In oDef.OccurrencePatterns
x = 1
For Each oElement As OccurrencePatternElement In oPattern.OccurrencePatternElements

oElement.Occurrences.Item(1).Name = oPattern.Name & ":" & x
x = x + 1
Next
Next  

 

If you still want to explicitly change for Ras1,first and then Ras2 etc. What I suggest is to create a multivalue text parameter named as Pattern and add your Pattern names (Ras1, Ras2) in it. After that you can try below rule. So what you need to do is to select the parameter and run this rule so it will change the occurrence name in that specific pattern only.

 

Dim oDef As AssemblyComponentDefinition = ThisApplication.ActiveDocument.ComponentDefinition

Dim oPattern As OccurrencePattern = oDef.OccurrencePatterns.Item(Parameter("Pattern"))

x = 1
For Each oElement As OccurrencePatternElement In oPattern.OccurrencePatternElements

oElement.Occurrences.Item(1).Name = oPattern.Name & ":" & x
x = x + 1
Next

 

Hope this will be helpful.

 

 

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes
Message 3 of 3

rlileikis
Participant
Participant

It works!!!. Thankyou very much!!!

0 Likes