Symmetric pattern via API?

Symmetric pattern via API?

kelly3QHXN
Explorer Explorer
311 Views
3 Replies
Message 1 of 4

Symmetric pattern via API?

kelly3QHXN
Explorer
Explorer

In the UI it's fairly easy to create a symmetric rectangular pattern. In the API documentation I can't find any way to do this. Is there a hidden way to create a symmetric pattern feature, or do I have to move the object and use a regular distance / extent pattern?

Thanks!

0 Likes
312 Views
3 Replies
Replies (3)
Message 2 of 4

BrianEkins
Mentor
Mentor

Are you trying to create a pattern in a sketch or of features? Can you post of picture of what you want to do?

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 3 of 4

kelly3QHXN
Explorer
Explorer

I'm creating a rectangular pattern feature, with an object type of features as well. Here's how I'd do it in the UI 

kelly3QHXN_0-1739029662674.png

I haven't found anything in the documentation that lets me set the direction to "symmetric." It's easy enough to move the initial object to one end and go from there, but I was curious if there's support for symmetry via the API.

0 Likes
Message 4 of 4

openers_blowout-0u
Community Visitor
Community Visitor

There is a thing called isSymmetricInDirectionOne as part of RectangularPatternFeature and RectangularPatternFeatureInput as per Autodesk Fusion API Reference: https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-cfa9dcf3-60e7-44cd-98b9-64561789fee0 

But I can't get it to work, using this Code Sample as a basis:
https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-b4d4a7c2-ee53-11e4-8d07-f8b156d7cd97 

 

import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        
        # Create a document.
        doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
 
        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)

        # Get the root component of the active design.
        rootComp = design.rootComponent
        
        # Create sketch
        sketches = rootComp.sketches
        sketch = sketches.add(rootComp.xZConstructionPlane)
        sketchCircles = sketch.sketchCurves.sketchCircles
        centerPoint = adsk.core.Point3D.create(0, 0, 0)
        sketchCircles.addByCenterRadius(centerPoint, 3.0)
        
        # Get the profile defined by the circle.
        prof = sketch.profiles.item(0)

        # Create an extrusion input
        extrudes = rootComp.features.extrudeFeatures
        extInput = extrudes.createInput(prof, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        
        # Define that the extent is a distance extent of 5 cm.
        distance = adsk.core.ValueInput.createByReal(5)
        extInput.setDistanceExtent(False, distance)

        # Create the extrusion.
        ext = extrudes.add(extInput)
        
        # Get the body created by extrusion
        body = ext.bodies.item(0)
        
        # Create input entities for rectangular pattern
        inputEntites = adsk.core.ObjectCollection.create()
        inputEntites.add(body)
        
        # Get x and y axes for rectangular pattern
        xAxis = rootComp.xConstructionAxis
        yAxis = rootComp.yConstructionAxis
        
        # Quantity and distance
        quantityOne = adsk.core.ValueInput.createByString('3')
        distanceOne = adsk.core.ValueInput.createByString('8 cm')
        quantityTwo = adsk.core.ValueInput.createByString('3')
        distanceTwo = adsk.core.ValueInput.createByString('8 cm')
        
        # Create the input for rectangular pattern
        rectangularPatterns = rootComp.features.rectangularPatternFeatures
        rectangularPatternInput = rectangularPatterns.createInput(inputEntites, xAxis, quantityOne, distanceOne, adsk.fusion.PatternDistanceType.SpacingPatternDistanceType)
        
        # Set the data for second direction
        rectangularPatternInput.setDirectionTwo(yAxis, quantityTwo, distanceTwo)
        
        # Create the rectangular pattern
        rectangularFeature = rectangularPatterns.add(rectangularPatternInput)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

0 Likes