Sketch on a construction plane in API

Sketch on a construction plane in API

NasimM1
Explorer Explorer
784 Views
4 Replies
Message 1 of 5

Sketch on a construction plane in API

NasimM1
Explorer
Explorer

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

0 Likes
785 Views
4 Replies
Replies (4)
Message 2 of 5

tykapl.breuil
Advocate
Advocate

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
Explorer
Explorer

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

0 Likes
Message 4 of 5

tykapl.breuil
Advocate
Advocate

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
Mentor
Mentor

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