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: 

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

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
ebunn3
472 Views, 7 Replies

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

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

7 REPLIES 7
Message 2 of 8
BrianEkins
in reply to: ebunn3

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
in reply to: BrianEkins

IsComputeDeferred definitely speeds things up.  Thanks

 

Eric

Message 4 of 8
hanskellner
in reply to: ebunn3

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
in reply to: hanskellner

Thanks.  I'll check it out.

 

Eric

Message 6 of 8
ebunn3
in reply to: BrianEkins

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

Message 7 of 8
BrianEkins
in reply to: ebunn3

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
in reply to: ebunn3

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

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