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.
Namespaced Variable names

Hi !
I happen to have multiple ID,OD, etc. variable in different parts studios and documents. I'd like a way to be able to namespace them (like in C++ ) instead of typing OD
the name Bearing0.5::OD
would be clearer, while avoiding superfluous manually naming dimensions. Also it would be extremely helpful to be able to have a global dictionary of sizes like M3::NS
for the nominal size, M3::Pitch
for the pitch etc… and if those could be available to every user, I'm sure It'll make all of our sketches simpler and reuse correct dimensions for many common spare parts.
I'm sure this would require a major code refactor, but I can assure you, the reward is way worth the trouble !
Comments
If I understand correctly ,this looks a lot like what variable studios are meant for?
You can also use a custom feature (with drop downs) to create a "set" of variables in one go (for example the (OD and Pitch) for a selected fastener, but you have to create it in every part studio you need it, and it's not available in assemblies (unlike the variable studio).
You could split up your code into functions and have the variables locally within those functions. If you really wanted to you could then store those in a separate feature studio and import them.
Another way to do it is to store all related variables within a map. You could call that map the name of your bearing. For example:
There are also lookup tables… but I don't want to get into those. Kind of a headache.
Maps and FeatureScript can be used directly within the part studio inputs as well. In case you weren't talking about FeatureScript studios.
.
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴