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.

another function question

papawopapawo Member, Developers Posts: 206 PRO
edited March 2018 in FeatureScript
lets say a feature that gives 'data' whatever the user pick
line & line = data
plane = data

how to do an export function to get 'data' usable to other fs?



  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,040 ✭✭✭✭✭
    if you mean that function should evaluate some query of unknown type and do some action with it then use the sequence of try silent {} operators

    function evQuery(context is Context, query is Query)
    var result;
    try silent {
    result = evLine();
    debug(context, result);
    return result;
    try silent {
    result = evPlane();
    debug(context, result);
    return result;
    //and so on

  • papawopapawo Member, Developers Posts: 206 PRO
    the whole feature does the evaluating already. and I would like to capture the result to be exported.
    when trying to do a function, I ending up repeating the code of the feature.
  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,040 ✭✭✭✭✭
    then simply assign desired results of feature evaluation to the variable or append to array and do debug() or print() in the end
  • papawopapawo Member, Developers Posts: 206 PRO
    it does println or debug.
    how to do the variable or append? 
  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,040 ✭✭✭✭✭
    ok, now i noticed your edited question.
    there are 2 ways to make data global:
    - setVariable() function creates global variable of any type (even function type) and this value can be obtained in later added features by getVariable()
    - setAttributes()/getAttributes() sets and gets attributes of any type to a certain geometry, which can later be extracted by other features
Sign In or Register to comment.