Problem with constraining and fillet

Problem with constraining and fillet

Anonymous
Not applicable
751 Views
2 Replies
Message 1 of 3

Problem with constraining and fillet

Anonymous
Not applicable

Hi all! I just started with Fusion 360 API and trying to figure out how to use it with 2D sketches...


I'm trying to make a fully constrained square with a series of smaller squares inside and curved edges on each side of each square. I found a way to print out the squares using a for loop, but can't make them constrained and can't apply a fillet on its edges. Would really appreciate any advice. Thanks!

import adsk.core, adsk.fusion, traceback

user_params = {}

def createParam(design, name, value, units, comment):
    userValue = adsk.core.ValueInput.createByString(value)
    newParam = design.userParameters.add(name, userValue, units, comment)

    return newParam
    
def run(context):
    ui = None
    try: 
        app = adsk.core.Application.get()
        ui = app.userInterface
        design = app.activeProduct
        
        doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
        # Get the root component of the active design.
        rootComp = adsk.fusion.Component.cast(design.rootComponent)
        core3Dpoint = adsk.core.Point3D.create;
        # Create a new sketch on the xy plane.
        sketches = rootComp.sketches;
        xzPlane = rootComp.xZConstructionPlane;
        firstS = sketches.add(xzPlane);        
        o = firstS.originPoint;      
        
        constraints = firstS.geometricConstraints;
        lines = firstS.sketchCurves.sketchLines;
        points = firstS.sketchPoints;
        center = points.add(core3Dpoint(0,0,0));        
        constraints.addCoincident(o,center);
             
        for i in range(1, 5):
            lines.addCenterPointRectangle(core3Dpoint(0,0,0), core3Dpoint(i, i, 0));
        
        constraints.addParallel()
               
        user_params['g_width'] = createParam(design, 'g_width', '100', 'mm', '')
        user_params['g_height'] = createParam(design, 'g_height', '100', 'mm', '')      
        
        center = adsk.core.Point3D.create(0, 5, 0)
        
        addRect(sketches, rootComp.xYConstructionPlane, center, ['g_height', 'g_width'])

    except:
        if ui:
            ui.messageBox('Failed. This code sucks, you know it and I know it:\n{}'.format(traceback.format_exc()))

Screen Shot 2019-05-29 at 9.20.17 PM.png

0 Likes
752 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

thank you guys and girls didn't expect all this help😳😨

0 Likes
Message 3 of 3

Anonymous
Not applicable

Sure no problem!

0 Likes