Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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
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
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.
Custom FeatureScript and Onshape Integrated Applications