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.
Need coordinate system (xAxis, zAxis) help for a transform
Marc_Miller
Member Posts: 110 ✭✭✭
I'm trying to learn some Featurescript but am having trouble getting the xAxis and zAxis vectors for a transform.
My Featurescript UI has the user select a start point (vertex), and a direction. From that I'm trying to move the orange strip (that was created by FS and is located at the origin) to the user selected point, and also orient it to the picked direction.
Here's my test file. I tried to get values for xAxis and zAxis on lines 42 and 43, but that doesn't seem to evaluate to anything (returns "undefined").
So I'm not sure how to get that, or what I need to put in Line 71 for xAxis and zAxis.
https://cad.onshape.com/documents/fa7433af79b5a1cd34725002/w/7fe2195f698aeb2a16d39728/e/fdcb389696130b3c594eba09
Thank you for having a look.
My Featurescript UI has the user select a start point (vertex), and a direction. From that I'm trying to move the orange strip (that was created by FS and is located at the origin) to the user selected point, and also orient it to the picked direction.
Here's my test file. I tried to get values for xAxis and zAxis on lines 42 and 43, but that doesn't seem to evaluate to anything (returns "undefined").
So I'm not sure how to get that, or what I need to put in Line 71 for xAxis and zAxis.
https://cad.onshape.com/documents/fa7433af79b5a1cd34725002/w/7fe2195f698aeb2a16d39728/e/fdcb389696130b3c594eba09
Thank you for having a look.
Tagged:
0
Best Answer
-
Jake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646@Marc_Miller
Your query filter is currently set to `QueryFilterCompound.ALLOWS_AXIS`. This allows the user to select anything that defines an axis (a line, a circle, a cylinder, etc). Notice that all these geometry types really only define a Z you are interested in, but not the X. Consequently, ALLOWS_AXIS is meant to be used with evAxis, which returns a Line. A line only has an origin and a direction.
https://cad.onshape.com/FsDoc/library.html#evAxis-Context-map
https://cad.onshape.com/FsDoc/library.html#Line
If you would like your user to fully specify a coordinate system, you should use `BodyType.MATE_CONNECTOR` as your query filter, which will ensure that the user is always creating a mate connector (as seen in your picture). Then, evaluate this mate connector with evMateConnector, which returns a coordSystem.
https://cad.onshape.com/FsDoc/library.html#evMateConnector-Context-map
https://cad.onshape.com/FsDoc/library.html#CoordSystem
Jake Rosenfeld - Modeling Team5
Answers
Should work.
Your query filter is currently set to `QueryFilterCompound.ALLOWS_AXIS`. This allows the user to select anything that defines an axis (a line, a circle, a cylinder, etc). Notice that all these geometry types really only define a Z you are interested in, but not the X. Consequently, ALLOWS_AXIS is meant to be used with evAxis, which returns a Line. A line only has an origin and a direction.
https://cad.onshape.com/FsDoc/library.html#evAxis-Context-map
https://cad.onshape.com/FsDoc/library.html#Line
If you would like your user to fully specify a coordinate system, you should use `BodyType.MATE_CONNECTOR` as your query filter, which will ensure that the user is always creating a mate connector (as seen in your picture). Then, evaluate this mate connector with evMateConnector, which returns a coordSystem.
https://cad.onshape.com/FsDoc/library.html#evMateConnector-Context-map
https://cad.onshape.com/FsDoc/library.html#CoordSystem
I got it to work after correcting those filter and eval lines, and adjusting my moveFrom coordinate vectors.
More to experiment with now!
Thank you @lana
I might come back and try that out if I decided I don't want to use a mate connector.
I experimented a bit more and decided that the simplest UI that is also really flexible about where to locate AND orient the object is simply a Mate connector option. With the ability to locate, rotate, flip direction, re-orientate, and offset all right there, Mate connectors are awesome!
I saved a version of the document here for anyone that may be searching the forums for this sort of example in the future.
https://cad.onshape.com/documents/fa7433af79b5a1cd34725002/v/6611496955cb9476a069e904/e/b9759b088e6afd81fa3c039a
It has two Featurescripts, the first with the Point and Mate connector option, and now a second one with just the MC option.
Cheers
-marc
HWM-Water Ltd