Setting Custom Properties using Workspace Properties

Alex_Benton
Alex_Benton Member, csevp Posts: 5 ✭

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_Armstrong
    Caden_Armstrong Member Posts: 471 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 --- Renaissance --- Kestrel -- SmartLink
    Experts in Onshape Automation - Custom Features and Integrated Applications