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.

Feature Script - Setting and overiding default parameter values

daniel_perahia_dedesdaniel_perahia_dedes Member Posts: 2 PRO
I am making a feature for a tube clevis insert. The function currently requires the user to select the outer and inner edges of the tube and a mate connector, and then generates an insert which fits inside. 

There are a further 5 parameters which define the clevis geometry. When the 'Default Values' box is checked, in the main function these parameters are set to values based off the inner and outer edges which have been selected. (For examples the height = OD, the depth = ID). This ensures that a suitable clevis is generated automatically as soon as the edges are selected. 

If a user would like to change these parameters, they can uncheck 'Default Values' and the parameters are made available to edit. However, when this is done, the previous 'defaults' which I have set, are overridden by the parameter default which is 25mm, and you are left with what can be seen in the second photo. 

I would like for the tube geometry-based default-clevis to stay, and for dimensions to only be updated if and when the user changes values in the dialog.

This will require setting the defaults of the parameters (Height, Depth etc)  however this must be done outside of the precondition, and I don't know how to do this in the main code. 

I can set a default value for the parameters in the precondition using the code below:

        // inputs 
        annotation { "Name" : "Height" }
        isLength(definition.clevisHeight, { (meter) : [0,  put default, 1e5] } as LengthBoundSpec);

Does anyone know how to do the equivalent but in the main code?

I hope this was clear and thanks for the help. 

Daniel 

 

Comments

Sign In or Register to comment.