Frequently, users want to include some metadata such as a Revision or Part Number in the file name of an exported file. Onshape has recently added Export Rules so this is no longer a manual process. Export Rules were originally released in February 2021, but already have received several improvements to make it a very versatile tool.

Location

You can set up Export Rules in either your User Preferences (My Account > Preferences > User Export Rules), or in the Company/Enterprise Preferences (Company/Enterprise Settings > Preferences > Company/Enterprise-wide Export Rules). If you use My Account, the Export Rules will apply to your account only. Note that only administrators can set up Company/Enterprise-wide rules.

Setup

Export Rules are available for all native Onshape Object Types. Select one of the types for the scope of the rule. Optionally, you can also apply a category to further filter the criteria. You can apply the rule to all exportable formats, or can select the format you want to apply it to.

TIP: Part Export Rules are triggered by part face or sheetmetal flat pattern exports as well!

Convention is the actual rule to be applied. It will always start with ${name} for the name of the object that is being exported, but you can remove it and put whatever you want. You can add static strings anywhere in the file name export, but dynamic properties must be denoted with ${propertyName}. Here is an example of a rule combining properties with static characters:

PRT- ${partNumber} ${description}

All properties use camel case. This means there are no spaces and the first word is lowercase (like partNumber). As you begin typing, Onshape will filter a list of possible selections for you to pick from to avoid mistakes:

Some properties require a prefix to define. Any properties that are assigned directly to the object you are exporting don’t require any sort of prefix, but sometimes you need to reference a parent or child of the object. One example would be ${document.name} to return the name of the document. All the prefixes and their usage are located below:

document - Uses the document properties. Available for all object types. 

workspaceOrVersion - Uses the active workspace or version properties. Available for all object types. workspace or version.

partStudio - Uses the Part Studio properties. Only available for parts. 

reference - Uses the properties of the part or assembly set as the Reference in the Sheet Properties. Only available for Drawings. 

For more detailed information on Export Rules, take a look at the Help under your subscription plan and then choose User/Company/Enterprise Account Settings > Preferences > Export Rules.