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.

Anyone ever written a feature script that references a .csv spreadsheet of part numbers/descriptions

Sam_SchlageckSam_Schlageck Member Posts: 18 PRO
Hello!

We have some standard-ish panels that are assigned part numbers based off of sizing and a few other options. Right now I'm manually entering in the part numbers for the panels based off of the sizing of the panels (which can be time consuming, annoying and prone to occasional errors)

I'd like to write a feature script that automatically changes the part number and description based off of the length and width configuration variables and a few other configuration options. the part numbers are assigned based on foot increments - so there would need to be a 12" range where the specific part number would need to be applied. 

Has anyone written a custom feature like this?

Thanks!

Comments

  • caden_armstrong2caden_armstrong2 Member, User Group Leader Posts: 127 ✭✭✭
    I have written some features similar to this.

    If you are looking for guidance,
    all you should need to do is get the configuration variables by name using:

    getVariable(context, "myConfigVarName")

    and then set the part number using your part number logic and:

            setProperty(context, {
                    "entities" : targetPart,
                    "propertyType" : PropertyType.PART_NUMBER,
                    "value" : myPartNumber
            });


    If you are looking to hire someone to write it for you, CADSharp provides custom featurescript development services.
    You can reach me via my email in my signature.
  • Sam_SchlageckSam_Schlageck Member Posts: 18 PRO
    Would this start out as a computed part property function or a standard function?
  • Sam_SchlageckSam_Schlageck Member Posts: 18 PRO
    Alright - I got something to work for one of our parts - it only has 12 different part numbers/configurations so I simply put the part numbers in some "if - else" statements. It's probably longer, less elegant than it could be, but it works for what I need it to do.

    our panels have over 150 different configurations - so building out a featurescript using if-else statements to assign part numbers would be very long.

    I have a .CSV file with columns for some of our different variables - mesh size, a lower limit and upper limit for height, and a lower limit and upper limit for width. 

    What would be the best logic here to look up part numbers in the .CSV file? Is there a function that will compare my different variables (mesh size, width, height) to values in the different columns, and then assign the part number in the corresponding row?

    The .CSV does have descriptions in it as well, but I was going to write a different section of the featurescript that would string together a description based on the actual variables in the panel instead of looking up the description in the .CSV
Sign In or Register to comment.