<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Problem with constraining and fillet in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/problem-with-constraining-and-fillet/m-p/8824857#M14111</link>
    <description>&lt;P&gt;Hi all! I just started with Fusion 360 API and trying to figure out how to use it with 2D sketches...&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;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 &lt;STRONG&gt;for&lt;/STRONG&gt; loop, but can't make them constrained and can't apply a &lt;STRONG&gt;fillet&lt;/STRONG&gt; on its edges. Would really appreciate any advice. Thanks!&lt;/P&gt;&lt;PRE&gt;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()))&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Screen Shot 2019-05-29 at 9.20.17 PM.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/642556iDB43EC682A30C7B7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2019-05-29 at 9.20.17 PM.png" alt="Screen Shot 2019-05-29 at 9.20.17 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 31 May 2019 02:53:14 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-05-31T02:53:14Z</dc:date>
    <item>
      <title>Problem with constraining and fillet</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/problem-with-constraining-and-fillet/m-p/8824857#M14111</link>
      <description>&lt;P&gt;Hi all! I just started with Fusion 360 API and trying to figure out how to use it with 2D sketches...&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;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 &lt;STRONG&gt;for&lt;/STRONG&gt; loop, but can't make them constrained and can't apply a &lt;STRONG&gt;fillet&lt;/STRONG&gt; on its edges. Would really appreciate any advice. Thanks!&lt;/P&gt;&lt;PRE&gt;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()))&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Screen Shot 2019-05-29 at 9.20.17 PM.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/642556iDB43EC682A30C7B7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2019-05-29 at 9.20.17 PM.png" alt="Screen Shot 2019-05-29 at 9.20.17 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 02:53:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/problem-with-constraining-and-fillet/m-p/8824857#M14111</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-05-31T02:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with constraining and fillet</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/problem-with-constraining-and-fillet/m-p/9349153#M14112</link>
      <description>&lt;P&gt;thank you guys and girls didn't expect all this help&lt;span class="lia-unicode-emoji" title=":flushed_face:"&gt;😳&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":fearful_face:"&gt;😨&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 18:32:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/problem-with-constraining-and-fillet/m-p/9349153#M14112</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-28T18:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with constraining and fillet</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/problem-with-constraining-and-fillet/m-p/9349157#M14113</link>
      <description>&lt;P&gt;Sure no problem!&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 18:33:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/problem-with-constraining-and-fillet/m-p/9349157#M14113</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-28T18:33:03Z</dc:date>
    </item>
  </channel>
</rss>

