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.
How Can I Map a Configuration Variable to a Custom Property
Kyler_Walker
Member Posts: 202 PRO
I have parts that have a configuration variable defining their lengths. I need to get their lengths into OpenBOM. I'm pretty sure that I can get the lengths into OpenBOM if I send OpenBOM a custom property containing the length. I just don't know how to link my "Length" custom property to a configuration variable. How might I do this? When setting up the custom property, I noticed that there was a button that said "Select computed part property function." This button allowed my to select a featurescript. I assume this allows me to write a featurescript to define the value of the configured property. What would this look like? Can I directly write to my "Length" property in the featurescript? Does the featurescript need to return a value that will then get assigned to my "Length" property? How do I reference the featurescript ID associated with a configuration variable? This needs to work generally for all my parts across many part studios that have configuration variables determining their lengths.
Thanks
Thanks
0
Answers
I just pass the variable into the precondition, then use setproperty
Here's an example. Just to make it easy on myself, this one looks for a variable explicitly called #length, which may not be flexible enough for you, and would be confusing if there are multiple parts in the studio, which might all be assigned that property. There are other more flexible ways to do it, like calculating the bounding box and assuming length is the longest dimension. Full disclosure, I've never done this before so I thought this would be good practice for me, but my custom property I made to test still says "pending" so I've not tested it yet. Feels like this will work or is close though.
https://cad.onshape.com/documents/021639b97541f3bb7ed98c3d/w/b516aa4e844fdff580b17305/e/65840c7b88114195730987d2
If you want to choose which part is getting the calculated property, you could also make a custom feature that let's you choose which part gets it, like this (again not tested yet):
https://cad.onshape.com/documents/021639b97541f3bb7ed98c3d/w/b516aa4e844fdff580b17305/e/32482e95ec5f62b0f54952b2