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.
accessing one coordinate of a vector?
EvanReese
Member, Mentor Posts: 2,135 ✭✭✭✭✭
I'm trying to use a triad manipulator to set 3 different length parameters (XY and Z coordinates). Since the base and offset of the triad are both simple vectors I'm not sure how to send the x value to the X length parameter. Is there a way to get one of the values out of a vector? Am I asking the right question? Manipulators in general are new to me too, so any info helps.
Evan Reese
0
Best Answers
-
MBartlett21 Member, OS Professional, Developers Posts: 2,050 ✭✭✭✭✭@Evan_Reese
3d vectors in Onshape are just a simple array of three ValueWithUnits, meaning that you can get the x, y and z dimensions with vec[0], vec[1], and vec[2], respectively.0 -
jon_sorrells Onshape Employees Posts: 51You can access the vector as an array to get the x, y, and z components. Like myVector[0] to get the x component.The Transform feature uses a triad manipulator, you can take a look at the transformManipulatorChange method in transformCopy.fs in the standard library. I've copied the relevant portion here:const offset = input[TRANSLATION].offset;You can also use the dot product, like dot(myVector, (vector(1, 0, 0))), which would get the x component of myVector.
output.dx = offset[0];
output.dy = offset[1];
output.dz = offset[2];
2
Answers
3d vectors in Onshape are just a simple array of three ValueWithUnits, meaning that you can get the x, y and z dimensions with vec[0], vec[1], and vec[2], respectively.
IR for AS/NZS 1100
output.dx = offset[0];
output.dy = offset[1];
output.dz = offset[2];