Message 1 of 4
Find All T-Splines by text command or python

Not applicable
02-15-2021
12:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello
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.
In design, Some 3d meshes ( with .obj extension) are imported and converted to "Quad to T-spline". I can do that with this script.
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()))
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. I can change its name and add a thichen modification.
Best Regards