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.

How to pass parameter to skRegularPolygon "centre"?

owen_sparksowen_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.


Business Systems and Configuration Controller
HWM-Water Ltd

Best Answers

Answers

  • john_f_carrjohn_f_carr Onshape Employees Posts: 74
    is2dPoint checks for a point in two dimensions but you passed a point in 3 dimensions.  You may need to project onto the sketch plane.
  • owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    Thanks guys, that worked perfectly.

    Much obliged.

    Owen S.
    Business Systems and Configuration Controller
    HWM-Water Ltd
Sign In or Register to comment.