Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Creating Sketch From CSV file

1 REPLY 1
Reply
Message 1 of 2
dmcrites
116 Views, 1 Reply

Creating Sketch From CSV file

I'm new to fusion scripting, but essentially what I want to do is have a script that will ask the user for a 3 csv files that contain a hole size, and a x,y coordinate, and have fusion automatically create circles with the hole size as its diameter. The code I'm trying to do is this, but I don't know how to prompt to find the desired csv file I want to use. I don't want the csv file to be hardcoded like below. 

 

 try:
            with open('C:\\workspace\\Test\\topData.csv', 'r') as f:
                  content = csv.reader(f)
                  next(content, None)
                  for line in content:
                   x=float('Center-X(mil)') * 2.54
                   y=float('Center-Y(mil)') * 2.54
                   r=(float('Hole'/2) * 2.54
                   r_clearance=(float(7/64)/2) * 2.54
                   # Draw some circles.
                   circle1 = circles.addByCenterRadius(adsk.core.Point3D.create(x, y, 0), r)
                   circle2 = circles2.addByCenterRadius(adsk.core.Point3D.create(x, y, 0), r_clearance)
        except OSError as err:
            print("OS error:", err)
            sketch.deleteMe()
            sketch2.deleteMe()

 

1 REPLY 1
Message 2 of 2
Jorge_Jaramillo
in reply to: dmcrites

Hi,

This is a sample of the UserInterface.createFileDialog() method which can be used to prompt the user to choose a file:

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-d5163350-6d2f-11e7-8c44-3417ebc87622

 

Regards,

Jorge Jaramillo

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report