Message 1 of 3
Weird behavior in circular patterns
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to create a circular pattern using the following code. It creates the pattern but not the same way the GUI does and it creates a something in the component tree which will cause a hard crash of Fusion 360.
Here's my code:
class fusionAPI: def __init__(self): try: self.app = adsk.core.Application.get() self.core = adsk.core self.ui = self.app.userInterface self.product = self.app.activeProduct self.design = adsk.fusion.Design.cast(self.product) self.rootComp = self.design.rootComponent self.sketches = self.rootComp.sketches self.pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062 self.globalOrigin = adsk.core.Point3D.create(0,0,0) self.extrudes = self.rootComp.features.extrudeFeatures self.getUserParameterNames() self.orientAligned = adsk.fusion.DimensionOrientations.AlignedDimensionOrientation self.orientHorizontal = adsk.fusion.DimensionOrientations.HorizontalDimensionOrientation self.orientVertical = adsk.fusion.DimensionOrientations.VerticalDimensionOrientation except: if self.ui: self.ui.messageBox('Problem in __init__:\n{}'.format(traceback.format_exc())) def circularPatternFeature(self,feature, axis = None, n = 6, totalAngle = 360, AngleUnits = 'deg'): if axis == None: axis = self.rootComp.yConstructionAxis if not isinstance(n,str): n = str(n) if not isinstance(totalAngle,str): totalAngle = str(totalAngle) totalAngle += ' ' + AngleUnits #Create a new component to stick the pattern in newOcc = self.rootComp.occurrences.addNewComponent(adsk.core.Matrix3D.create()) # grab the body from the feature anc create an Assembly Context in the new component body = feature.faces.item(0).body body = body.createForAssemblyContext(newOcc) # create an assembly contect for the axis as well in the new component axis = self.rootComp.yConstructionAxis.createForAssemblyContext(newOcc) # create an object collection and add the body to it entities = adsk.core.ObjectCollection.create() entities.add(body) # create a circular pattern circularPatterns = self.rootComp.features.circularPatternFeatures patternInput = circularPatterns.createInput(entities,axis) numInstances = adsk.core.ValueInput.createByString(n) totalAngle = adsk.core.ValueInput.createByString(totalAngle) patternInput.quantity = numInstances patternInput.totalAngle = totalAngle circularPatterns.add(patternInput) return newOcc
create in insance of fusionAPI and then pass a feature into circularPatternFeature
This is what I get:
The original component was the Single_Segment:1. I turned off the visibility to highlight the new component (Component2:1). Now look at the C-Pattern1 Group(8). It does indeed have 8 bodies, but notice that it has 2 bodies labled Body1. If I click on the first Body 1 or even mouse over it, it will cause a crash.
Am I doing something wrong or is this a bug?
21st Century Woodworking
-Blending 21st Century Woodworking with Old World Skill
-Blending 21st Century Woodworking with Old World Skill