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.

Setting Custom Properties using Workspace Properties

Alex_BentonAlex_Benton Member, csevp Posts: 5 PRO

Hi all,

I'm trying out some featurescript stuff to set some custom assembly properties automatically using a defined combination of workspace properties (custom properties from enterprise settings.)

I know what I want to do once I've 'imported' the relevant properties, but am struggling to even get there!

I've got the code below which I think is right but I get the error "Precondition of getProperty failed (definition.customPropertyId is string)" when I run in a test part studio. Is this because the context variable applies only to the part studio and can't access workspace properties?

Please let me know how you'd go about accessing custom properties set at the workspace level.

Thanks,

Alex

FeatureScript 2433;
import(path : "onshape/std/computedPartProperty.fs", version : "2433.0");
import(path : "onshape/std/properties.fs", version : "2433.0");

annotation { "Property Function Name" : "Test ID" }
export const dfvIdFull = defineComputedPartProperty(
function(context is Context, part is Query, definition is map) returns string

{
var desID = getProperty(context, {
            "entity" : part,
            "propertyType" : PropertyType.CUSTOM,
            "customPropertyID": "<redacted>"
        });


    return desID;
});

Comments

  • Caden_ArmstrongCaden_Armstrong Member Posts: 152 PRO

    I believe the get/set property featurescript function only works on parts specifically. Workspace, Partstudio, document (etc) properties are not accessible.

    Sounds like something that you'll need to use the API for.

    www.smartbenchsoftware.com --- fs.place --- Renaissance
    Custom FeatureScript and Onshape Integrated Applications
Sign In or Register to comment.