<?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: Multiple input to a splitBodyFeature ? in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10966578#M6534</link>
    <description>&lt;P&gt;I wrote this add-in a few years ago and it might be close to what you're looking for.&lt;/P&gt;&lt;P&gt;&lt;A href="https://ekinssolutions.com/sliceitup/" target="_blank"&gt;https://ekinssolutions.com/sliceitup/&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Feb 2022 05:57:03 GMT</pubDate>
    <dc:creator>BrianEkins</dc:creator>
    <dc:date>2022-02-23T05:57:03Z</dc:date>
    <item>
      <title>Multiple input to a splitBodyFeature ?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10963662#M6531</link>
      <description>&lt;P&gt;I am trying to split a model into sections of 1cm along one axis(lets say Y-axis)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The model is about 700cm high, so there will be 699 sections. I want to read out the volume of each of theese "slices".&amp;nbsp; So if there is a way that doesnt involve splitting the body, I am all ears.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can do it using the API, but the time it takes is extreme. (10 minutes)&lt;/P&gt;&lt;P&gt;Are there any better(read:faster) way than making an offset plane, using it as a splitting tool and splitting the body.?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cant seem to find a way to get the split-feature to accept multiple inputs, i think that is part of the problem, because the timeline gets filled with plane-fetures and split-features. I have also tried to model a continuous line that covers the model in a back-and-forth kind of way, but no luck.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thoughts ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;Andreas&lt;/P&gt;</description>
      <pubDate>Mon, 21 Feb 2022 22:00:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10963662#M6531</guid>
      <dc:creator>andreas.pedersen8EDUH</dc:creator>
      <dc:date>2022-02-21T22:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple input to a splitBodyFeature ?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10964022#M6532</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8472298"&gt;@andreas.pedersen8EDUH&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Think of it as an idea.&lt;/P&gt;
&lt;P&gt;I found the analyzeInterference method to be very fast when I tried it here before.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/fusion-360-api-and-scripts/find-any-interferance-with-active-objects-and-only-one-tool/m-p/10885516" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/fusion-360-api-and-scripts/find-any-interferance-with-active-objects-and-only-one-tool/m-p/10885516&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may want to try creating a box as the tools of the split in advance and check for interference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Feb 2022 03:33:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10964022#M6532</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2022-02-22T03:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple input to a splitBodyFeature ?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10964687#M6533</link>
      <description>&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Hi Mr. Andreas.Pedersen8EDUH,&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Consider implementing &lt;STRONG&gt;&lt;FONT color="#339966"&gt;the splitting process&lt;/FONT&gt;&lt;/STRONG&gt; in the domain of&amp;nbsp;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&lt;STRONG&gt;TemporaryBRepManager&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;It should run much faster. The &lt;EM&gt;&lt;STRONG&gt;F360&lt;/STRONG&gt;&lt;/EM&gt; docs contain some examples of &lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#FF6600"&gt;HOW TO DO IT&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Regards&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;MichaelT&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Feb 2022 11:18:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10964687#M6533</guid>
      <dc:creator>MichaelT_123</dc:creator>
      <dc:date>2022-02-22T11:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple input to a splitBodyFeature ?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10966578#M6534</link>
      <description>&lt;P&gt;I wrote this add-in a few years ago and it might be close to what you're looking for.&lt;/P&gt;&lt;P&gt;&lt;A href="https://ekinssolutions.com/sliceitup/" target="_blank"&gt;https://ekinssolutions.com/sliceitup/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 05:57:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10966578#M6534</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2022-02-23T05:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple input to a splitBodyFeature ?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10966709#M6535</link>
      <description>&lt;P&gt;Thanks for your reply! I will look into this, but as I understand, it will still require 700 tool-boxes ?&lt;/P&gt;&lt;P&gt;-Andreas&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 07:42:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10966709#M6535</guid>
      <dc:creator>andreas.pedersen8EDUH</dc:creator>
      <dc:date>2022-02-23T07:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple input to a splitBodyFeature ?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10966710#M6536</link>
      <description>&lt;P&gt;Thank you for your suggestion, I will look into this, as this may be what I need for reducing the time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;_Andreas&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 07:43:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10966710#M6536</guid>
      <dc:creator>andreas.pedersen8EDUH</dc:creator>
      <dc:date>2022-02-23T07:43:01Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple input to a splitBodyFeature ?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10966713#M6537</link>
      <description>&lt;P&gt;Thank you for your contribution. Looks nice. If I cant fix my script, I will look into your plugin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Andreas&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 07:44:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10966713#M6537</guid>
      <dc:creator>andreas.pedersen8EDUH</dc:creator>
      <dc:date>2022-02-23T07:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple input to a splitBodyFeature ?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10968605#M6538</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8472298"&gt;@andreas.pedersen8EDUH&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;gt;it will still require 700 tool-boxes ?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Yes, it is.&lt;BR /&gt;I'd like to try it out and compare, but I'm busy with work and don't have the time.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 23:19:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10968605#M6538</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2022-02-23T23:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple input to a splitBodyFeature ?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10969915#M6539</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8472298"&gt;@andreas.pedersen8EDUH&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We created a sample to compare.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I didn't know how to do the splitting using TemporaryBRepManager, so I used the booleanOperation method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result of my test was that TemporaryBRepManager was faster to process.&lt;BR /&gt;I feel that the reason for the slowness is the fact that Component.bRepBodies.add needs to be done twice when using the analyzeInterference method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;# Fusion360API Python script

import traceback
import adsk.fusion
import adsk.core
import time

def run(context):
    ui = adsk.core.UserInterface.cast(None)
    try:
        app: adsk.core.Application = adsk.core.Application.get()
        ui = app.userInterface
        des: adsk.fusion.Design = app.activeProduct

        msg: str = 'Select Solid Body'
        selFiltter: str = 'SolidBodies'
        sel: adsk.core.Selection = selectEnt(msg, selFiltter)
        if not sel:
            return

        targetBody:adsk.fusion.BRepBody = sel.entity
        des.designType = adsk.fusion.DesignTypes.ParametricDesignType

        # start test
        app.log(' -- test start --')
        t = time.time()

        # Please switch between test1 and test2 to execute.
        test1(targetBody) # Design.analyzeInterference
        # test2(targetBody) # TemporaryBRepManager.booleanOperation

        app.log(f'done: {time.time() - t} s')

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


def selectEnt(
        msg: str,
        filterStr: str) -&amp;gt; adsk.core.Selection:

    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        sel = ui.selectEntity(msg, filterStr)
        return sel
    except:
        return None

# TemporaryBRepManager.booleanOperation Method
# https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-F845AD0E-D25F-4FDD-B31B-3E6DFC5A8A9B
def test2(
    targetBody: adsk.fusion.BRepBody,
    step: float = 1):

    app: adsk.core.Application = adsk.core.Application.get()
    measMgr: adsk.core.MeasureManager = app.measureManager
    oriBBox: adsk.core.OrientedBoundingBox3D = measMgr.getOrientedBoundingBox(
        targetBody,
        adsk.core.Vector3D.create(1, 0, 0),
        adsk.core.Vector3D.create(0, 1, 0),
    )

    minZ = oriBBox.centerPoint.z - oriBBox.height * 0.5
    halfStep = step * 0.5
    count = int((oriBBox.height // step) + 1)

    baseBBox: adsk.core.OrientedBoundingBox3D = oriBBox.copy()
    baseBBox.centerPoint = adsk.core.Point3D.create(
        oriBBox.centerPoint.x,
        oriBBox.centerPoint.y,
        minZ + halfStep
    )
    baseBBox.height = step

    tempMgr: adsk.fusion.TemporaryBRepManager = adsk.fusion.TemporaryBRepManager.get()
    tempBodies = []
    for idx in range(count):
        bBox: adsk.core.OrientedBoundingBox3D = baseBBox.copy()
        pnt: adsk.core.Point3D = bBox.centerPoint.copy()
        pnt.z = minZ + halfStep + (step * idx)
        bBox.centerPoint = pnt
        tempBodies.append(tempMgr.createBox(bBox))

    # -- Same process until this part --

    resBodies = []
    for tempBody in tempBodies:
        clone: adsk.fusion.BRepBody = tempMgr.copy(targetBody)
        tempMgr.booleanOperation(
            clone,
            tempBody,
            adsk.fusion.BooleanTypes.IntersectionBooleanType
        )
        resBodies.append(clone)

    comp: adsk.fusion.Component = targetBody.parentComponent
    bodies: adsk.fusion.BRepBodies = comp.bRepBodies
    resBaseFeat: adsk.fusion.BaseFeature = comp.features.baseFeatures.add()
    resBaseFeat.startEdit()
    try:
        for body in resBodies:
            bodies.add(
                body,
                resBaseFeat
            )
    except:
        pass
    finally:
        resBaseFeat.finishEdit()

    app.log(f'  bodies count: {resBaseFeat.bodies.count}')


# Design.analyzeInterference Method
# https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-7B17A057-49A7-4332-ACD1-F6FA4EA84C88
def test1(
    targetBody: adsk.fusion.BRepBody,
    step: float = 1):

    app: adsk.core.Application = adsk.core.Application.get()
    measMgr: adsk.core.MeasureManager = app.measureManager
    oriBBox: adsk.core.OrientedBoundingBox3D = measMgr.getOrientedBoundingBox(
        targetBody,
        adsk.core.Vector3D.create(1, 0, 0),
        adsk.core.Vector3D.create(0, 1, 0),
    )

    minZ = oriBBox.centerPoint.z - oriBBox.height * 0.5
    halfStep = step * 0.5
    count = int((oriBBox.height // step) + 1)

    baseBBox: adsk.core.OrientedBoundingBox3D = oriBBox.copy()
    baseBBox.centerPoint = adsk.core.Point3D.create(
        oriBBox.centerPoint.x,
        oriBBox.centerPoint.y,
        minZ + halfStep
    )
    baseBBox.height = step

    tempMgr: adsk.fusion.TemporaryBRepManager = adsk.fusion.TemporaryBRepManager.get()
    tempBodies = []
    for idx in range(count):
        bBox: adsk.core.OrientedBoundingBox3D = baseBBox.copy()
        pnt: adsk.core.Point3D = bBox.centerPoint.copy()
        pnt.z = minZ + halfStep + (step * idx)
        bBox.centerPoint = pnt
        tempBodies.append(tempMgr.createBox(bBox))

    # -- Same process until this part --

    comp: adsk.fusion.Component = targetBody.parentComponent
    bodies: adsk.fusion.BRepBodies = comp.bRepBodies
    bodyObjs: adsk.core.ObjectCollection = adsk.core.ObjectCollection.create()
    bodyObjs.add(targetBody)

    toolBaseFeat: adsk.fusion.BaseFeature = comp.features.baseFeatures.add()
    toolBaseFeat.startEdit()
    try:
        for body in tempBodies:
            bodyObjs.add(
                bodies.add(
                    body,
                    toolBaseFeat
                )
            )
    except:
        pass
    finally:
        toolBaseFeat.finishEdit()

    des: adsk.fusion.Design = app.activeProduct
    interferanceResults: adsk.fusion.InterferenceResults = des.analyzeInterference(
        des.createInterferenceInput(bodyObjs)
    )

    interBodies = []
    res: adsk.fusion.InterferenceResult
    for res in interferanceResults:
        interBodies.append(res.interferenceBody)

    resBaseFeat: adsk.fusion.BaseFeature = comp.features.baseFeatures.add()
    resBaseFeat.startEdit()
    try:
        for body in interBodies:
            bodies.add(
                body,
                resBaseFeat
            )
    except:
        pass
    finally:
        resBaseFeat.finishEdit()

    # resBaseFeat.bodies.count &amp;lt;- 0
    app.log(f'  bodies count: {len(interBodies)}')

    toolBaseFeat.deleteMe()&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 24 Feb 2022 14:38:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10969915#M6539</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2022-02-24T14:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple input to a splitBodyFeature ?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10971369#M6540</link>
      <description>&lt;P&gt;WOW! That was lightning fast compared to my code!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It went from 221 seconds to 10.5 seconds!&lt;/P&gt;&lt;P&gt;I dont need the resulting bodies, just the volumes, best thing is if there is no change on the original model.&lt;/P&gt;&lt;P&gt;Edited your code to not add the resulting bodies, just collectiong their volumes, and the execution time went down to 5.9 seconds! That is very acceptable for me!&lt;/P&gt;&lt;P&gt;Thank you,@kandennti so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Andreas&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 08:25:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/multiple-input-to-a-splitbodyfeature/m-p/10971369#M6540</guid>
      <dc:creator>andreas.pedersen8EDUH</dc:creator>
      <dc:date>2022-02-25T08:25:41Z</dc:date>
    </item>
  </channel>
</rss>

