- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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("",...)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
At this point, it is an unknown amount of patterns. So doing the rename at the end would probably be more desirable.
Thanks.