Help with instantiation

Dylan_Tobey
Dylan_Tobey Member Posts: 4 PRO

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:

image.png

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