How to create a sketch with many (over 100) points by reading coordinates from file and be able to update thier positions.

How to create a sketch with many (over 100) points by reading coordinates from file and be able to update thier positions.

olegkar
Participant Participant
1,135 Views
3 Replies
Message 1 of 4

How to create a sketch with many (over 100) points by reading coordinates from file and be able to update thier positions.

olegkar
Participant
Participant

Hello!

I have a model, which relies on a set of curves, which I calculate in a script in Matlab. 

When I build the model in Fusion I export it in CST Studio to run some simulations, then after analyzing it I apply some  changes to the curves and build the new model.

For now I was doing in such way:

I have made a sketch, consisting the points, constrained each point using dimensions, and linked each dimension to user parameters. Then I have updated user parameters using the ParameterI/O AddIn.

It is a dumb way, required some time and efforts to constrain each point, but it worked very well for me. 

Until the latest update... which killed lots of plugings and addins...

 

So the questions are:

is there a more efficient way then just manually click each point and apply dimension constrains? 

Is there a way to maybe generate script from the sketch I have done manually to then do the same sketch using script?

The points coordinates has to be updated, not draw new ones, so the scripts like ImportSplineCSV won't do. 

 

PS. Is there a chance that ParameterI/O will work again? Who is supporting it? 

 

Cheers,

Oleg

 

0 Likes
Accepted solutions (1)
1,136 Views
3 Replies
Replies (3)
Message 2 of 4

BrianEkins
Mentor
Mentor
Accepted solution

It's certainly possible to directly edit the location of a sketch point or a construction point. Possibly either one can work in your case.  I've attached a little program that reads in a text file that defines a number of points and creates points in a sketch. You can later read in an updated text file and update the position of the points.  The attached zip file contains two sample text files.  I used one to create the original points and the second to test updating them.  There's not too much code and I did almost no error handling so if things aren't correct, errors will happen but hopefully it works good enough for what you need.

 

I added quite a few comments to the code describing what it does but each row in the input file has four comma delimited values. The first is an ID for the point, the other three are the X, Y, and Z components of the coordinate.  When creating points, if a sketch is active, it will add the new points to that sketch, otherwise it will create a new sketch. It uses attributes to add the ID to each point.  When you update the points, it reads the ID from the file and finds the existing point with that ID and updates it's position using the new coordinate.

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

olegkar
Participant
Participant

Thank you very much, Brian!

The script is very useful for me. And thank you for help in my other topic about Parameter I/O

Because of that issue with Parameter I/O I have learned a lot about python scripts and Fusion API and enjoyed very much!

 

There is still one problem. I need the sketch to be fully constrained. Because it has to be "miss-click-proof".
Is it possible to Fix/Unfix points in the script?
 
0 Likes
Message 4 of 4

BrianEkins
Mentor
Mentor

Just add the last line shown below to the CreatePoints function.

skPnt = sk.sketchPoints.add(coord)
skPnt.attributes.add('editPointSample', name, '')
skPnt.isFixed = True

 

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