Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Sketch on selected face - weird offset / orientation

Anonymous

Sketch on selected face - weird offset / orientation

Anonymous
Not applicable

Hey,

 

I thought its an easy task to do but...yeah.

I need a sketch to extrude some profiles out of an user selected face - but if I check if the profile is on that face with

isOnFace = faceEvaluator.isParameterOnFace(sketchPoint2D)

I always have some weird offsets and orientation problems like this (the center point of every circle should be within the face):

problem.PNG

What I do so far:

#select a face
selectedFace = ui.selectEntity("select Face", "Faces").entity

#prepare matrix
 rangeX = range(1-arraySize, arraySize, 2)
 rangeY = range(1-arraySize, arraySize, 2)

# go thru
 for nowX in rangeX:
            for nowY in rangeY:
                sketchPoint2D = adsk.core.Point2D.create(nowX, nowY)               
                sketch.sketchCurves.sketchCircles.addByCenterRadius(sketchPoint, 0.4)
                isOnFace = faceEvaluator.isParameterOnFace(sketchPoint2D)
                if isOnFace:
                     #extrude Circle

In some cases the hittest is mirrored or not matching the selected face and sometimes its all fine.

Can someone give me a hint what I'm doing wrong here?

 

Thanks in advance!

 

0 Likes
Reply
Accepted solutions (1)
446 Views
2 Replies
Replies (2)

BrianEkins
Mentor
Mentor
Accepted solution

You're working in two different spaces; sketch space and the parameter space of the face.  I'm not following what you're trying to do but if you have a coordinate in sketch space, (which is a 3D space), and want to get the equivalent in the parametric space of a surface you'll need to first get the position of the sketch point in model space.  You can use the Sketch.sketchToModelSpace function to do that.  Now you need to go from model space (which is also 3D) to the parameter space (which is 2D) of the surface.  To do this you'll need to use the SurfaceEvaluator.getParameterAtPoint function which will return a Point2D object that is the position of the coordinate in parameter space.  You can use that as input to the SurfaceEvaluator.isParameterOnFace.

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

Anonymous
Not applicable

Thanks alot!

0 Likes