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.

println units

hervé_piponhervé_pipon Member Posts: 60 ✭✭
Hello

Here is a small piece of code:
    var sketchPlane = evOwnerSketchPlane(context, { "entity" : definition.selectedEdge });
    var n = 100;
    var samples = evEdgeTangentLines(context, { "edge" : definition.selectedEdge, "parameters" : range(0, 1, n) });
    var origin = worldToPlane(sketchPlane, samples[0].origin);
    println(origin * centimeter );

It prints :
    (0 meter^2, 0 meter^2)

I want to display centimeter : what is wrong ?

Comments

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,714
    Units in println are always meters, plus you are multiplying origin (which has length units) by another length to get an area.
    Senior Director, Technical Services, EMEAI
  • hervé_piponhervé_pipon Member Posts: 60 ✭✭
    NeilCooke said:
    Units in println are always meters.
    @NeilCooke Thanks I didn't know.
  • Jacob_CorderJacob_Corder Member Posts: 137 PRO
    change your println to this

    println(origin / centimeter );

  • EvanReeseEvanReese Member, Mentor Posts: 2,186 ✭✭✭✭✭
    If you wanna get fancy with it
    printLn("origin = " ~ roundToPrecision(origin/centimeter, 3)~ " cm";
    This will print "origin = 3.25 cm" or whatever. You round to not display 3.250000000001 or some floating point value.

    Usually this isn't needed, but if there are a ton of things printing it can be nice to label them with strong concatenation. 
    Evan Reese
Sign In or Register to comment.