<?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 Re: Radius of tangent circle cannot be set properly in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/radius-of-tangent-circle-cannot-be-set-properly/m-p/9443624#M12173</link>
    <description>&lt;P&gt;I tried running your code and it runs without any errors but I don't know if the result is what you expect.&amp;nbsp; What is the specific problem?&amp;nbsp; One thing I would be cautious of is drawing things of the X-Y sketch plane and expecting constraints to behave like normal.&amp;nbsp; In the UI you're limited to what you can do with curves that aren't on the X-Y sketch plane.&amp;nbsp; For example, I can't add a dimension constraint to the circles.&amp;nbsp; You would be better off having to sketches, one for each Z height.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Apr 2020 01:47:34 GMT</pubDate>
    <dc:creator>BrianEkins</dc:creator>
    <dc:date>2020-04-15T01:47:34Z</dc:date>
    <item>
      <title>Radius of tangent circle cannot be set properly</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/radius-of-tangent-circle-cannot-be-set-properly/m-p/9442907#M12172</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a problem with proper setting radius of circle when:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;circle is tangent to arcs&lt;/LI&gt;&lt;LI&gt;Z coordinate of those arcs and circle is different than 0&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I checked it for lines and then it works. I use newest version of Fusion for Windows, monthly subscription.&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import adsk.core, adsk.fusion

def run(context):
    app = adsk.core.Application.get()
    product = app.activeProduct
    design = adsk.fusion.Design.cast(product)
    rootComponent = design.rootComponent
    design.designType = adsk.fusion.DesignTypes.DirectDesignType

    sketch = rootComponent.sketches.add(rootComponent.xYConstructionPlane)

    # Lines - z=0   OK, radius of circle is 1
    z = 0
    p11 = adsk.core.Point3D.create(2, 1, z)
    p12 = adsk.core.Point3D.create(5, 1.5, z)
    p21 = adsk.core.Point3D.create(1, 1, z)
    p22 = adsk.core.Point3D.create(2.6, 6, z)

    line1 = sketch.sketchCurves.sketchLines.addByTwoPoints(p11, p12)
    line2 = sketch.sketchCurves.sketchLines.addByTwoPoints(p21, p22)

    circle1 = sketch.sketchCurves.sketchCircles.addByCenterRadius(adsk.core.Point3D.create(4, 4, z), 1)

    # Make circle tangent to lines
    line1.isFixed = True
    line2.isFixed = True
    sketch.geometricConstraints.addTangent(circle1, line1)
    sketch.geometricConstraints.addTangent(circle1, line2)

    # Lines - z=5   OK, radius of circle is 1
    z = 5
    p11 = adsk.core.Point3D.create(2, 1, z)
    p12 = adsk.core.Point3D.create(5, 1.5, z)
    p21 = adsk.core.Point3D.create(1, 1, z)
    p22 = adsk.core.Point3D.create(2.6, 6, z)

    line1 = sketch.sketchCurves.sketchLines.addByTwoPoints(p11, p12)
    line2 = sketch.sketchCurves.sketchLines.addByTwoPoints(p21, p22)

    circle1 = sketch.sketchCurves.sketchCircles.addByCenterRadius(adsk.core.Point3D.create(4, 4, z), 1)

    # Make circle tangent to lines
    line1.isFixed = True
    line2.isFixed = True
    sketch.geometricConstraints.addTangent(circle1, line1)
    sketch.geometricConstraints.addTangent(circle1, line2)

    # Arcs - z=0   OK, radius of circle is 1
    z = 0
    p1s = adsk.core.Point3D.create(12, 1, z)
    p1e = adsk.core.Point3D.create(15, 1.5, z)
    p1m = adsk.core.Point3D.create(13.5, 1.4, z)
    p2s = adsk.core.Point3D.create(11, 1, z)
    p2e = adsk.core.Point3D.create(12.6, 6, z)
    p2m = adsk.core.Point3D.create(11.5, 3.8, z)

    p1sSketch = sketch.sketchPoints.add(p1s)
    p1eSketch = sketch.sketchPoints.add(p1e)
    arc1 = sketch.sketchCurves.sketchArcs.addByThreePoints(p1sSketch, p1m, p1eSketch)
    p2sSketch = sketch.sketchPoints.add(p2s)
    p2eSketch = sketch.sketchPoints.add(p2e)
    arc2 = sketch.sketchCurves.sketchArcs.addByThreePoints(p2sSketch, p2m, p2eSketch)

    circle2 = sketch.sketchCurves.sketchCircles.addByCenterRadius(adsk.core.Point3D.create(14, 4, z), 1)
    arc1.isFixed = True
    arc2.isFixed = True
    sketch.geometricConstraints.addTangent(circle2, arc1)
    sketch.geometricConstraints.addTangent(circle2, arc2)
    circle2.radius = 1

    # Arcs - z=5   WRONG, radius of circle is not 1
    z = 5
    p1s = adsk.core.Point3D.create(12, 1, z)
    p1e = adsk.core.Point3D.create(15, 1.5, z)
    p1m = adsk.core.Point3D.create(13.5, 1.4, z)
    p2s = adsk.core.Point3D.create(11, 1, z)
    p2e = adsk.core.Point3D.create(12.6, 6, z)
    p2m = adsk.core.Point3D.create(11.5, 3.8, z)

    p1sSketch = sketch.sketchPoints.add(p1s)
    p1eSketch = sketch.sketchPoints.add(p1e)
    arc1 = sketch.sketchCurves.sketchArcs.addByThreePoints(p1sSketch, p1m, p1eSketch)
    p2sSketch = sketch.sketchPoints.add(p2s)
    p2eSketch = sketch.sketchPoints.add(p2e)
    arc2 = sketch.sketchCurves.sketchArcs.addByThreePoints(p2sSketch, p2m, p2eSketch)

    circle2 = sketch.sketchCurves.sketchCircles.addByCenterRadius(adsk.core.Point3D.create(14, 4, z), 1)
    arc1.isFixed = True
    arc2.isFixed = True
    sketch.geometricConstraints.addTangent(circle2, arc1)
    sketch.geometricConstraints.addTangent(circle2, arc2)
    circle2.radius = 1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 19:05:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/radius-of-tangent-circle-cannot-be-set-properly/m-p/9442907#M12172</guid>
      <dc:creator>marcinszydlowski.1984</dc:creator>
      <dc:date>2020-04-14T19:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: Radius of tangent circle cannot be set properly</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/radius-of-tangent-circle-cannot-be-set-properly/m-p/9443624#M12173</link>
      <description>&lt;P&gt;I tried running your code and it runs without any errors but I don't know if the result is what you expect.&amp;nbsp; What is the specific problem?&amp;nbsp; One thing I would be cautious of is drawing things of the X-Y sketch plane and expecting constraints to behave like normal.&amp;nbsp; In the UI you're limited to what you can do with curves that aren't on the X-Y sketch plane.&amp;nbsp; For example, I can't add a dimension constraint to the circles.&amp;nbsp; You would be better off having to sketches, one for each Z height.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 01:47:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/radius-of-tangent-circle-cannot-be-set-properly/m-p/9443624#M12173</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2020-04-15T01:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: Radius of tangent circle cannot be set properly</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/radius-of-tangent-circle-cannot-be-set-properly/m-p/9443749#M12174</link>
      <description>&lt;P&gt;Hi Brian,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the problem is that &lt;STRONG&gt;circle2.radius = 1&amp;nbsp;&lt;/STRONG&gt;in the fourth example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;...
    # Arcs - z=5   WRONG, radius of circle is not 1
    z = 5
    p1s = adsk.core.Point3D.create(12, 1, z)
    p1e = adsk.core.Point3D.create(15, 1.5, z)
    p1m = adsk.core.Point3D.create(13.5, 1.4, z)
    p2s = adsk.core.Point3D.create(11, 1, z)
    p2e = adsk.core.Point3D.create(12.6, 6, z)
    p2m = adsk.core.Point3D.create(11.5, 3.8, z)

    p1sSketch = sketch.sketchPoints.add(p1s)
    p1eSketch = sketch.sketchPoints.add(p1e)
    arc1 = sketch.sketchCurves.sketchArcs.addByThreePoints(p1sSketch, p1m, p1eSketch)
    p2sSketch = sketch.sketchPoints.add(p2s)
    p2eSketch = sketch.sketchPoints.add(p2e)
    arc2 = sketch.sketchCurves.sketchArcs.addByThreePoints(p2sSketch, p2m, p2eSketch)

    circle2 = sketch.sketchCurves.sketchCircles.addByCenterRadius(adsk.core.Point3D.create(14, 4, z), 1)
    arc1.isFixed = True
    arc2.isFixed = True
    sketch.geometricConstraints.addTangent(circle2, arc1)
    sketch.geometricConstraints.addTangent(circle2, arc2)
    circle2.radius = 1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;doesn't work for arcs on z = 5 but similar code works for lines (second example):&lt;/P&gt;&lt;LI-CODE lang="python"&gt;...
# Lines - z=5   OK, radius of circle is 1
...&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;I changed radius of circle in the second example after applying constraints and it works.&lt;/P&gt;&lt;P&gt;But it doesn't when I use arcs:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="All examples visible" style="width: 895px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/754344i5AFF752B8906EFC8/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot_22.png" alt="All examples visible" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;All examples visible&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="View from top (along Z axis)" style="width: 811px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/754343i7A54EB2A90AC6408/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot_23.png" alt="View from top (along Z axis)" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;View from top (along Z axis)&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My target is to set all radiuses equals in one sketch. I can use many sketches but without direct design it'll expand timeline significantly and slow down Fusion. I cannot use sweep in this case. I also tried parametric design with adding radial dimension (as driving) to the circle but it didn't help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to know if I do something wrong or it is specific behaviour for constraints with arcs and I have to do workaround for it.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 05:49:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/radius-of-tangent-circle-cannot-be-set-properly/m-p/9443749#M12174</guid>
      <dc:creator>marcinszydlowski.1984</dc:creator>
      <dc:date>2020-04-15T05:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: Radius of tangent circle cannot be set properly</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/radius-of-tangent-circle-cannot-be-set-properly/m-p/9443848#M12175</link>
      <description>&lt;P&gt;If it's not a bug, please close this. I've handled this using cosines theorem which is enough for my case.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 07:10:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/radius-of-tangent-circle-cannot-be-set-properly/m-p/9443848#M12175</guid>
      <dc:creator>marcinszydlowski.1984</dc:creator>
      <dc:date>2020-04-15T07:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: Radius of tangent circle cannot be set properly</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/radius-of-tangent-circle-cannot-be-set-properly/m-p/9457940#M12176</link>
      <description>&lt;P&gt;Ok. As a quick workaround for this particular case I used law of cosines. I always need one case&amp;nbsp; (two intersection points of circles and third circle inside the second one) so formula will be always the same. Another assumption is that circles/arcs are intersect together in two points.&lt;/P&gt;&lt;P&gt;For those of you who have similar &lt;STRONG&gt;problem with proper radius between three tangent circles/arcs on coordinate Z different than 0&lt;/STRONG&gt; here's the idea and solution.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="We need to find the center of red circle for given radius" style="width: 715px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/757572i86745671E7D7B3AE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Circle tangent to two others.png" alt="We need to find the center of red circle for given radius" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;We need to find the center of red circle for given radius&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Symbols:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;O1 - known center of circle/arc 1&lt;/LI&gt;&lt;LI&gt;O2 - known center of circle/arc 2&lt;/LI&gt;&lt;LI&gt;r1 - known radius of circle/arc 1&lt;/LI&gt;&lt;LI&gt;r2 - known radius of circle/arc 2&lt;/LI&gt;&lt;LI&gt;r3 - desired radius of circle/arc 3&lt;/LI&gt;&lt;LI&gt;d - known distance between centers of circles/arcs 1 and 2&lt;/LI&gt;&lt;LI&gt;r1 + r3 - known distance between centers of circles/arcs 1 and 3&lt;/LI&gt;&lt;LI&gt;r2 - r3 - known distance between centers of circles/arcs 2 and 3&lt;/LI&gt;&lt;LI&gt;alpha - angle between vectors d and r1r3&lt;/LI&gt;&lt;LI&gt;betha - angle between vector [1, 0, 0] and r1r3&lt;/LI&gt;&lt;LI&gt;O3 - unknown center of circle/arc 3&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;The idea is to find center of circle 3 based on distance r1 + r3 and angle alpha + betha.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cosine theorem for triangle O1 O2 O3 is:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cosine formula for triangle O1 O2 O3" style="width: 517px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/757577iAF9CBB085B273A77/image-size/large?v=v2&amp;amp;px=999" role="button" title="Cosine theorem.png" alt="Cosine formula for triangle O1 O2 O3" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Cosine formula for triangle O1 O2 O3&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;By transforming this we can obtain alpha angle:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Alpha angle" style="width: 466px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/757578iB9409002E3899EB5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Alpha angle.png" alt="Alpha angle" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Alpha angle&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is all we need. All script showing an example is listed below.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import math
import adsk.core, adsk.fusion

def run(context):
    app = adsk.core.Application.get()
    product = app.activeProduct
    design = adsk.fusion.Design.cast(product)
    rootComp = design.rootComponent

    # Assumption that circle 3 is inside circle 2 and near the top intersection point of circles 1 and 2
    z = 3

    # Circle 1
    radius1 = 3.1
    center1 = adsk.core.Point3D.create(-1, 0.5, z)

    # Circle 2
    radius2 = 2.03
    center2 = adsk.core.Point3D.create(3.5, 1.2, z)

    # Draw circle 1 and 2
    sketch = rootComp.sketches.add(rootComp.xYConstructionPlane)
    sketch.sketchCurves.sketchCircles.addByCenterRadius(center1, radius1)
    sketch.sketchCurves.sketchCircles.addByCenterRadius(center2, radius2)

    # Show wait
    adsk.core.Application.get().userInterface.messageBox("Click to continue...", "Waiting")

    # Circle 3
    radius3 = 0.9

    # Calculations
    d = center1.distanceTo(center2)
    r1r3 = radius1 + radius3
    r2r3 = radius2 - radius3
    alpha = math.acos((r2r3**2 - r1r3**2 - d**2) / (-2 * r1r3 * d))
    betha = center1.vectorTo(center2).angleTo(adsk.core.Vector3D.create(1, 0, 0))
    center3x = center1.x + r1r3 * math.cos(alpha + betha)
    center3y = center1.y + r1r3 * math.sin(alpha + betha)
    center3 = adsk.core.Point3D.create(center3x, center3y, z)
    sketch.sketchCurves.sketchCircles.addByCenterRadius(center3, radius3)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Formulas for other cases (outside circles, other intersection point, different direction) will be slightly different but idea is the same. The only differences will be with signs +/-. You have to remember that for non-intersecting circles/arcs it'll raise cosine domain error so you need to change approach.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2020 05:55:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/radius-of-tangent-circle-cannot-be-set-properly/m-p/9457940#M12176</guid>
      <dc:creator>marcinszydlowski.1984</dc:creator>
      <dc:date>2020-04-21T05:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: Radius of tangent circle cannot be set properly</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/radius-of-tangent-circle-cannot-be-set-properly/m-p/9517821#M12177</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5741855"&gt;@BrianEkins&lt;/a&gt;&amp;nbsp;for the tip. It seems that keeping profiles or other important features per sketch is the best solution so far.&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2020 04:53:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/radius-of-tangent-circle-cannot-be-set-properly/m-p/9517821#M12177</guid>
      <dc:creator>marcinszydlowski.1984</dc:creator>
      <dc:date>2020-05-15T04:53:08Z</dc:date>
    </item>
  </channel>
</rss>

