Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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.
How to pass parameter to skRegularPolygon "centre"?
owen_sparks
Member, Developers Posts: 2,660 PRO
Hi guys.
Sorry to be asking trivial questions. I feel like a toddler again.
I'm trying to set the center point for a polygon on a recently created sketch as follows:-
It looks like the evVertexPoint returns a 3D vector where as the polygon is looking for a 2D vector.
var sketch1 = newSketchOnPlane(context, id, {
"sketchPlane" : evOwnerSketchPlane(context, {
"entity" : definition.targetpoint
})
});
var startPosition is Vector = evVertexPoint(context, {
"vertex" : definition.targetpoint
});
debug(context, startPosition);
skRegularPolygon(sketch1, "polygon1", {
//"center" : vector(0, 0) * millimeter,
Duff bit>> "center" : startPosition,
"firstVertex" : vector(0, FeatureWidth/2) * millimeter ,
"sides" : 6
});
error message is "Precondition of skRegularPolygon failed (is2dPoint(value.center))"
the debug yields sensible looking 3d coordinate values so I think we're good to that point.
With the incorrect "center" set back to a vector (0,0) * millimeter the code executes fine with the polygon placed about the origin.
Any help appreciated.
Cheers,
Owen S.
Sorry to be asking trivial questions. I feel like a toddler again.
I'm trying to set the center point for a polygon on a recently created sketch as follows:-
It looks like the evVertexPoint returns a 3D vector where as the polygon is looking for a 2D vector.
var sketch1 = newSketchOnPlane(context, id, {
"sketchPlane" : evOwnerSketchPlane(context, {
"entity" : definition.targetpoint
})
});
var startPosition is Vector = evVertexPoint(context, {
"vertex" : definition.targetpoint
});
debug(context, startPosition);
skRegularPolygon(sketch1, "polygon1", {
//"center" : vector(0, 0) * millimeter,
Duff bit>> "center" : startPosition,
"firstVertex" : vector(0, FeatureWidth/2) * millimeter ,
"sides" : 6
});
error message is "Precondition of skRegularPolygon failed (is2dPoint(value.center))"
the debug yields sensible looking 3d coordinate values so I think we're good to that point.
With the incorrect "center" set back to a vector (0,0) * millimeter the code executes fine with the polygon placed about the origin.
Any help appreciated.
Cheers,
Owen S.
Business Systems and Configuration Controller
HWM-Water Ltd
HWM-Water Ltd
0
Best Answers
-
ilya_baran Onshape Employees, Developers, HDM Posts: 1,215To expand a little, in your example, store the result of evOwnerSketchPlane into a variable (say, "sketchPlane") and then to skRegularPolygon you can pass worldToPlane(sketchPlane, startPosition)Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc5
-
kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565Specifically, use worldToPlane(Plane, Vector), which returns a 2D vector in plane space.
Project will move the point onto the plane but still returns a 3D vector in world space.5
Answers
Project will move the point onto the plane but still returns a 3D vector in world space.
Much obliged.
Owen S.
HWM-Water Ltd