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: 

Sketch on a construction plane in API

4 REPLIES 4
Reply
Message 1 of 5
NasimM1
249 Views, 4 Replies

Sketch on a construction plane in API

Dear support team, 

 

I am trying to use the API to construct a plane to be able to sketch a spline on that plane using a csv file. I have managed to do that but the problem is that it seems that the position of the points is changing as the coordinates are relative to the construction plane not the absolute coordinate system. I would be thankful if you could help me regarding this. 

 

Kind regards,

Nasim

4 REPLIES 4
Message 2 of 5
tykapl.breuil
in reply to: NasimM1

The problem you are encoutnering is quite common and the reason is that the coordinate system of the sketch is not the same as the coordinate system of the model (think of how the origin and axes move when creating a sketch through the UI).

The easiest way to deal with this situation is to use the modelToSketchSpace and sketchToModelSpace methods of the sketch object.

For your use case, you would add the point returned by sketch.modelToSketchSpace(thePointYouWantToAdd) to the spline.

Message 3 of 5
NasimM1
in reply to: tykapl.breuil

Dear tykapl.breuil,
Thanks for your reply. I defined my points as:
point = adsk.core.Point3D.create(data[0], data[1], data[2])
points.add(point)


and later in the code after defining the plane I added:


points2=sketch.modelToSketchSpace(points)
sketch.sketchCurves.sketchFittedSplines.add(points2)


but when I run the code I faced the following error:


Autodesk/webdeploy/production/5f961055b6b4e87cb54d819910f25c62ea3df4be/Api/Python/packages\adsk\fusion.py", line 30918, in modelToSketchSpace
return _fusion.Sketch_modelToSketchSpace(self, modelCoordinate)
TypeError: in method 'Sketch_modelToSketchSpace', argument 2 of type 'adsk::core::Ptr< adsk::core::Point3D > const &'

 

I would be thankful if you could help me regarding this.

Thanks.
Nasim

Message 4 of 5
tykapl.breuil
in reply to: NasimM1

Hey there,

 

The methode modelToSketchSpace only works on single points ! (I see you're calling it on an object called points2 with an s)

Message 5 of 5
BrianEkins
in reply to: tykapl.breuil

Another option is to create the sketch on the base XY construction plane. The coordinate system of a sketch created on that construction plane is the same as the model coordinate system and you won't have to worry about the difference between the two and can skip the modelToSketchSpace calls.

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

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