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.


If based Look Up Tables For Configurations

Michael_UrsuliakMichael_Ursuliak Member Posts: 14
Configurations are powerful and are able to make it very easy to grab a specific part and insert it into your assembly.
However as of right now i think that some improvements can be made in regards to parts that have multiple part numbers and configs.
For example I have a wire duct part that comes in a verity of height width and length combinations.
Too many combinations to put into a single config list. instead i have 3 config inputs. Height, Width, and Length.
Having 3 entries makes it much easier to create your specific part.

However in this method there is no way to attach part numbers to the configured parts.

I propose a logic based Look up table.

for example, if Config input 1 == 1" & Config input == 1.5" & Config input 3 > 5" & Config input 3 < 2" then part number = 12345

Using logic would allow for lots of part numbers to be dynamically addressed based on the users needs. 

If i need 7" of wire duct but the wire duct stock only comes in 5" and 10" then i would need the 10" stock number but still use the 7" part in my model. 


  • Options
    chadstoltzfuschadstoltzfus Member, Developers, csevp Posts: 131 PRO
    I like the lookup table idea. For now though, there are some ways of getting this accomplished with a little bit of FeatureScript. You could create a custom feature that uses the setProperty() function to set the part number, and simply put your logic for the part number in the defintion.partNumber parameter. 

    Or if you wanted to you could build that into your code itself. It's worth noting that you can grab any configuration parameters with the getVariable() function. I would personally recommend putting a try silent around that though, since you might not want your feature breaking if it can't find a specific configuration variable. 

    FeatureScript 2075;
    import(path : "onshape/std/geometry.fs", version : "2075.0");
    annotation { "Feature Type Name" : "Set Property" }
    export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)
            annotation { "Name" : "Entities", "Filter" : EntityType.BODY }
            definition.entities is Query;
            annotation { "Name" : "partNumber Params" }
            definition.partNumber is string;
            // Example of grabbing a configuration variable
            var configurationVariable; 
            try silent
                configurationVariable = getVariable(context, "configurationVariableName");    
            // Sets the property
            setProperty(context, {
                        "entities" : definition.entities,
                        "propertyType" : PropertyType.PART_NUMBER,
                        "value" : definition.partNumber

    Applications Developer at Premier Custom Built
  • Options
    Evan_ReeseEvan_Reese Member Posts: 2,065 PRO
    I like what Chad is suggesting probably more, but I've solved this another way in the past.

    I was modeling a configured torsion spring with various parameters including a left-handed and right-handed version of each. I was referencing a McMaster part number, so the LH and RH springs should have different part numbers even if all other specs are the same. What I was looking for could be represented well with a 2-dimensional matrix, like this:

    Spring specsLeft HandedRight Handed

    So I ended up making a List Config for the Spring Specs and a Boolean Config for the LH/RH. The LH/RH button controlled a variable called #isRightHanded which is set to 0 or 1, which I used to access two lists of part numbers stored in a nested array, like this
    #partNumber = [[9271K223, 9271K355, 9271K403],[9271K224, 9271K384, 9271K446]][#isRightHanded][#listIndex]
    This has two lists of part numbers, one for LH, and one for RH. #isRightHanded chooses whether to look at the first or second list (array) of part numbers, and #listIndex, picks which part number to use from that list.

    Evan Reese / Principal and Industrial Designer with Ovyl
    Website: ovyl.io
  • Options
    Sam_SchlageckSam_Schlageck Member Posts: 18 PRO
    I managed something similar with if - else statements. If a certain part falls within a certain size range, then a part number gets assigned to it. It works great for parts with less than 20 different part numbers. 

    I'm trying to figure out what the logic would look like for a table of 150+ part numbers with 3 different configuration variables. Using if - else statements isn't a good option - as the code would wind up being very long. 
Sign In or Register to comment.