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.

Set Category with Featurescript?

EvanReeseEvanReese Member, Mentor Posts: 2,804 PRO

I'm trying to change a part category via FS. Some properties (like "Not Revision Managed") don't autocomplete, but can be set anyway as a "CUSTOM" property with the property ID. I hoped to do the same thing for a Category. Here's what I'm trying, but it isn't working. Has anyone else proven whether or not this is possible?

        const categoryID = "57f3fb8efa3416c06701d625";
        const categorySelectionID = "6983854abad5b851116b0a88";
        
        setProperty(context, {
                "entities" : entities,
                "propertyType" : PropertyType.CUSTOM,
                "customPropertyId" : categoryID,
                "value" : categorySelectionID
        });
Evan Reese
The Onsherpa | Reach peak Onshape productivity
www.theonsherpa.com

Answers

  • Caden_ArmstrongCaden_Armstrong Member Posts: 386 PRO

    Formatting the value is very counterintuitive, you need to put the property inside of a literal array - quotes and all:
    (And the forum is being weird with formatting so you get a screenshot)

    This is the value that goes into set property.
    If you do multiple categories, you add a comma between each and surround them with quotes.

    image.png
    www.smartbenchsoftware.com --- Renaissance --- fs.place
    Experts in Onshape Automation - Custom Features and Integrated Applications
Sign In or Register to comment.