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: 

Draw large Number of circles

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
fa.sea24
791 Views, 2 Replies

Draw large Number of circles

Hello, everyone.

 

I'm quite new to Fusion 360 environment, I'm trying to use the API to draw a large number of circles around 10.000, I have a file that contains the coordinates and the radius of each circle where the script reads the inputs for circle drawing, the problem is that I'm running out of memory then the software crash, so I'm looking for a better way to do it.

 

thank you 🙂

import adsk.core, adsk.fusion, traceback, csv
def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        
        doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
        
        design = app.activeProduct

        # Get the root component of the active design.
        rootComp = design.rootComponent

        # Create a new sketch on the xy plane.
        sketches = rootComp.sketches
        xyPlane = rootComp.xYConstructionPlane
        sketch = sketches.add(xyPlane)
        circles = sketch.sketchCurves.sketchCircles

        #Open the File 
        with open('C:\\the\pathl\SampleXYandR.csv', 'r') as f:
                  content = csv.reader(f) 
                  for line in content:
                   x=float(line[0])
                   y=float(line[1])
                   z=float(line[2])
                   r=float(line[3])
#                 Draw some circles.
                   circle1 = circles.addByCenterRadius(adsk.core.Point3D.create(y, z, 0), r)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
2 REPLIES 2
Message 2 of 3
BrianEkins
in reply to: fa.sea24

A sketch in Fusion 360 is doing a lot more than just drawing 2D geometry and because of that, it's not very good with large sketches.  For example, when you're sketching it's analyzing all of the geometry to calculate possible profiles in the sketch and if there are constraints, it's solving the sketch for those.  I would recommend breaking up your circles into groups and creating multiple sketches.  Each one is solved independently.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 3
fa.sea24
in reply to: BrianEkins

thank you for your reply ,I think dividing the circles to groups might the best choice 

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report