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.

Comparing enum check inside group

MBagwanMBagwan 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

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,686
    Can you share your code here? Just need the precondition. 
    Senior Director, Technical Services, EMEAI
  • MBagwanMBagwan 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
            }


        });

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,686
    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, EMEAI
Sign In or Register to comment.