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.
Default value of a configurable variable from an imported part studio?
MichaelPascoe
Member Posts: 1,979 PRO
I have imported a studio to be instantiated. There is a configured variable called "fillet". Is there a way to grab the imported studio's default value for "fillet"?
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
0
Best Answers
-
Alex_Kempen Member Posts: 248 EDUIf you’re talking about configurations, then the answer is not really, unless you try doing shenanigans with queries to figure out the fillet radius after importing. However, the instantiator does give you options to drive the configuration of imported part studios, even ones which are selected manually, so although you don’t know the default, you could easily override it with whatever computer value you want.CS Student at UT DallasAlex.Kempen@utdallas.eduCheck out my FeatureScripts here:0
-
MichaelPascoe Member Posts: 1,979 PROFor anyone else trying to instantiate a part studio and would like to control the custom configurations while keeping the default configurations default values if they are not changed... Each instantiation definition map must be the same size. I wrote this to check for the largest definition in my array of maps. Once it finds the largest definition map, it goes through all the other definition maps and adds fake configurations to maintain the definition map size for the instantiation...
//For instantiations, each instantiation definition map must be the same size //Find the largest map var largestMap = 0; for (var i = 0; i < size(customParameterDefinitions); i += 1) { if (size(customParameterDefinitions[i]) >= largestMap) { largestMap = size(customParameterDefinitions[i]); } } //Adds fake configurations to the map until all maps are the same size for instantiations for (var i = 0; i < size(customParameterDefinitions); i += 1) { var thisMap = size(customParameterDefinitions[i]); if (thisMap < largestMap) { for (var k = 0; k < largestMap; k += 1) { if (size(customParameterDefinitions[i]) < largestMap) { customParameterDefinitions[i] = mergeMaps(customParameterDefinitions[i], { "Nothingness" ~ toString(k) : 0 * inch }); } } } }
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴0 -
kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565A couple things can help build this type of feature:
1) When FeatureScript controls a specific configuration value, you can make that value unsettable by end users with the "ComputedConfigurationInputs" option.
2) When using that option, the value passed in will always be the default value of that Part Studio configuration parameter at the time the feature was created. Its exact value can be accessed as e.g. definition.selectedPartStudio.Length
3) When adding the instances, any number of configuration inputs can be overridden in the addInstance function with e.g.addInstance(instantiator, definition.partStudio, { "configurationOverride" : { "Length" : computedLength } });
You can make a single instance with a custom value, or make many instances with different custom values.
@MichaelPascoe
For your specific issue on map size, it seems very odd that such code would be necessary. What error are you seeing from the instantiator if instance maps are not the same size?1
Answers
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
If you want to see an example of the configurator being used to bring in configured bodies, I would take a look at lines 912-981 of my belt calculator FS here:
https://cad.onshape.com/documents/9cffa92db8b62219498f89af/w/06b332ccabc9d2e0aa0abf88/e/99672d1e329b38e647d90146
Notably, omitting an argument from the configuration map simply causes the value of that configuration to become the default for the part studio. Similarly, additional configuration arguments which don't match the FeatureScript value of a configuration are ignored. The above process looks slightly different if using PartStudioData from a part studio reference parameter, but the core concepts are more or less the same.
I will release the feature soon. You will be able to see what I'm talking about then.
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
1) When FeatureScript controls a specific configuration value, you can make that value unsettable by end users with the "ComputedConfigurationInputs" option.
2) When using that option, the value passed in will always be the default value of that Part Studio configuration parameter at the time the feature was created. Its exact value can be accessed as e.g. definition.selectedPartStudio.Length
3) When adding the instances, any number of configuration inputs can be overridden in the addInstance function with e.g.
@MichaelPascoe
For your specific issue on map size, it seems very odd that such code would be necessary. What error are you seeing from the instantiator if instance maps are not the same size?
This is valuable info. Thank you!
The specific error I was getting: @matrixDifference: Matrices must be the same size.
This error would happen if instances had different map sizes.
For example, if customParameterDefinitions[0] was { "fillet" : 1 * inch} while customParameterDefinitions[1] was { "fillet" : 2 * inch, "chamfer : 1 * inch} the error would occur.
Solution: Make each instantiation map the same size.
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
This is definitely an issue in the instantiator where we could do better on our end. We've filed it as a bug internally and we'll update here if/when there is a fix. For now your workaround is good. Thanks for reporting!