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.

Options

Vector or not vector ?

thierry_maletthierry_malet Member Posts: 52 ✭✭
edited December 2022 in FeatureScript
Hello, i would like to make an simple cuboid with coordinate of a selected point, 
i copy code from an "mesure value" FS existing code and i just reused a little part of it

but i don't know why "result" .value know as vector couldn't replace a vector(x,y,z) ?

https://cad.onshape.com/documents/fda00c1195e7580861511e84/w/3daf66389302de733d5dd7c7/e/b8d7fb7c4e612cd57d17307b

   
i try "corner1" : Vector (result)*millimeter,    but didn't work



but when i look result should be a vector 
 

Could you help me :neutral:

Comments

  • Options
    eric_pestyeric_pesty Member Posts: 1,596 PRO
    On my phone so can't dig into details but I think you should be able to use "result" directly for corner 1 as it already has length units. What you have there looks like it would be length^2...
  • Options
    eric_pestyeric_pesty Member Posts: 1,596 PRO
    Had a quick look from the office this morning:

    This gets rid of the error as expected since "result" already has length units.

    fCuboid(context, id + "cuboid1", {
                  "corner1" : result,//vector(result)* millimeter, 
                  "corner2" : vector(1, 1, 1) * definition.myLength
          });              
    As a side note, "corner2" has to be the "absolute" coordinates so what you currently have does weird stuff. I'm guessing what you were going for would be achieved with something like this:
                  "corner2" : result + vector(1, 1, 1) * definition.myLength

  • Options
    thierry_maletthierry_malet Member Posts: 52 ✭✭
    Thanks, it's simply !! :smiley: thought i had tried this combination, but sometime when "my.length" create an 0 mm edge for cuboid, feature failed,
  • Options
    Evan_ReeseEvan_Reese Member Posts: 2,070 PRO
    Not exactly what you asked, and may not apply here, but sometimes it's easier to just make an object on the origin, and use opPattern() or opTransform() in a loop to copy it all over the place, instead of trying to calculate the corner vectors for each fCuboid().
    Evan Reese / Principal and Industrial Designer with Ovyl
    Website: ovyl.io
  • Options
    NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,466
    opPattern all day long. 
    Senior Director, Technical Services, EMEAI
Sign In or Register to comment.