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.

problems with "x-axis" key in Plane object

adamohernadamohern Member, OS Professional Posts: 216 PRO
I'm trying to retrieve the X axis vector for a Plane.

var sketchPlane = plane(origin, normal, xDirection);
println(sketchPlane);
// result:
// normal(0, 0.7071067811865476, -0.7071067811865476)
// origin(-0.3048 meter, -0.6096 meter, 1.2192 meter)
// x-axis(1, 0, 0)

Huzzah! Except that I can't access the "x-axis" key in the map.

println(sketchPlane.x-axis);
// result:
// Variable axis not found.
// Using "-" in a map key is probably a bad idea for this reason. println(sketchPlane["x-axis"]); // result: // undefined // What the wha? It's clearly defined, as you can see in the original println() above.

What am I missing?

Comments

  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 928
    The field is just called "x".  "x-axis" is just how it's getting pretty-printed (println uses the toString function which is overloaded to pretty-print Planes).  I can see how that's confusing and will change the plane pretty printing to say "x".  You can always get the "raw" form by doing:
    println("" ~ sketchPlane);
    Ilya Baran \ Director, Architecture and FeatureScript \ Onshape Inc
  • adamohernadamohern Member, OS Professional Posts: 216 PRO
    Ah, thanks Ilya. Why would you ever want to pretty-print a map definition, I wonder? In what use-case would a user print a map definition but not care what the key strings are?
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 928
    An example is meter: that is actually a map with keys "value" and "units", but a user would likely just want to see "meter" printed.
    Ilya Baran \ Director, Architecture and FeatureScript \ Onshape Inc
Sign In or Register to comment.