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

Can we update configuration variable or simple variable using featurescript?

MBagwanMBagwan Member Posts: 15
I have length parameter(simple variable or configuration variable) say "a"=10 mm.  Can we update this variable using featurescript. I tried following:

setVariable(context,"a",20*millimeter);
var updateda=getVariable(context,"a");

the  updateda=20 mm. 

But this will not update the variable on GUI. As well as the dimension configured with variable a doesn't update.

Can we do this using featurescript ?

Thanks in advance.

Comments

  • Options
    kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    A configuration variable is an input to your Part Studio (set before any FeatureScript runs) not an output. So the configuration values you see in the upper-left corner of your part studio are those input values. They can be set to any desired value when you( or another user) inserts your part(s) into an assembly, drawing, etc.

    As with any variable, you can update the configuration variables inside features, but I wouldn't recommend it precisely because it leaves you in the confusing state you describe: You can control this value in the upper-left corner, and inside a custom feature. That feature override changes the value partway through regenerating your features, meaning features below see the new value (from the feature) and features above see the old value (from the configuration).

    So, it seems likely there are more fitting tools in the Onshape toolbox for this job. What are you trying to accomplish?
  • Options
    MBagwanMBagwan Member Posts: 15
    Hi, thanks for the response.

    First of all, I am not importing part studio in another model. I am working on the same model.

    I have a model created using the revolving sketch. There is a configuration variable say "a" configured to one of dimension in the revolve sketch.
    This model has many configurations. For each configuration, I have a set of values in the configuration table. 

    One of the values in this set represents the default value for the same dimension which is configured with the variable "a".

    My task is to configuration variable "a"= default value from the set of values for the selected configuration.

    I hope you will understand the problem.

Sign In or Register to comment.