Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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.

Options

Featurescript Instantiator

Hugh_GoodbodyHugh_Goodbody Member Posts: 39 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?

Comments

  • Options
    ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,178
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • Options
    Hugh_GoodbodyHugh_Goodbody Member Posts: 39 PRO
    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 bodies
    the 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?



  • Options
    konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    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.
  • Options
    Hugh_GoodbodyHugh_Goodbody Member Posts: 39 PRO
    Lovely thanks, working
  • Options
    Hugh_GoodbodyHugh_Goodbody Member Posts: 39 PRO
    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)});



  • Options
    konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    edited February 2021
    I bet you need to set configuration data in the field "configuration" rather then "configurationOverride". Don't really understand how configuration override works.
  • Options
    Hugh_GoodbodyHugh_Goodbody Member Posts: 39 PRO
    Thats it! I was copying some snippets from somewhere else.
    Thanks so much
Sign In or Register to comment.