- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Controlling Number of Features in a Circular Pattern - iLogic
How do you control the number of features in a circular pattern(of a single part) with iLogic? I can count them but don't know how to change them. I can change the parameter directly but is there something like oCircularPatternFeature.NumberOfElements?
SyntaxEditor Code Snippet
Dim oDoc As PartDocument Dim oCompDef As PartComponentDefinition Dim oCircularPatternFeature As CircularPatternFeature Dim oCircularPatternFeatures As CircularPatternFeatures Dim dNumberOfBolts As Parameter 'Set the document oDoc = ThisDoc.Document 'Set the component definition oCompDef = oDoc.ComponentDefinition 'Set the circular pattern features collection oCircularPatternFeatures = oCompDef.Features.CircularPatternFeatures 'Show the number of bolts For Each oCircularPatternFeature In oCircularPatternFeatures If oCircularPatternFeature.Name = "BoltPattern" Then dNumberOfBolts = oCircularPatternFeature.Count MessageBox.Show("There are now " & dNumberOfBolts.Value & " bolts.", "Test") Else End If Next
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
In the documentation is looks like you can redefine your pattern with the "CircularPatternFeatures.Add" Method. Use the Count variable.
CircularPatternFeatures.Add( ParentFeatures As ObjectCollection, AxisEntity As Object, NaturalAxisDirection As Boolean, Count As Variant, Angle As Variant, FitWithinAngle As Boolean, [ComputeType] As PatternComputeTypeEnum ) As CircularPatternFeature
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks for the reply. I did previously try that and got an error message that Count is read-only.
Also, I am not trying to add a new pattern, just modify an existing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I understand you just want to modify the existing pattern but I do not think it's that easy.
I think you will need to redefine the pattern with all of the original inputs plus add to the number of features in the pattern with the count parameter in the add method.
here is a link to a macro for creating a circular pattern from VBA. Maybe it will help push you in the right direction. It uses the .Add method and changes the count parameter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Here is the sample to proof the concept.
It adds the second extrude feature (disk) to the existing circular pattern feature.
Open the attached part file and run the iLogic rule.
'this rule adds one more feature
'to the existing circular pattern Feature
Dim oDoc As PartDocument = ThisDoc.Document
Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
'Feature to be added to the existing pattern
'Should be above the pattern node in the browser!
Dim oPartFeature As PartFeature = oDoc.ComponentDefinition _
.Features.ExtrudeFeatures.Item("Disk")
'reference to the circular pattern feature
Dim oCPF As CircularPatternFeature = oDef.Features.CircularPatternFeatures.Item(1)
'get the feature collection
Dim objCol As ObjectCollection = oCPF.ParentFeatures
'modify the object collection - add one more extrude feature
Call objCol.Add(oPartFeature)
'apply changes to the pattern
oCPF.ParentFeatures = objCol
oDoc.Update
Beep
Initial state:
Result:
cheers,
Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks this helped me a lot also works for RectangularPatternFeature to swap around ParentFeature
Public Sub ChangeElem(oPartDef As PartComponentDefinition, oDoc As Document)
Dim oPartFeature As PartFeature
Set oPartFeature = oPartDef.features.HoleFeatures.Item("TRP3_HOLE")
Dim oRPF As RectangularPatternFeature
Set oRPF = oPartDef.features.RectangularPatternFeatures.Item("TopPattern")
Dim objCol As ObjectCollection
Set objCol = oRPF.Definition.ParentFeatures
'I added the clear so I can swap the old ParentFeature with a new one
Call objCol.Clear
Call objCol.Add(oPartFeature)
oRPF.Definition.ParentFeatures = objCol
oRPF.Definition.NaturalXDirection = False
oDoc.Update
End Sub