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.

FeatureScript fault

hansjuerg_jenzerhansjuerg_jenzer Member Posts: 9

I have a fault in this script.

mismatched input ')' expecting {'[', 'box', '::', 'boolean', 'number', 'string', 'array', 'map', 'builtin', 'function', 'undefined', '{', BOOLEAN, NUMBER, ID, STRING}

19:6 Feature Studio 1

Code:
FeatureScript 2581;
import(path : "onshape/std/common.fs", version : "2581.0");

annotation { "Feature Type Name" : "Set Part Appearance" }
export const stetPartAppearance = defineFeature function(context is Context, id is Id, definition is map)
precondition
{
annotation { "Name" : "Part to modify", "Filter" : EntityType.BODY }
definition.part is Query;
}

{
// Set the appearance with the desired transparency (0.5)
setProperty(context, {
"entities" : definition.part,
"propertyType" : PropertyType.APPEARANCE,
"value" : color(1, 1, 1, 0.5) // RGB (1,1,1) with 0.5 alpha for transparency
});
});

My idea: a feature script that sets the appearance to 50% when the part is actively selected.

Thank you for your support

Hansjürg

Comments

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,793

    defineFeature(

    Senior Director, Technical Services, EMEA
  • hansjuerg_jenzerhansjuerg_jenzer Member Posts: 9

    Hello Neil

    What exactly would you like to have better defined?

    The error message is there.

    “ mismatched input ')' expecting {'[', 'box', '::', 'boolean', 'number', 'string', 'array', 'map', 'builtin', 'function', 'undefined', '{', BOOLEAN, NUMBER, ID, STRING} ” In the last line at the second “ }); ”

    What should the script do?

    Set the appearance to 50% for a part activated with the mouse. However, the color should not be changed. This is certainly still wrong in the code.

    Thanks for the help.

    Hansjürg

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,793

    I was merely pointing out that you are missing a parenthesis after defineFeature.

    Senior Director, Technical Services, EMEA
  • hansjuerg_jenzerhansjuerg_jenzer Member Posts: 9

    Thank you for the further explanation. It has helped.
    I am an absolute greenhorn in the script area.

Sign In or Register to comment.