Draw large Number of circles

Draw large Number of circles

Anonymous
Not applicable
1,423 Views
2 Replies
Message 1 of 3

Draw large Number of circles

Anonymous
Not applicable

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()))
0 Likes
Accepted solutions (1)
1,424 Views
2 Replies
Replies (2)
Message 2 of 3

BrianEkins
Mentor
Mentor
Accepted solution

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
0 Likes
Message 3 of 3

Anonymous
Not applicable

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

0 Likes