Add sketch on existing planar face

Add sketch on existing planar face

Anonymous
Not applicable
1,952 Views
2 Replies
Message 1 of 3

Add sketch on existing planar face

Anonymous
Not applicable

My goal is to create sketch on existing planar face. I have exact coordinates of points that should be placed on face. I'm creating sketch in the following way (here face is chosen arbitrary)

 

 

Ptr<BRepFace> face = bRepFaces->item(0);
fusionSketch = fusionSketches->add(face);

The thing is when I'm adding points to this sketch their coordinates could be with the opposite sign. It depends on surface I'm choosing. For example, on top face of the object. 

 

 

pnt.jpg

 

I suppose this issue occurs because I'm using existing face rather than construction plane (for sketch on construction plane everything works fine, coordinates don't change their signs). Looks like sketch on existing face should be added in some other way, but cannot find any other. Any idea how this could be done? Appreciate any help. Thanks.

 

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

BrianEkins
Mentor
Mentor
Accepted solution

I had intended to write a section for the Fusion 360 help describing how sketches work in Fusion but now I guess I'll need to write a blog post at some point.  Here are some basics though that should get you through your issue.

 

A sketch is a 3D object, although typically geometry is only drawn on its X-Y plane.  A sketch defines its own 3D coordinate system in space.  One way to visualize a sketch is like a user-defined coordinate system positioned somewhere within model space.  The Fusion 360 UI doesn't indicate this in any way and it can be difficult to understand what the sketch coordinate system is.  When using the UI, you typically don't care because you just draw the geometry so that it looks correct and position it relative to other geometry using constraints.  When using the API though you can use precise coordinates, but without know where those coordinates are it's not very useful.

 

When you create a new sketch on a face, or construction plane, the X-Y plane of the sketch will lie on the face or construction plane.  The positive Z direction uses the normal of the face or construction plane.  The orientation of the sketch is determined using an internal algorithm in Fusion 360, so may appear to be somewhat arbitrary.

 

To do what you want to do, you can create the sketch, and then get a point in the 3D sketch space that is equivalent to a 3D model space point.  You use the Sketch.modelToSketchSpace method where you pass in the model space point and it returns the equivalent point in sketch space.  There is also the sketchToModelSpace method to do the reverse.

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

kdrector
Contributor
Contributor

@Anonymous,

I found this very useful information. I couldn't find anything so helpful in the reference or user manual, but even so, I'm still having a problem.

 

I calculated an array of objectPoints using real values from other entities, which I believe will result in points in world or Model space. Then I map these to a sketch on a construction plane off in space somewhere;

 

pointsetPoints = constructionSketch.modelToSketchSpace(objectPoints[i]])

 

Inspecting the coordinates for objectPoints[14] for example, they are (6.636,-0.116,0.0).

 

The resulting pointsetPoints[14] is (-3.762,.0.116,0.193) which may be close to right for sketch space.


However, when I create a spline using;

 

constructionsketch.sketchCurves.sketchFittedSplines.add(pointset_points[i])

 

the resulting spline curve points have the correct x,y values but their z coordinate is always zero causing the curve to lie on the z=0 plane in model space, whereas it should have increasing positive values so it will lie on the z == 0 plane in constructionSketch.

 

Whats up with the z values?

 

The model space origin (0.0.0) translates to the constructionSketch coordinates (3.0367,0.0,1.111).  Using these values the conversion of objectPoints[14] doesnt balance.  6.6367-3.762  != 3.0367.  How come?

 

Ken

 

 

 

0 Likes