FeatureScript fault

hansjuerg_jenzer
hansjuerg_jenzer Member Posts: 16 ✭

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

  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,126 image

    defineFeature(

    Senior Director, Technical Services, EMEA
  • hansjuerg_jenzer
    hansjuerg_jenzer Member Posts: 16 ✭

    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

  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,126 image

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

    Senior Director, Technical Services, EMEA
  • hansjuerg_jenzer
    hansjuerg_jenzer Member Posts: 16 ✭

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