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.

Why do I get a "Duplicate feature parameter" error when defining parameters inside IF...ELSE?

aaron_pattyaaron_patty Member Posts: 3
edited May 2018 in Community Support
Why does the following code throw a "Duplicate feature parameter 'tubeLength'" error when the definition.tubeLength definition can only execute once?

        annotation { "Name" : "Type" } definition.tubeTypeTest is TubeTypes;
        if(definition.tubeTypeTest == TubeTypes.TOP) 
            annotation { "Name" : "Length" }
            isLength(definition.tubeLength, TOP_TUBE_LENGTH_BOUNDS);
        else if(definition.tubeTypeTest == Tube.HEAD)
            annotation { "Name" : "Length" }
            isLength(definition.tubeLength, HEAD_TUBE_LENGTH_BOUNDS);

More specifically, how do I use the same definition.myVar with different LengthBoundSpec definitions based on the earlier input?

Best Answer

Answers

  • aaron_pattyaaron_patty Member Posts: 3
    This is a current limitation.  You can work around it by using different parameters in the precondition and then doing:

    if (definition.tubeTypeTest == Tube.HEAD)
       definition.tubeLength = definition.headTubeLength;

    in the body.
    Thanks ilya_baran. This would be a very convenient capability, reducing FeatureScript code significantly.
Sign In or Register to comment.