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

Feedback into UI panel

2»

Answers

  • Options
    Lee_HeskethLee_Hesketh Member, Developers Posts: 148 ✭✭
    @ilya_baran
    I changed it to changedDefinition.width = initialComputations(context, id, changedDefinition).part_wide / 3 and now there is a new error and the width is still 25mm.
    There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!
  • Options
    ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,175
    Ok, I see -- the problem is that you can only calculate the default once you've selected the face and the edge, while the editing logic function was only doing something when the dialog got initially opened (and fEdge was still undefined -- that's why it couldn't resolve the vertex).
    Changing lines 240-242 to:
    <div>export function setDefault(context is Context, id is Id, oldDefinition is map, changedDefinition is map, specified is map)</div><div>
    {</div><div>
    &nbsp; &nbsp; if (!specified.width && specified.fSide && specified.fEdge) // side and edge specified but not width</div><div></div>
    makes it work for me.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • Options
    Lee_HeskethLee_Hesketh Member, Developers Posts: 148 ✭✭
    Thanks, it works now! But I'm still getting the error about not resolving entities when calling evVertexPoint() Does the error come up on your end?
    Also, is oldDefinition still needed?
    There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!
  • Options
    ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,175
    Yes, the error comes up for me if the selections for fSide and fEdge are there but not valid or deleted (at that point they're considered to have been "specified" so initialComputations gets called, even though the inputs are not valid.  That error is safe to ignore.  If you want it to go away, you can wrap the evVertexPoint call inside a try block and return an appropriate map in the catch (though it may take a little iteration to figure out what that is).
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • Options
    Lee_HeskethLee_Hesketh Member, Developers Posts: 148 ✭✭
    Ah, okay. I'll just ignore it. My script is far from complete at the moment, but I'll eventually have a fully functioning mortice and tenon script. Thank you for your help. I will need it again soon probably!
    There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!
  • Options
    rune_thorsen229rune_thorsen229 Member Posts: 179 ✭✭
    Here's a slightly closer example of a feature that does this: https://cad.onshape.com/documents/8e50bb14e0b5602c307daafb/w/e49c36f7865e005268e46ec9/e/661a12669665a5ed18ddd2e1

    Notice that the length parameter is set to a string -- that sets the expression in the dialog.  If you want to set it to a value, you'd do something like
    getVariable(context, "part_width") / 3<br>
    instead of
    "#part_width / 3"
    How is this supposed to work? It seems to do nothing. 
Sign In or Register to comment.