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.
Featurescript Instantiator
Hugh_Goodbody
Member Posts: 41 PRO
I am looking to write a featurescript using the instantiator to build configured hydraulic cylinders. I have made the configured parts of the cylinder such as pistons, endcaps, ports etc.
I now want to use featurescript to build cylinders. I assume that the instantiator is the way to go. Is there any documentation or examples on how to use the instantiator - as I haven't used the feature yet?
0
Comments
-
I would start here: https://cad.onshape.com/FsDoc/library.html#module-instantiator.fsIlya Baran \ VP, Architecture and FeatureScript \ Onshape Inc0
-
Thanks for that, have made some progress.I have brought in some parts using the below code:
const instantiator = newInstantiator(id + "inst", {});<br><br><br> //Instantiate Port<br> addInstance(instantiator, port::build, { "configuration" : { "Name" : "RP092A" }, "transform" : transform(vector(-capPortPos, 0, portVertPos) * millimeter) });<br> addInstance(instantiator, port::build, { "configuration" : { "Name" : "RP092A" }, "transform" : transform(vector(rodPortPos, 0, portVertPos) * millimeter) });<br> <br> //Instantiate Cap<br> addInstance(instantiator, endPlug::build, { "configuration" : { "Name" : endPlugConfig }, "transform" : transform(vector(-capPos, 0, 0) * millimeter) });<br><br><br><br> // repeat the above as necessary<br> instantiate(context, instantiator);<br> // This call actually brings in the bodiesthe variable endPlugConfig is changing as the user changes the bore input, however the part instantiated does not update to the correct configuration - am I missing something here?
0 -
it is not fully described in documentation, but for configuration list input you should use configuration id and list parameter id, rather then it displayed name or edit featurescripts id's manually to match it's name from within corresponding part studio menu of configuration input.
0 -
Lovely thanks, working
0 -
Moving on, am now trying to bring in a part configured with configuration variables, the following snippet is only bringing in the default configuration. I have checked the featurescript ID's and they are as listed in the below snippet
addInstance(instantiator, customBoss::build, { "configurationOverride" : {"Bore" : 12.1*millimeter, "OD": 50*millimeter, "Length" : 25*millimeter}, "transform" : transform(vector((pinBossPos+50), 0, 0) * millimeter)});
0 -
I bet you need to set configuration data in the field "configuration" rather then "configurationOverride". Don't really understand how configuration override works.0
-
Thats it! I was copying some snippets from somewhere else.Thanks so much0


