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.

Featurescript Instantiator - addInstance result not evaluating to any bodies

Jacob_CorderJacob_Corder Member Posts: 19 PRO
I am creating an instantiator featurescript. everything works great, i'm pulling in sketches into another part. I'm building the PartStudioData myself using maps. Everything is working as expected besides the Query returned from addInstance. when a sketch profile is all that is imported (instantiated), it resolves to no entities. these sketch profiles are closed sketches.

however, when i do this
var createdFaces = evaluateQuery(context, qCreatedBy(id + "instantiator1", EntityType.FACE))
size(createdFaces) returns the expected number of faces and i can proceed. however, the order these faces are returned, is not consistent.
i cant exactly share the code as it is for a client. 

any help would be much appreciated.  Thank you 


  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 493
    What you're suggesting should work fine, with sketches or any other geometry (example).

    Make sure you use the query returned by addInstance() after you call the instantiate() function. instantiate() is where geometry is actually created, so before it's called, the query returned by addInstance() is just an order form for entities that don't yet exist.
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 493
    Note that when not using a reference parameter, the default partQuery excludes sketches, so you'll need to specify it like
    const instanceQuery = addInstance(instantiator, PROFILE::build, {
        "partQuery" : qConstructionFilter(qEverything(EntityType.BODY), ConstructionObject.NO) // include sketches, only exclude default planes
    Leaving that out would cause instantiate to fail outright since the instance has no geometry.
  • Jacob_CorderJacob_Corder Member Posts: 19 PRO

    i am instantiating first. then execute the query created by addinstance.

    qCreatedBy InstantiatorID  returns everything created even the wire bodies in each instance as expected
    however evaluateQuery (context, addinstanceReturnQuery) returns nothing for each instance. i have shared the featurescript with support if you want to see it. 

Sign In or Register to comment.