<?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: Batch import multiple splines of csv files. And adding a loft between those splines. in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/batch-import-multiple-splines-of-csv-files-and-adding-a-loft/m-p/12751849#M1476</link>
    <description>&lt;P&gt;Your files are encoded differently than mine, so it worked for me and not for you. My files, which I created using Excel, had extra characters at the beginning of the file to specify the encoding type used for the file. I was assuming all files had this same encoding, so I was always ignoring the first three characters. I changed the code, so instead of blindly assuming there are encoding characters at the beginning of the file, I now specify the encoding when opening the file and let Python take care of it.&lt;/P&gt;&lt;P&gt;After fixing that, the loft was failing with your data. The problem is that the files must be named alphabetically in the order they're processed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;They were being processed:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SectionCurve1.csv&lt;/P&gt;&lt;P&gt;SectionCurve10.csv&lt;/P&gt;&lt;P&gt;SectionCurve11.csv&lt;/P&gt;&lt;P&gt;SectionCurve12.csv&lt;/P&gt;&lt;P&gt;SectionCurve13.csv&lt;/P&gt;&lt;P&gt;SectionCurve14.csv&lt;/P&gt;&lt;P&gt;SectionCurve15.csv&lt;/P&gt;&lt;P&gt;SectionCurve16.csv&lt;/P&gt;&lt;P&gt;SectionCurve17.csv&lt;/P&gt;&lt;P&gt;SectionCurve18.csv&lt;/P&gt;&lt;P&gt;SectionCurve19.csv&lt;/P&gt;&lt;P&gt;SectionCurve2.csv&lt;/P&gt;&lt;P&gt;SectionCurve3.csv&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I renamed the single digits, so the first files are now SectionCurve01.csv, SectionCurve02.csv, etc. Now, they're in correct alphabetical order.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the modified program. I've also attached the files for the renamed sections.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import adsk.core, adsk.fusion, traceback
import os
import csv

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        if app.activeProduct.productType != 'DesignProductType':
            ui.messageBox('A Design must be acitve.')
            return

        des: adsk.fusion.Design = app.activeProduct
        root = des.rootComponent

        # Prompt to have the folder containing the csv files selected.
        dlg = ui.createFolderDialog()
        dlg.title = 'Section Curves Folder'
        if dlg.showDialog() != adsk.core.DialogResults.DialogOK :
            return

        sectionFolder = dlg.folder

        # Create a new sketch for the sections.
        sk = root.sketches.add(root.xYConstructionPlane)
        sk.name = 'Section Curves'

        # Get all of the csv files.
        files = [f for f in os.listdir(sectionFolder) if f.endswith('.csv')]
        files.sort()

        sections = []
        for file in files:
            fullFilename = os.path.join(sectionFolder, file)

            points = adsk.core.ObjectCollection.create()
            with open(fullFilename, 'r', encoding = 'utf-8-sig') as file:
                reader = csv.reader(file)
                for row in reader:
                    points.add(adsk.core.Point3D.create(float(row[0]), float(row[1]), float(row[2])))

            if points.count &amp;gt; 1:
                curve = None
                curve = sk.sketchCurves.sketchFittedSplines.add(points)
                sections.append(curve)
            else:
                point = sk.sketchPoints.add(points[0])
                sections.append(point)

        loftInput = root.features.loftFeatures.createInput(adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        for section in sections:
            if section.objectType == adsk.fusion.SketchPoint.classType():
                loftSection = loftInput.loftSections.add(section)
                loftSection.setPointTangentEndCondition(adsk.core.ValueInput.createByReal(1))
            else:
                loftInput.loftSections.add(section)

        loft = root.features.loftFeatures.add(loftInput)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 03 May 2024 22:27:55 GMT</pubDate>
    <dc:creator>BrianEkins</dc:creator>
    <dc:date>2024-05-03T22:27:55Z</dc:date>
    <item>
      <title>Batch import multiple splines of csv files. And adding a loft between those splines.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/batch-import-multiple-splines-of-csv-files-and-adding-a-loft/m-p/12748849#M1472</link>
      <description>&lt;P&gt;&lt;SPAN&gt;It's my first time using the Fusion API.&amp;nbsp;I am using Windows 10 and Python. I want to import multiple splines into the Fusion (which currently works nicely with the "ImportSplineCSV" sample script), but I find it tedious to do for every csv.file. I was wondering if there was a way to select multiple csv files and create a spline for each seperate one.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In this thread i found a solution, i think, but couldnt get the batch import to work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/fusion-api-and-scripts/trouble-with-batch-import-and-loft-of-csv-files/m-p/9990354#M12318" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/fusion-api-and-scripts/trouble-with-batch-import-and-loft-of-csv-files/m-p/9990354#M12318&lt;/A&gt;&amp;nbsp;&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;#Author-Autodesk Inc.

#Description-Import spline from csv file

import adsk.core, adsk.fusion, tracebac
import io

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        # Get all components in the active design.
        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)
        rootComp = design.rootComponent
        title = 'Import Spline csv'
        if not design:
            ui.messageBox('No active Fusion design', title)
            return
       
        dlg = ui.createFileDialog()
        dlg.title = 'Open CSV File'
        dlg.filter = 'Comma Separated Values (*.csv);;All Files (*.*)'
        if dlg.showOpen() != adsk.core.DialogResults.DialogOK :
            return
       
        filename = dlg.filename

        sketches = []
        for i in range(1,202‌‌#Loop for csv import
            filename = 'C:/*privacy*/layer{}.csv'.format(i)

            with io.open(filename, 'r', encoding='utf-8-sig') as f:
                points = adsk.core.ObjectCollection.create()
                line = f.readline()
                data = []
                while line:
                    pntStrArr = line.split(',')
                    for pntStr in pntStrArr:
                        try:
                            data.append(float(pntStr))
                        except:
                            break
               
                    if len(data) &amp;gt;= 3 :
                        point = adsk.core.Point3D.create(data[0], data[1], data[2])
                        points.add(point)
                    line = f.readline()
                    data.clear()            
            if points.count:
                sketch = design.rootComponent.sketches.add(design.rootComponent.xYConstructionPlane)
                sketch.sketchCurves.sketchFittedSplines.add(points)
                sketches.append(sketch)
            else:
                ui.messageBox('No valid points', title)            
       
        loftFeats = rootComp.features.loftFeatures
        loftInput = loftFeats.createInput(adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        loftSectionsObj = loftInput.loftSections

        for sketch in skethes:
            profile = sketch.profiles.item(0)
            loftSectionsObj.add(profile)
       
        loftFeats = rootComp.features.loftFeatures
        loftInput = loftFeats.createInput(adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        loftSectionsObj = loftInput.loftSections

        for j in range(0,100‌‌#Loop for selecting the scetch profiles for the loft
           
         profile = design.rootComponent.sketches.add(rootComp.xYConstructionPlane).profiles.item(j)
         loftSectionsObj.add(profile)
         
     

        loftInput.isSolid = False

        # Create loft feature
        loftFeats.add(loftInput)



#design.rootComponent.sketches.add(rootComp.xZConstructionPlane).profiles.item(0)
    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;&lt;SPAN&gt;After importing the splines, I want to create a loft between the splineprofiles, i wonder if that can be done in the same script. I am working on a propeller and im generating the sectioncurves using openprop v3.3.4. in matlab:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tomas_kramer_0-1714666883056.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1357577i5F985BD7C78EE173/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tomas_kramer_0-1714666883056.png" alt="tomas_kramer_0-1714666883056.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;After using the import spline script 20 times i get one blade of the propeller:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tomas_kramer_1-1714667264098.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1357580i578933C76344D491/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tomas_kramer_1-1714667264098.png" alt="tomas_kramer_1-1714667264098.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Since its always the same process for each propeller, i wonder if its possible to automate the whole process to create a propeller. With&lt;/SPAN&gt;&amp;nbsp;the solid loft function iIwant to create a blade. Than i import the hub component and combine the components together. After using a fillet i get a nice transistion between the blades and the hub. With the c-pattern i want to copy the blade with the fillet to the other side.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tomas_kramer_2-1714667558311.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1357581i4DFE9C929D920A1C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tomas_kramer_2-1714667558311.png" alt="tomas_kramer_2-1714667558311.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance and have a nice day,&lt;/P&gt;&lt;P&gt;Tomas&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2024 17:22:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/batch-import-multiple-splines-of-csv-files-and-adding-a-loft/m-p/12748849#M1472</guid>
      <dc:creator>tomas_kramer</dc:creator>
      <dc:date>2024-05-02T17:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: Batch import multiple splines of csv files. And adding a loft between those splines.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/batch-import-multiple-splines-of-csv-files-and-adding-a-loft/m-p/12749765#M1473</link>
      <description>&lt;P&gt;What you're wanting to do is certainly possible. Here's a script I just wrote that creates a spline for each CSV file in a specified folder and then creates a loft through the splines. I've attached the CSV files I used for testing. You should be able to find other posts and examples to add the additional code to insert the hub, mirror the blade, and combine them into a single body. Hopefully, this provides a good start.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        if app.activeProduct.productType != 'DesignProductType':
            ui.messageBox('A Design must be acitve.')
            return

        des: adsk.fusion.Design = app.activeProduct
        root = des.rootComponent

        # Prompt to have the folder containing the csv files selected.
        dlg = ui.createFolderDialog()
        dlg.title = 'Section Curves Folder'
        if dlg.showDialog() != adsk.core.DialogResults.DialogOK :
            return

        sectionFolder = dlg.folder

        # Create a new sketch for the sections.
        sk = root.sketches.add(root.xYConstructionPlane)
        sk.name = 'Section Curves'

        # Get all of the csv files.
        files = [f for f in os.listdir(sectionFolder) if f.endswith('.csv')]
        files.sort()

        sections = []
        for file in files:
            fullFilename = os.path.join(sectionFolder, file)

            points = adsk.core.ObjectCollection.create()
            firstLine = True
            with open(fullFilename, 'r') as file:
                reader = csv.reader(file)
                for row in reader:
                    if firstLine:
                        # Strip off the byte characters at the beginning of the file.
                        row[0] = row[0][3:]
                        firstLine = False
                    points.add(adsk.core.Point3D.create(float(row[0]), float(row[1]), float(row[2])))

            if points.count &amp;gt; 1:
                curve = sk.sketchCurves.sketchFittedSplines.add(points)
                sections.append(curve)
            else:
                point = sk.sketchPoints.add(points[0])
                sections.append(point)

        loftInput = root.features.loftFeatures.createInput(adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        for section in sections:
            if section.objectType == adsk.fusion.SketchPoint.classType():
                loftSection = loftInput.loftSections.add(section)
                loftSection.setPointTangentEndCondition(adsk.core.ValueInput.createByReal(1))
            else:
                loftInput.loftSections.add(section)

        loft = root.features.loftFeatures.add(loftInput)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2024 02:34:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/batch-import-multiple-splines-of-csv-files-and-adding-a-loft/m-p/12749765#M1473</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2024-05-03T02:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Batch import multiple splines of csv files. And adding a loft between those splines.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/batch-import-multiple-splines-of-csv-files-and-adding-a-loft/m-p/12750488#M1474</link>
      <description>&lt;P&gt;Files:&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2024 11:14:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/batch-import-multiple-splines-of-csv-files-and-adding-a-loft/m-p/12750488#M1474</guid>
      <dc:creator>tomas_kramer</dc:creator>
      <dc:date>2024-05-03T11:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: Batch import multiple splines of csv files. And adding a loft between those splines.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/batch-import-multiple-splines-of-csv-files-and-adding-a-loft/m-p/12750494#M1475</link>
      <description>&lt;P&gt;Thank you so much for your help!&lt;/P&gt;&lt;P&gt;Ive tried the code and I thought it was allready amazing, but than I found out it failed to make a spline:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tomas_kramer_0-1714734038212.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1357898i463FBA4CACD625BF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tomas_kramer_0-1714734038212.png" alt="tomas_kramer_0-1714734038212.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tomas_kramer_1-1714734055489.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1357899iAAB792087FD9C6F2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tomas_kramer_1-1714734055489.png" alt="tomas_kramer_1-1714734055489.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I've tried to understand how it works, but the code seems fine, so i dont know what the problem is. I've provided my csv files too which i used for testing, maybe it helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;#Author-
#Description-

import adsk.core, adsk.fusion, adsk.cam, traceback, os, csv

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        if app.activeProduct.productType != 'DesignProductType':
            ui.messageBox('A Design must be acitve.')
            return

        des: adsk.fusion.Design = app.activeProduct
        root = des.rootComponent

        # Prompt to have the folder containing the csv files selected.
        dlg = ui.createFolderDialog()
        dlg.title = 'Section Curves Folder'
        if dlg.showDialog() != adsk.core.DialogResults.DialogOK :
            return

        sectionFolder = dlg.folder

        # Create a new sketch for the sections.
        sk = root.sketches.add(root.xYConstructionPlane)
        sk.name = 'Section Curves'

        # Get all of the csv files.
        files = [f for f in os.listdir(sectionFolder) if f.endswith('.csv')]
        files.sort()

        sections = []
        for file in files:
            fullFilename = os.path.join(sectionFolder, file)

            points = adsk.core.ObjectCollection.create()
            firstLine = True
            with open(fullFilename, 'r') as file:
                reader = csv.reader(file)
                for row in reader:
                    if firstLine:
                        # Strip off the byte characters at the beginning of the file.
                        row[0] = row[0][3:]
                        firstLine = False
                    points.add(adsk.core.Point3D.create(float(row[0]), float(row[1]), float(row[2])))
#create spline part:
            if points.count &amp;gt; 1:#check if there 2 points to create a spline
                curve = sk.sketchCurves.sketchFittedSplines.add(points)
                sections.append(curve)
            else:# If there's only one point, add it as a sketch point
                point = sk.sketchPoints.add(points[0])
                sections.append(point)

        loftInput = root.features.loftFeatures.createInput(adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        for section in sections:
            if section.objectType == adsk.fusion.SketchPoint.classType():
                loftSection = loftInput.loftSections.add(section)
                loftSection.setPointTangentEndCondition(adsk.core.ValueInput.createByReal(1))
            else:
                loftInput.loftSections.add(section)

        loft = root.features.loftFeatures.add(loftInput)
    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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5741855"&gt;@BrianEkins&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2024 11:14:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/batch-import-multiple-splines-of-csv-files-and-adding-a-loft/m-p/12750494#M1475</guid>
      <dc:creator>tomas_kramer</dc:creator>
      <dc:date>2024-05-03T11:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: Batch import multiple splines of csv files. And adding a loft between those splines.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/batch-import-multiple-splines-of-csv-files-and-adding-a-loft/m-p/12751849#M1476</link>
      <description>&lt;P&gt;Your files are encoded differently than mine, so it worked for me and not for you. My files, which I created using Excel, had extra characters at the beginning of the file to specify the encoding type used for the file. I was assuming all files had this same encoding, so I was always ignoring the first three characters. I changed the code, so instead of blindly assuming there are encoding characters at the beginning of the file, I now specify the encoding when opening the file and let Python take care of it.&lt;/P&gt;&lt;P&gt;After fixing that, the loft was failing with your data. The problem is that the files must be named alphabetically in the order they're processed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;They were being processed:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SectionCurve1.csv&lt;/P&gt;&lt;P&gt;SectionCurve10.csv&lt;/P&gt;&lt;P&gt;SectionCurve11.csv&lt;/P&gt;&lt;P&gt;SectionCurve12.csv&lt;/P&gt;&lt;P&gt;SectionCurve13.csv&lt;/P&gt;&lt;P&gt;SectionCurve14.csv&lt;/P&gt;&lt;P&gt;SectionCurve15.csv&lt;/P&gt;&lt;P&gt;SectionCurve16.csv&lt;/P&gt;&lt;P&gt;SectionCurve17.csv&lt;/P&gt;&lt;P&gt;SectionCurve18.csv&lt;/P&gt;&lt;P&gt;SectionCurve19.csv&lt;/P&gt;&lt;P&gt;SectionCurve2.csv&lt;/P&gt;&lt;P&gt;SectionCurve3.csv&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I renamed the single digits, so the first files are now SectionCurve01.csv, SectionCurve02.csv, etc. Now, they're in correct alphabetical order.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the modified program. I've also attached the files for the renamed sections.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import adsk.core, adsk.fusion, traceback
import os
import csv

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        if app.activeProduct.productType != 'DesignProductType':
            ui.messageBox('A Design must be acitve.')
            return

        des: adsk.fusion.Design = app.activeProduct
        root = des.rootComponent

        # Prompt to have the folder containing the csv files selected.
        dlg = ui.createFolderDialog()
        dlg.title = 'Section Curves Folder'
        if dlg.showDialog() != adsk.core.DialogResults.DialogOK :
            return

        sectionFolder = dlg.folder

        # Create a new sketch for the sections.
        sk = root.sketches.add(root.xYConstructionPlane)
        sk.name = 'Section Curves'

        # Get all of the csv files.
        files = [f for f in os.listdir(sectionFolder) if f.endswith('.csv')]
        files.sort()

        sections = []
        for file in files:
            fullFilename = os.path.join(sectionFolder, file)

            points = adsk.core.ObjectCollection.create()
            with open(fullFilename, 'r', encoding = 'utf-8-sig') as file:
                reader = csv.reader(file)
                for row in reader:
                    points.add(adsk.core.Point3D.create(float(row[0]), float(row[1]), float(row[2])))

            if points.count &amp;gt; 1:
                curve = None
                curve = sk.sketchCurves.sketchFittedSplines.add(points)
                sections.append(curve)
            else:
                point = sk.sketchPoints.add(points[0])
                sections.append(point)

        loftInput = root.features.loftFeatures.createInput(adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        for section in sections:
            if section.objectType == adsk.fusion.SketchPoint.classType():
                loftSection = loftInput.loftSections.add(section)
                loftSection.setPointTangentEndCondition(adsk.core.ValueInput.createByReal(1))
            else:
                loftInput.loftSections.add(section)

        loft = root.features.loftFeatures.add(loftInput)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 03 May 2024 22:27:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/batch-import-multiple-splines-of-csv-files-and-adding-a-loft/m-p/12751849#M1476</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2024-05-03T22:27:55Z</dc:date>
    </item>
  </channel>
</rss>

