Is there a way to plot a list of points to a sketch without looping?

Is there a way to plot a list of points to a sketch without looping?

ebunn3
Advocate Advocate
1,069 Views
7 Replies
Message 1 of 8

Is there a way to plot a list of points to a sketch without looping?

ebunn3
Advocate
Advocate

I am creating a gridwork of points that I want to add to a sketch and can only determine how to do it one at a time.  Is there a way to plot the entire list of points in one shot?  Something more efficient then the following:

# Create sketch point
        for i in points:
            point = adsk.core.Point3D.create(i[0],i[1],i[2])
            sketchPoint = sketchPoints.add(point)

 

Thanks in advance,

 

Eric

0 Likes
Accepted solutions (1)
1,070 Views
7 Replies
Replies (7)
Message 2 of 8

BrianEkins
Mentor
Mentor
Accepted solution

The only way to create a sketch point, or any sketch geometry, is to use the add methods which only support creating one entity at a time.  I'm not sure how much it will impact the creation of points, but you'll want to try using the isComputeDeferred property of the Sketch.

 

One other possible solution is to create a DXF file that contains the points.  It should be fairly simple to reverse engineer the format for just points.  And then read the DXF file in to create them all at once.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 8

ebunn3
Advocate
Advocate

IsComputeDeferred definitely speeds things up.  Thanks

 

Eric

0 Likes
Message 4 of 8

hanskellner
Autodesk
Autodesk

Hi@ebunn3 -

 

On a side note, my add-in ImportCSVPoints uses IsComputeDeferred to help speed up point creation.  You may also find the add-in useful for your purposes.

 

You can find it here: https://github.com/hanskellner/Fusion360ImportCSVPoints

 

Cheers



Hans Kellner
Senior Manager, Principal Engineer
Message 5 of 8

ebunn3
Advocate
Advocate

Thanks.  I'll check it out.

 

Eric

0 Likes
Message 6 of 8

ebunn3
Advocate
Advocate

Brian

 

Could you outline the

process for creating the points as a dxf file?   I don’t have physical points.  They are point objects in a list.  

Eric

0 Likes
Message 7 of 8

BrianEkins
Mentor
Mentor

I'm certainly not an expert at DXF but my idea was to use AutoCAD to create a file that contains a few points at known coordinates and then read that into a sketch in Fusion to make sure you get what you expect.

 

The next step is to look at the contents of the DXF and find where the points are defined.  You can manually edit the DXF and try adding a new point and then read that into Fusion to see if it still works.

 

If you've gotten that far you can now write a program that will add all of the point data you want as new points definitions in the DXF file.

 

It's all just an idea and not something I've tried myself, so good luck. 😀

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 8 of 8

hanskellner
Autodesk
Autodesk

There are libraries that you may use to create DXF files.  For example:

 

https://pypi.org/project/ezdxf/

 

You could read your point data then use the above library to create a DXF and populate it with points that match your point data.



Hans Kellner
Senior Manager, Principal Engineer