iLogic Add Rect pattern name

iLogic Add Rect pattern name

blandb
Mentor Mentor
312 Views
4 Replies
Message 1 of 5

iLogic Add Rect pattern name

blandb
Mentor
Mentor

Anyone happen to know why when leaving the name blank when adding a rect. pattern errors out in:

 

Patterns.AddRectangular("", "ComponentA:1", 3, 1.5 in, Nothing, "X Axis", columnNaturalDirection := True, rowCount := 2, rowOffset := 1.0 in, rowEntityName := "Y Axis", rowNaturalDirection := True)

But you can do that when placing a component from content center or a mate and automatically indexes it to the next number? 

Components.AddContentCenterPart("",...)
Constraints.AddFlush("",...)

 

Autodesk Certified Professional
0 Likes
Accepted solutions (2)
313 Views
4 Replies
Replies (4)
Message 2 of 5

blandb
Mentor
Mentor

Ok, so does anyone have a better solution to add multiple patterns to an assembly and have it auto index the next rectangular pattern browser number? I have a rule that will be run several times to do things, and It will potentially add a new pattern each time its ran. So I was hoping to just leave the pattern name blank and have it auto fill the browser name as if I manually added a pattern.

Autodesk Certified Professional
0 Likes
Message 3 of 5

WCrihfield
Mentor
Mentor
Accepted solution

Hi @blandb.  I have not really looked into it yet, but if it will not allow you to specify an empty String as its name when you originally create it by code, then maybe it will allow you to supply a random or unique name when creating it, then change its name to an empty String afterwards.  If the pattern has a BrowserNode, then we should be able to set its name to an empty string after the fact, to reset its name to its default, with the next index Integer after its name.  Just a quick thought.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 5

Curtis_Waguespack
Consultant
Consultant
Accepted solution

@blandb 

 

I am guessing about this, but recall that the iLogic functions often have more going on under the hood than we can see. I suspect the Add Constraint and Add CC Part functions include handlers for blank fields, that autogenerate the names when one is not provided.

 

And the Add Rect Pattern function simply doesn't have that sort of handler.

 

As for how to proceed, I would probably add a loop to the end of your rule, and have it rename all of the rectangular patterns.

 

Dim rectPattern = Patterns.AddRectangular("RectPatternName", "Part:3", 3, 1.5 in, Nothing, 
"X Axis", columnNaturalDirection := True, rowCount := 2, rowOffset := 1.0 in, rowEntityName := "Y Axis", 
rowNaturalDirection := True)

Dim oDoc As AssemblyDocument = ThisDoc.Document
i = 1
For Each oPattern As OccurrencePattern In oDoc.ComponentDefinition.OccurrencePatterns
	oPattern.Name = "Component Pattern:" & i
	i = i+1
Next

 

Or get the pattern count on the front end, and increment the count by 1:

 

Dim oDoc As AssemblyDocument = ThisDoc.Document
patcount = oDoc.ComponentDefinition.OccurrencePatterns.Count

Dim rectPattern = Patterns.AddRectangular("Component Pattern:" & patcount+1, "Part:3", 3, 1.5 in, Nothing, 
"X Axis", columnNaturalDirection := True, rowCount := 2, rowOffset := 1.0 in, rowEntityName := "Y Axis", 
rowNaturalDirection := True)

 

EESignature

0 Likes
Message 5 of 5

blandb
Mentor
Mentor

At this point, it is an unknown amount of patterns. So doing the rename at the end would probably be more desirable.

 

Thanks.

Autodesk Certified Professional
0 Likes