Comparing enum check inside group

MBagwan
MBagwan Member Posts: 15 ✭
Hi @NeilCooke
Inside the group, I am not able to compare enums.
suppose I have variable group.type which of one enum ok. Now I want to compare this enum value and depend on this value need to declare some specific annotations and ignore other annotations.
But I am getting error like this, " Could not Identify Parameter Id in either operand of comparison in if".
Could you just explain what I am doing wrong?

Comments

  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,126 image
    Can you share your code here? Just need the precondition. 
    Senior Director, Technical Services, EMEA
  • MBagwan
    MBagwan Member Posts: 15 ✭
    Hi, Thanks for the quick reply, here is the code.


    export enum ENUM_TYPES
    {
        annotation { "Name" : "TYPE_1" }
        TYPE_1,
        annotation { "Name" : "TYPE_2" }
        TYPE_2
    }

    annotation { "Feature Type Name" : "feature name" }
    export const featureName = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {

            // annotation { "Name" : "Enum Type" }
            // definition.enumType is ENUM_TYPES;

           
            annotation { "Name" : "enumType", "Item name" : "entities", "Item label template" : "#enumType" }
            definition.groups is array;
            for (var groups in definition.groups)
            {
                annotation { "Name" : "Enum Type" }
                groups.enumType is ENUM_TYPES;

                if (groups.enumType == ENUM_TYPES.TYPE_1)
                {

                }
                if (groups.enumType == ENUM_TYPES.TYPE_2)
                {

                }
            }

        }
        {

            if (definition.enumType == ENUM_TYPES.TYPE_1)
            {
                //call type 1 method
            }
            if (definition.enumType == ENUM_TYPES.TYPE_2)
            {
                //call type 2 method
            }


        });

  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,126 image
    Sorry - now I understand your question - it does not work with "Array Parameters" at this time. There is a ticket open for this already - if you would like your name added to it, please vote here: https://forum.onshape.com/discussion/7628/conditional-visibility-of-array-parameters/p1
    Senior Director, Technical Services, EMEA