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.
How to use function autocomplete?

I am trying to write my own functions with feature script. I want to use autocomplete the way the standard onshape functions do. The problem is I can't get it to work. I've been copying what I see in the standard library with no luck:
Here's a dummy function with what I'm trying
export function dummyFunction(id is Id) returns array{ /** * @param id : @autocomplete `id + "dummy" (forum is doing weird formatting things when I include the closing ` but it's there in my code) * **/ return []; }
Which in theory should give me dummyFunction(id + "dummy") when I call it. But I keep getting just dummyFunction(id).
What am I doing wrong?
Best Answer
-
MichaelPascoe Member Posts: 2,196 PRO
Here is one of Onshape's, try this format instead:
/** * Attach an attribute to one or several entities. Will overwrite any attribute previously set on the same entity * with the same name. * * @param definition {{ * @field entities {Query} : Entities to attach attribute to. Throws an error if the query resolves to nothing. * @field name {string} : The name of the attribute @autocomplete `"myName"` * @field attribute : The data to set. Can be any type. If `undefined` is provided, any existing attribute * will be unset (and this entity will no longer resolve in [qHasAttribute] and similar functions) * @autocomplete `"myValue"` * * Legacy unnamed attributes: * If name is not provided, adds an unnamed attribute to the entities. If more than one unnamed attribute * with the same type is set on any entity, throws an error. * }} */ export function setAttribute(context is Context, definition is map) precondition { definition.entities is Query; definition.name is string || definition.attribute != undefined; } { @setAttribute(context, definition); }
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴0
Answers
Here is one of Onshape's, try this format instead:
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
Ah I see, the placement is different. Thanks!!