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.

Featurescript - Evaluate centre of circle

Hugh_GoodbodyHugh_Goodbody PROMember Posts: 16 PRO
I am embarking on my first custom feature creation! I have run into an issue someone might be able to shed some light on.
I have selected the edge of a circle and would like to get the centre point to place a hole on. I have the below code to evaluate the selected circle:

var circleCentre = evCurveDefinition(context, { "edge" : definition.startVertex });
        println(circleCentre);
        var myVar = circleCentre is map;
        println(myVar);
        println(circleCentre.radius);
        println(circleCentre.center);

The first two println ststements give the expected results:
println(myVar) = radius 0.024999999999999994 meter
                          center (-0.10832993533461188 meter, -0.025 meter, 0.08940204711347347 meter)

println(circleCentre.radius) = 0.024999999999999994 meter

However, the last statement returns undefined, but I was expecting the coordinates.

println(circleCentre.center) = undefined




Comments

  • MBartlett21MBartlett21 EDU Member Posts: 1,640 EDU
    you can use evCurveDefinition(context, { "edge" : definition.startVertex }).coordSystem to get the coordinate system of the circle. You can use evCurveDefinition(context, { "edge" : definition.startVertex }).coordSystem.origin to get the center of the circle
    MB - I make FeatureScripts: view FS (My FS's have "Official" beside them)
  • Hugh_GoodbodyHugh_Goodbody PRO Member Posts: 16 PRO
    Splendid, thanks for the advice. Will give it a go.
Sign In or Register to comment.