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.
vertex coordinates
joel_guerrero
Member, Developers Posts: 14 EDU
Hi,
I have a featureScript where I select a point. Now, I want to print the coordinates of this point. How can I do this?
I already have the query, but I don't know how to access the selected point
Thanks for your help.
0
Best Answers
-
Alex_Kempen Member Posts: 247 EDUThe following code:
const vertex = evVertexPoint(context, { "vertex" : definition.myQuery }); println(vertex);
Will print the coordinates to the console (accessible via the {✓} icon in the top right corner of a part studio).
CS Student at UT DallasAlex.Kempen@utdallas.eduCheck out my FeatureScripts here:1 -
Alex_Kempen Member Posts: 247 EDUYeah, pretty much. I freehand the code, so watch out for spelling mistakes and the like, but it seems like you’re pointed in the right direction. Feel free to compare my code with the documentation to see how they match up as well.CS Student at UT DallasAlex.Kempen@utdallas.eduCheck out my FeatureScripts here:1
Answers
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! cadsharp.com/featurescripts 💎
Will print the coordinates to the console (accessible via the {✓} icon in the top right corner of a part studio).
You can also find more code examples in my FeatureScript Examples document here:
https://cad.onshape.com/documents/eebb66e5a6139b9b86708957/w/093d288d7231f660efc44c25/e/5e7b65a8f889c7077b49a9ed
Let me know if you need any additional help!
opTransform(context, id + "toPoint", {
"bodies" : qCreatedBy(id + "sketch1", EntityType.BODY),
"transform" : transform(vertex - WORLD_ORIGIN)
});
The transform I popped in is designed to bring entities from the world origin to your vertex. If that isn't what you want, there's a variety of ways to adapt it which depend on what you're trying to do.
Also, you can apply transforms one after another by simply multiplying the transforms together; for example, transform2 * transform1 is equal to running transform1 followed by transform2; for that reason, you should never really have to call opTransform on an object multiple times since you can simply multiply their transforms together into one big transform first.
Feel free to let me know if you get stuck and want to see some actual code of this, too.