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.
Help with instantiation

I'm a new FeatureScript user working to develop a custom feature which will allow a user to select a part studio containing one part and bring it into the a new document. However, I've run into some issues with the instantiation module, receiving the error below:
I've already looked at the standard documentation and tried to follow along with this post:
But I haven't had any luck resolving the error on my own. Any chance someone could point out where I'm going wrong?
FeatureScript 2641; import(path : "onshape/std/common.fs", version : "2641.0"); annotation { "Feature Type Name" : "Add thing" } export const addThing = defineFeature(function(context is Context, id is Id, definition is map) precondition { annotation { "Name" : "Mounting mate connector", "Filter" : BodyType.MATE_CONNECTOR, "MaxNumberOfPicks" : 1 } definition.mountingConnector is Query; annotation { "Name" : "Choose part to import" } definition.partChoice is PartStudioData; } { const instantiator = newInstantiator(id + "inst", {}); const toPlane = evMateConnector(context, { "mateConnector" : definition.mountingConnector })->plane(); var toInstantiate = definition.partChoice; const instance = addInstance(instantiator, toInstantiate, { "transform" : transform(XY_PLANE, toPlane) }); instantiate(context, instantiator); const instantiatedBodies = qCreatedBy(id + "inst", EntityType.BODY); const instantiatedFaces = qCreatedBy(id + "inst", EntityType.FACE); });
Comments
Your code seems to be working fine… https://cad.onshape.com/documents/dfc1499f6151bb475715b537/w/ebf804f2164f2b92444e9890/e/0a5e680b4892d4d039632ffd
Thanks for confirming the code itself was right. I figured out what I was doing wrong:
I was selecting "Part Studio 1" in the image without clicking the "Create version" button, first. Creating the version first resolves the issue and lets me bring in the part.