<?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 Find All T-Splines by text command or python in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/find-all-t-splines-by-text-command-or-python/m-p/10083703#M9426</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am sure this is an easy question but I searched all day for a solution. I am writing a script to automate some modification on 3D models before CAM.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In design, Some 3d meshes ( with .obj extension)&amp;nbsp; are imported and converted to "Quad to T-spline". I can do that with this script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;import adsk.core, adsk.fusion, adsk.cam, traceback
import os

ui = None
app = adsk.core.Application.get()
ui  = app.userInterface

def run(context):
    try:
        string = ui.inputBox("Directory","File link")
        ui.messageBox(string[0])

        design = adsk.fusion.Design.cast(app.activeProduct)
        design.designType = adsk.fusion.DesignTypes.ParametricDesignType
        
        #Import Meshes
        file_list = os.listdir(string[0])
        for obj in file_list:
            file_url = os.path.join(string[0], obj)
            design.rootComponent.meshBodies.add(file_url, adsk.fusion.MeshUnits.MillimeterMeshUnit) 
        design.designType = adsk.fusion.DesignTypes.DirectDesignType
        
        #Change Names of Meshes and Create T-Spline from them
        array = design.rootComponent.meshBodies
        for component in array:
            component.name = ' '.join([str(elem) for elem in component.name.split(' ')[4:]])
            ui.activeSelections.clear()
            ui.activeSelections.add(component)
            
            #Create T-Spline for each model
            app.executeTextCommand("Commands.Start TSpline2BRepCommand")
            x = app.executeTextCommand("NuCommands.CommitCmd")
            
            # At this point, I added a screenshot of the browser
            # For now, I need to do these
            # 1) Changing name of T-Spline with component.name
            # 2) Add thicken feature to Mesh with 0.1 mm 

    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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is that I can not iterate the T-Spline objects. If I can get the T-spline which is created with textcommand above.&amp;nbsp; I can change its name and add a thichen modification.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;</description>
    <pubDate>Mon, 15 Feb 2021 08:33:39 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-02-15T08:33:39Z</dc:date>
    <item>
      <title>Find All T-Splines by text command or python</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/find-all-t-splines-by-text-command-or-python/m-p/10083703#M9426</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am sure this is an easy question but I searched all day for a solution. I am writing a script to automate some modification on 3D models before CAM.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In design, Some 3d meshes ( with .obj extension)&amp;nbsp; are imported and converted to "Quad to T-spline". I can do that with this script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;import adsk.core, adsk.fusion, adsk.cam, traceback
import os

ui = None
app = adsk.core.Application.get()
ui  = app.userInterface

def run(context):
    try:
        string = ui.inputBox("Directory","File link")
        ui.messageBox(string[0])

        design = adsk.fusion.Design.cast(app.activeProduct)
        design.designType = adsk.fusion.DesignTypes.ParametricDesignType
        
        #Import Meshes
        file_list = os.listdir(string[0])
        for obj in file_list:
            file_url = os.path.join(string[0], obj)
            design.rootComponent.meshBodies.add(file_url, adsk.fusion.MeshUnits.MillimeterMeshUnit) 
        design.designType = adsk.fusion.DesignTypes.DirectDesignType
        
        #Change Names of Meshes and Create T-Spline from them
        array = design.rootComponent.meshBodies
        for component in array:
            component.name = ' '.join([str(elem) for elem in component.name.split(' ')[4:]])
            ui.activeSelections.clear()
            ui.activeSelections.add(component)
            
            #Create T-Spline for each model
            app.executeTextCommand("Commands.Start TSpline2BRepCommand")
            x = app.executeTextCommand("NuCommands.CommitCmd")
            
            # At this point, I added a screenshot of the browser
            # For now, I need to do these
            # 1) Changing name of T-Spline with component.name
            # 2) Add thicken feature to Mesh with 0.1 mm 

    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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is that I can not iterate the T-Spline objects. If I can get the T-spline which is created with textcommand above.&amp;nbsp; I can change its name and add a thichen modification.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2021 08:33:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/find-all-t-splines-by-text-command-or-python/m-p/10083703#M9426</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-02-15T08:33:39Z</dc:date>
    </item>
    <item>
      <title>Re: Find All T-Splines by text command or python</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/find-all-t-splines-by-text-command-or-python/m-p/10085769#M9427</link>
      <description>&lt;P&gt;Hi @Anonymous&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please attach a couple of OBJ files?&lt;BR /&gt;The error occurs in an unrelated area and it is difficult to reproduce the situation.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2021 02:27:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/find-all-t-splines-by-text-command-or-python/m-p/10085769#M9427</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2021-02-16T02:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: Find All T-Splines by text command or python</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/find-all-t-splines-by-text-command-or-python/m-p/10086167#M9428</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3787950" target="_self"&gt;&lt;SPAN class="login-bold"&gt;kandennti&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help.&amp;nbsp; I attached the sample folder.&lt;/P&gt;&lt;P&gt;1) Exporting zip file to someplace&lt;/P&gt;&lt;P&gt;2) When you run the script, copy- and paste the directory of the folder into the input box.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;C:\Users\xxxx\Downloads\xxxx\sample&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The script is working on windows system but I think it also works on Linux or Mac because of python libraries.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2021 08:00:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/find-all-t-splines-by-text-command-or-python/m-p/10086167#M9428</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-02-16T08:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: Find All T-Splines by text command or python</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/find-all-t-splines-by-text-command-or-python/m-p/10086877#M9429</link>
      <description>&lt;P&gt;@Anonymous&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I couldn't find a way to access the TSplineBody, so I went into Parametric Design to edit the FormFeatur and converted it.&lt;/P&gt;
&lt;P&gt;After that, I think I can add the thickness of the surface.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import adsk.core, adsk.fusion, adsk.cam, traceback
import os

ui = None
app = adsk.core.Application.get()
ui  = app.userInterface

def run(context):
    try:
        # string = ui.inputBox("Directory","File link")
        # ui.messageBox(string[0])
        string  = [r'C:\Temp']
        design = adsk.fusion.Design.cast(app.activeProduct)
        design.designType = adsk.fusion.DesignTypes.ParametricDesignType

        #Import Meshes
        file_list = os.listdir(string[0])
        for obj in file_list:
            file_url = os.path.join(string[0], obj)
            design.rootComponent.meshBodies.add(file_url, adsk.fusion.MeshUnits.MillimeterMeshUnit) 
        # design.designType = adsk.fusion.DesignTypes.DirectDesignType

        # Create FormFeature
        root = design.rootComponent
        forms = root.features.formFeatures
        fFeat :adsk.fusion.FormFeature = forms.add()
        tBodies :adsk.fusion.TSplineBodies = fFeat.tSplineBodies

        # FormFeature start edit
        fFeat.startEdit()

        #Change Names of Meshes and Create T-Spline from them
        meshBodies = design.rootComponent.meshBodies
        for mBody in meshBodies:
            mBody.name = ' '.join([str(elem) for elem in mBody.name.split(' ')[4:]])
            ui.activeSelections.clear()
            ui.activeSelections.add(mBody)
            
            #Create T-Spline for each model
            app.executeTextCommand("Commands.Start TSpline2BRepCommand")
            app.executeTextCommand("NuCommands.CommitCmd")

            # rename TSplineBody
            tBody :adsk.fusion.TSplineBody = tBodies[-1]
            tBody.name = mBody.name

        # FormFeature finish edit
        fFeat.finishEdit()

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 16 Feb 2021 14:07:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/find-all-t-splines-by-text-command-or-python/m-p/10086877#M9429</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2021-02-16T14:07:17Z</dc:date>
    </item>
  </channel>
</rss>

