<p>Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.</p></p><strong>First time visiting? Here are some places to start:</strong></p><ol style="list-style:inherit;margin-left:25px;"><li>Looking for a certain topic? Check out the <a href="https://forum.onshape.com/categories">categories filter</a> or use Search (upper right).</li><li>Need support? <a href="https://forum.onshape.com/post/question/community-support">Ask a question</a> to our <a href="https://forum.onshape.com/categories/community-support">Community Support</a> category.</li><li>Please submit support tickets for bugs but you can request improvements in the <a href="https://forum.onshape.com/categories/product-feedback">Product Feedback category</a>.</li><li>Be respectful, on topic and if you see a problem, Flag it.</li></ol><p>If you would like to contact our Community Manager personally, feel free to <a href="https://forum.onshape.com/profile/6/LouGallo">send a private message</a> or <a href="mailto:lgallo@onshape.com">an email</a>.
</p>

Is there a way to transform a 3D point (map) into a 3D vector ?

Antoine_Bodin
Antoine_Bodin Member Posts: 6 PRO
Hello there,

I am looking for a way to transform a 3D point (map) into a vector in a feature script. How can I do it ? 
Tagged:

Answers

  • Jake_Rosenfeld
    Jake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646 image
    edited April 2018
    Hi @Antoine_Bodin

    You can make Vectors in featurescript with the `vector(x, y, z)` function.  Here is some documentation:
    https://cad.onshape.com/FsDoc/library.html#module-vector.fs

    Some examples:
    const pointInSpace = vector(1, 2, 3) * inch; // point at (1 inch, 2 inch, 3 inch)
    
    const xLoc = 5 * meter;
    const anotherPointInSpace = vector(xLoc, 4 * inch, 3 * centimeter); // point at (5 meter, 4 inch, 3 centimenter)
    
    // show these vectors as red dots while you're in the part studio with your custom feature dialog open
    debug(context, pointInSpace);
    debug(context, anotherPointInSpace);


    If you post the URL of your document, or screenshots of the specific issue you are facing, we can get more specific with our help.
    Jake Rosenfeld - Modeling Team
  • konstantin_shiriazdanov
    konstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    i think you have a query (which is internally a map) of a vertex and want to get it coordinates? evVertexPoint() function does it
  • Antoine_Bodin
    Antoine_Bodin Member Posts: 6 PRO
    edited April 2018
    In fact, I am drawing a point in a sketch and I need to define a vector that represents this point to use it in the function qContainsPoint(). I tried to use evVertexPoint() but I got the following error: evVertexPoint: CANNOT_RESOLVE_ENTITIES. 

  • konstantin_shiriazdanov
    konstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    the first approach: planeToWorld(plane2, vector(0,0.6)*millimeter) will return corresponding vector in 3d.
    the approach with evVertexPoint() requares the query of a point, so if the sketch contains the only point you can directly use qCreatedBy("sketch_feature_id", EntityType.VERTEX). or if you need sketch entity with specific id use sketchEntityQuery()
  • mthiesmeyer
    mthiesmeyer Onshape Employees Posts: 115 image
    Hi Antoine,

    Here is a document with an example Feature Script that implements the three methods @konstantin_shiriazdanov outlined.

    Best,

    Mike