<?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: Non-minimum Profile.boundingBox. Is it a bug? in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/non-minimum-profile-boundingbox-is-it-a-bug/m-p/10130267#M9313</link>
    <description>&lt;P&gt;I tried it. It is indeed strange.&lt;BR /&gt;It seemed to be happening only when there were duplicate entities.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I'm guessing, but looking at the documentation, I think the description here implies that it's not very accurate.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-9ce5053e-72b6-4a47-8172-e4223fb4caff" target="_blank" rel="noopener"&gt;https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-9ce5053e-72b6-4a47-8172-e4223fb4caff&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 713px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/888732i6B1349BF9F865460/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I'm sure it's to speed up the process, but even so, the discrepancy seems huge.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead, I felt that BoundingBox3D is always guaranteed to contain entities.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Mar 2021 15:08:21 GMT</pubDate>
    <dc:creator>kandennti</dc:creator>
    <dc:date>2021-03-04T15:08:21Z</dc:date>
    <item>
      <title>Non-minimum Profile.boundingBox. Is it a bug?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/non-minimum-profile-boundingbox-is-it-a-bug/m-p/10128902#M9312</link>
      <description>&lt;P&gt;My assumption in using Profile.boundingBox has always been that it returns a minimum bounding box. But in practice I have encountered some cases that Profile.boundingBox returns a non-minimum bounding box. Is it a bug or it is by design?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example as shown in the following sample for two intersecting circles, Profile.boundingBox returns a minimum bounding box for the middle profile (shared area of the circles), but returns a non-minimum bounding box for the other two profiles.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import adsk.core, adsk.fusion, traceback

ui = None

def run(context):
        try:
                global ui
                app = adsk.core.Application.get()
                ui  = app.userInterface
                
                design = adsk.fusion.Design.cast(app.activeProduct)
                rootComp = design.rootComponent
                
                sketches = rootComp.sketches
                sketch = sketches.add(rootComp.xZConstructionPlane)
                sketchCircles = sketch.sketchCurves.sketchCircles

                centerPoint = adsk.core.Point3D.create(0, 0, 0)
                sketchCircles.addByCenterRadius(centerPoint, 10.0)

                centerPoint = adsk.core.Point3D.create(10, 0, 0)
                sketchCircles.addByCenterRadius(centerPoint, 10.0)

                boundingBoxesSketch = sketches.add(rootComp.xZConstructionPlane) 
                
                for profile in sketch.profiles:
                        boundingBoxesSketch.sketchCurves.sketchLines.addTwoPointRectangle(profile.boundingBox.minPoint, profile.boundingBox.maxPoint)
        except:
                if ui:
                        ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="34.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/888466i3174564253D52F66/image-size/large?v=v2&amp;amp;px=999" role="button" title="34.png" alt="34.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 07:20:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/non-minimum-profile-boundingbox-is-it-a-bug/m-p/10128902#M9312</guid>
      <dc:creator>nnikbin</dc:creator>
      <dc:date>2021-03-04T07:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: Non-minimum Profile.boundingBox. Is it a bug?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/non-minimum-profile-boundingbox-is-it-a-bug/m-p/10130267#M9313</link>
      <description>&lt;P&gt;I tried it. It is indeed strange.&lt;BR /&gt;It seemed to be happening only when there were duplicate entities.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I'm guessing, but looking at the documentation, I think the description here implies that it's not very accurate.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-9ce5053e-72b6-4a47-8172-e4223fb4caff" target="_blank" rel="noopener"&gt;https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-9ce5053e-72b6-4a47-8172-e4223fb4caff&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 713px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/888732i6B1349BF9F865460/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I'm sure it's to speed up the process, but even so, the discrepancy seems huge.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead, I felt that BoundingBox3D is always guaranteed to contain entities.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 15:08:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/non-minimum-profile-boundingbox-is-it-a-bug/m-p/10130267#M9313</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2021-03-04T15:08:21Z</dc:date>
    </item>
    <item>
      <title>Re: Non-minimum Profile.boundingBox. Is it a bug?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/non-minimum-profile-boundingbox-is-it-a-bug/m-p/10131105#M9314</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3787950"&gt;@kandennti&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Thank you for your reply and thank you for trying the sample.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even minimum bounding boxes provide rough approximation of the volume in the space (except for non-rotatd cubes) so I think form that part of the document that you highlighted we may not be able to strictly conclude whether the box is minimum or not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2228534"&gt;@KrisKaplan&lt;/a&gt;&amp;nbsp; [&lt;A href="https://forums.autodesk.com/t5/fusion-360-api-and-scripts/wrong-bounding-boxes-after-splitting-a-torus/m-p/5892880" target="_blank" rel="noopener"&gt;from this post]&lt;/A&gt;&lt;/P&gt;&lt;P&gt;"BRepBody.boundingBox uses a method that favors speed over a tight fitting aligned bounding box. So the box returned is guaranteed to enclose the body, but not necessarily to be the tightest fitting box."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It confirms your idea about "speed up the process" but I think for sketches the calculations may be simpler than BRepBodies, so perhaps there is a bug in returning a non-minimum bounding box.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think it will be nice if the documents mention whether the bounding box is guranteed to be minimal or not.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 19:18:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/non-minimum-profile-boundingbox-is-it-a-bug/m-p/10131105#M9314</guid>
      <dc:creator>nnikbin</dc:creator>
      <dc:date>2021-03-04T19:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: Non-minimum Profile.boundingBox. Is it a bug?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/non-minimum-profile-boundingbox-is-it-a-bug/m-p/10131884#M9315</link>
      <description>&lt;P&gt;My guess is that the purpose of implementing the BoundingBox is to speed up the checking of interference using Octree.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;If the process of checking for exact interference takes a long time, the space to be checked needs to be narrowed down in order to speed up the process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As an alternative, the MeasureManager.getOrientedBoundingBox method was described as doing the exact processing.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-DE730595-9235-4DA1-8096-22A058921819" target="_blank" rel="noopener"&gt;https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-DE730595-9235-4DA1-8096-22A058921819&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used it to do this, and it worked correctly.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import adsk.core, adsk.fusion, traceback

ui = None

def run(context):
    try:
        global ui
        app = adsk.core.Application.get()
        ui  = app.userInterface
        
        design = adsk.fusion.Design.cast(app.activeProduct)
        rootComp = design.rootComponent
        
        sketches = rootComp.sketches
        plane = rootComp.xZConstructionPlane #.xYConstructionPlane

        sketch = sketches.add(plane)
        sketchCircles = sketch.sketchCurves.sketchCircles

        centerPoint = adsk.core.Point3D.create(0, 0, 0)
        sketchCircles.addByCenterRadius(centerPoint, 10.0)

        centerPoint = adsk.core.Point3D.create(10, 0, 0)
        sketchCircles.addByCenterRadius(centerPoint, 10.0)

        boundingBoxesSketch = sketches.add(plane)

        for profile in sketch.profiles:
            bound = getPreciseBoundingBox3D(profile)
            boundingBoxesSketch.sketchCurves.sketchLines.addTwoPointRectangle(bound.minPoint, bound.maxPoint)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


def getPreciseBoundingBox3D(
    profile :adsk.fusion.Profile
    ) -&amp;gt; adsk.core.BoundingBox3D:

    # get sketch
    skt :adsk.fusion.Sketch = profile.parentSketch
    sktMat :adsk.core.Matrix3D = skt.transform

    # get WireBody
    loop :adsk.fusion.ProfileLoop = profile.profileLoops[0]
    crvs = [pc.geometry for pc in loop.profileCurves]
    if not sktMat.isEqualTo(adsk.core.Matrix3D.create()):
        for crv in crvs:
            crv.transformBy(sktMat)

    tmpMgr = adsk.fusion.TemporaryBRepManager.get()
    wireBody, _ = tmpMgr.createWireFromCurves(crvs)

    # get OrientedBoundingBox3D
    vecX :adsk.core.Vector3D = skt.xDirection
    vecY :adsk.core.Vector3D = skt.yDirection

    app = adsk.core.Application.get()
    measureMgr :adsk.core.MeasureManager = app.measureManager
    orientedBox :adsk.core.OrientedBoundingBox3D = measureMgr.getOrientedBoundingBox(
        wireBody, vecY, vecX)

    halfX = orientedBox.width * 0.5
    halfY = orientedBox.length * 0.5
    halfZ = orientedBox.height * 0.5

    vec3D = adsk.core.Vector3D
    maxPnt :adsk.core.Point3D = orientedBox.centerPoint.copy()
    maxPnt.translateBy(vec3D.create(halfX, halfY, halfZ))

    minPnt :adsk.core.Point3D = orientedBox.centerPoint.copy()
    minPnt.translateBy(vec3D.create(-halfX, -halfY, -halfZ))

    return adsk.core.BoundingBox3D.create(minPnt, maxPnt)&lt;/LI-CODE&gt;
&lt;P&gt;To be honest, I think there are easier ways to do this.&lt;BR /&gt;I have not tested enough, so I may have missed something.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 01:23:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/non-minimum-profile-boundingbox-is-it-a-bug/m-p/10131884#M9315</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2021-03-05T01:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: Non-minimum Profile.boundingBox. Is it a bug?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/non-minimum-profile-boundingbox-is-it-a-bug/m-p/10132163#M9316</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3787950"&gt;@kandennti&lt;/a&gt;&amp;nbsp;for sharing this nice solution and sharing your guess.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually I have been able to find another workaround for finding the minimum bounding box of profiles and have used it in my project. My main goal for this post was knowing what we can expect from Profile.boundingBox and whether returning non-minimum bounding box is a bug or not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Personally I guess we could expect exact bounding boxes for sketch elements using Fusion 360 API and it is a bug.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 05:31:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/non-minimum-profile-boundingbox-is-it-a-bug/m-p/10132163#M9316</guid>
      <dc:creator>nnikbin</dc:creator>
      <dc:date>2021-03-05T05:31:39Z</dc:date>
    </item>
  </channel>
</rss>

