<?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: How to edit a loft by API in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-edit-a-loft-by-api/m-p/9589089#M11404</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6607933"&gt;@bjoern79de&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using the attached file, I was able to process it like an image.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 737px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/785539i51E3B79AD99BB204/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;This is the source code.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;#Fusion360API Python script
import adsk.core, adsk.fusion, traceback

_app = adsk.core.Application.cast(None)
_ui = adsk.core.UserInterface.cast(None)

def run(context):
    try:
        global _app, _ui
        _app = adsk.core.Application.get()
        _ui = _app.userInterface
        des  :adsk.fusion.Design = _app.activeProduct
        root :adsk.fusion.Component = des.rootComponent

        # get loft
        loft = root.features.loftFeatures.item(0)
        sects :adsk.fusion.LoftSections = loft.loftSections

        # get insert profile
        prof :adsk.fusion.Profile = root.sketches.item(2).profiles.item(0)

        # backup markerPosition
        tlPos :int = des.timeline.markerPosition

        # change timeline before loft
        des.timeline.markerPosition = loft.timelineObject.index

        # get the last LoftSection
        endSect :adsk.fusion.LoftSection = sects.item(sects.count - 1)

        # backup the last entity
        endEnt = endSect.entity

        # change the last LoftSection entity
        # LoftSection.entity was a read/write property
        # https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-E0CE293E-9ED4-4E00-A5E6-32695A0F0A40
        endSect.entity = prof

        # add last entity backed up
        sects.add(endEnt)

        # Restore timeline
        des.timeline.markerPosition = tlPos

    except:
        if _ui:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 19 Jun 2020 08:07:24 GMT</pubDate>
    <dc:creator>kandennti</dc:creator>
    <dc:date>2020-06-19T08:07:24Z</dc:date>
    <item>
      <title>How to edit a loft by API</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-edit-a-loft-by-api/m-p/9588202#M11403</link>
      <description>&lt;P&gt;I'm able to remove items from loftFeature.loftSections by:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;for section in loftFeat.loftSections:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; section.deleteMe()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;But I'm not able to add new profiles:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;for&lt;/SPAN&gt;&lt;SPAN&gt; sketch &lt;/SPAN&gt;&lt;SPAN&gt;in&lt;/SPAN&gt; &lt;SPAN&gt;component.sketches&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; loftFeats.&lt;/SPAN&gt;&lt;SPAN&gt;loftSections.add(sketch.profiles[&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"InternalValidationError: entities_size &amp;gt; 0"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Any suggestions?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 18 Jun 2020 19:12:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-edit-a-loft-by-api/m-p/9588202#M11403</guid>
      <dc:creator>bjoern79de</dc:creator>
      <dc:date>2020-06-18T19:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit a loft by API</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-edit-a-loft-by-api/m-p/9589089#M11404</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6607933"&gt;@bjoern79de&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using the attached file, I was able to process it like an image.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 737px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/785539i51E3B79AD99BB204/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;This is the source code.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;#Fusion360API Python script
import adsk.core, adsk.fusion, traceback

_app = adsk.core.Application.cast(None)
_ui = adsk.core.UserInterface.cast(None)

def run(context):
    try:
        global _app, _ui
        _app = adsk.core.Application.get()
        _ui = _app.userInterface
        des  :adsk.fusion.Design = _app.activeProduct
        root :adsk.fusion.Component = des.rootComponent

        # get loft
        loft = root.features.loftFeatures.item(0)
        sects :adsk.fusion.LoftSections = loft.loftSections

        # get insert profile
        prof :adsk.fusion.Profile = root.sketches.item(2).profiles.item(0)

        # backup markerPosition
        tlPos :int = des.timeline.markerPosition

        # change timeline before loft
        des.timeline.markerPosition = loft.timelineObject.index

        # get the last LoftSection
        endSect :adsk.fusion.LoftSection = sects.item(sects.count - 1)

        # backup the last entity
        endEnt = endSect.entity

        # change the last LoftSection entity
        # LoftSection.entity was a read/write property
        # https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-E0CE293E-9ED4-4E00-A5E6-32695A0F0A40
        endSect.entity = prof

        # add last entity backed up
        sects.add(endEnt)

        # Restore timeline
        des.timeline.markerPosition = tlPos

    except:
        if _ui:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 19 Jun 2020 08:07:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-edit-a-loft-by-api/m-p/9589089#M11404</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2020-06-19T08:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit a loft by API</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-edit-a-loft-by-api/m-p/9589131#M11405</link>
      <description>&lt;P&gt;Excuse me. I forgot to attach the file.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 08:48:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/how-to-edit-a-loft-by-api/m-p/9589131#M11405</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2020-06-19T08:48:23Z</dc:date>
    </item>
  </channel>
</rss>

