Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
2. Need support? Ask a question to our Community Support category.
3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Options

# plane creation questioning

Member Posts: 60 ✭✭
Hello

My question :how can I create a normal plane, with an origin point specified on its normal line, and with a pierce point on another specified point.....

Let see on a drawing :

I created the circle0 with the following code :
```var R = definition.Radius;
var Angle = definition.myAngle;
var x0 = definition.Xcoord;
var y0 = definition.Ycoord;
var z0 = definition.Zcoord;

const sphereCenter = vector(x0, y0, z0) ;
const sphereRadius =  R.value * meter ;
const ApexPoint =  vector(0 ,0 ,R.value ) * meter ;
const FirstRadius = vector( sphereCenter +  ApexPoint );

opFitSpline(context, id + "line_0" , { "points" : [ sphereCenter, ApexPoint ] });  // a vertical radius as reference
var sketch = newSketch(context, id + "sketch", {"sketchPlane" : qCreatedBy(makeId("Front"), EntityType.FACE) });
skPoint(sketch, "apex" , { "position" :  vector(x0, z0) + vector(0 ,R.value ) * meter });
skSolve(sketch);

var sketchId = id + ("sketch_0" ~ 0);
var sketch_0 = newSketchOnPlane(context, sketchId, {
"sketchPlane" : sketchPlane_0
});
skCircle(sketch_0, "circle0", {
"center" : vector(0, 0) * meter,
});
skPoint(sketch_0, "apex" , { "position" :  vector(0,0)  * meter });
skSolve(sketch_0);```

And circle_1 with this code :
```const endPointX = sphereCenter[0] + sphereRadius * sin(Angle) * cos(angleInDegrees);
const endPointY = sphereCenter[1] + sphereRadius * sin(Angle) * sin(angleInDegrees);
const endPointZ = sphereCenter[2] + sphereRadius * cos(Angle);
const endPoint = vector(endPointX, endPointY, endPointZ);

var newId = id + i + 1 + "line_" ;
opFitSpline(context, newId, { "points" : [ sphereCenter, endPoint ] });

var plane_temp = plane(ApexPoint,endPoint);

var sketchId = id + ("sketch" ~ i + 1);
var sketch_loop = newSketchOnPlane(context, sketchId, {
"sketchPlane" : plane_temp
});
var newCircleId =  "circle_" ~ (i + 1);
skCircle(sketch_loop, newCircleId, {
});

var newPointId =  "point_" ~ (i + 1);
skPoint(sketch_loop, newPointId , { "position" : vector(0, 0) * meter});```

My problem is that I want the circle_1 center to be on the line id+1+"line" (but not on endpoint) , and that the corresponding plane pass through apex, and taht the circle will pierce apex

I don't know if i t's very clear
Tagged:

• Options
Member Posts: 60 ✭✭
• Options
Moderator, Onshape Employees Posts: 5,517
There's probably a few ways you could do it, for example, you could create a plane normal to "line", measure the distance to apex, move the plane by that distance, then measure the distance from the plane center to apex, then draw the circle. Or you could do some clever vector math.
Senior Director, Technical Services, EMEAI
• Options
Member Posts: 60 ✭✭
@NeilCooke Thanks for your comment, but as by selecting the line and the point, with my mouse, I can create the normal plane that I want, there should have a function to do this. Despite my attempts, I still don't understand how vectors and points work.
I would like to find the right parameters for the function like :

```var Origin = endPoint;
var Normal = line_1
var Xdir   = ???
var plane_temp  = plane(Origin, Normal, Xdir);```

• Options
Moderator, Onshape Employees Posts: 5,517
As unlikely as it may sound, I didn't know you could make a plane like that!

See here from line 289:

The code is measuring the distance between the vertex and the line, which results in the "parameter" (0 to 1) where that minimum distance is measured along the line, then justs retrieves the tangent line and builds the plane from the vertex and normal. Simples.

Senior Director, Technical Services, EMEAI
• Options
Member Posts: 60 ✭✭
I can create my plane with

```var planeOrigin = ApexPoint;
var normalDirection = lineEnd - lineStart;
var planeDirection=vector(1, 1, 0);
const newPlane = plane (planeOrigin, normalDirection, planeDirection);```

I don't understand why

`planeDirection=vector(1, 1, 0)`

But it works
But how can I give a name to this plane ?
• Options
Member, Onshape Employees Posts: 331
edited November 2023
If you're asking about putting a visible label on the plane, the way we do for the default planes, that's not supported yet. We do have at least a couple of related improvement requests, e.g., https://forum.onshape.com/discussion/14608/derived-show-derived-sketch-plane-names-within-workspace

On planeDirection=vector(1, 1, 0), it turns out the plane(origin is Vector, normal is Vector, x is Vector) constructor normalizes the inputs, so all it needs is an origin and one or two dimensionless vectors.
• Options
Member Posts: 60 ✭✭
@_anton Concerning the plane direction , what I saw is that (1,1,0) is the only vector which works as I expected. For the other combinations, the plane is normal in one of the two directions, but not in both.
• Options
Moderator, Onshape Employees Posts: 5,517
Using a hardcoded planeDirection is not advisable - what it is doing is creating a coordinate system where all three axes are not orthogonal (it projects, so it works). Any other combination of line input will likely fail. The only reliable solution is that in std which I mentioned above.
Senior Director, Technical Services, EMEAI
• Options
Member Posts: 60 ✭✭
@NeilCooke Thank you for that clarification
Too bad, I wanted to avoid basing my Feature on measurements.