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.

Export description through Feature Script

Kiran_ThimmegowdaKiran_Thimmegowda Member Posts: 6
Hi,
I am working on a feature script to create a custom feature & export its data to an app through set variable approach. The name of the set variable should be robust enough to differentiate in case of multiple part studios & multiple custom feature instances.
I am looking for an way to find the part studio identity(for e.g. name) & custom feature instance identity(for e.g. name) through feature script so that i can attach it with set variable name. Please let me know if anybody come across such feature scripts. Thanks.

Comments

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 2,350
    Hi @Kiran_Thimmegowda - this is not possible through FeatureScript. The security model is such that a custom feature cannot read or write to other features or read properties from a part studio (with the exception of variables and attributes). You will have to use the API in order to do what you want, especially if you are wanting to export the data to another app.
    Neil Cooke, Director of Technical Marketing, Onshape Inc.
  • Kiran_ThimmegowdaKiran_Thimmegowda Member Posts: 6
    @NeilCooke, Thanks for the reply.
    I am calling Evaluate FS, get feature list & element list API's to get the setvariable data, features & elements respectively. As there is no direct mapping b/w the data, i am not able to retrieve setvariable data at app side specific to custom feature & part studio. Please let me know if there is a single API to get all the data mentioned above OR any alternative way.
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 928
    The feature id can help you differentiate between feature instances within a part studio (and is in the feature list you get via the API).  I'm less clear on what you want to do with part studio ids -- if you're calling the evaluate FS API, you're providing the part studio id already and there should be no ambiguity.  In FS itself, there's no way to access the part studio id (because we want to ensure that if you copy a part studio and it gets a different id, it'll nevertheless regenerate identically).
    Ilya Baran \ Director, Architecture and FeatureScript \ Onshape Inc
  • Kiran_ThimmegowdaKiran_Thimmegowda Member Posts: 6
    Hi @ilya_baran,
    To be more specific, i am creating points using custom feature & export its coordinates to excel using set variable & evaluate FS API call. To handle multiple custom feature instances, i am incrementing set variable x to x1, x2, x3, etc for every instance created(CF1-serial #1, CF2-serial #2 , CF3-serial #3). Retrieving data at App side using the increment index 1,2,3 mapping with CF serial # 1,2,3.
    In case of deletion of CF instance for e.g., if user delete CF2-serial #2 then CF3 will become serial #2 & App retrieves data of x2 instead of x3. To overcome this, i need to rename setvariable specific to custom feature created. Complexity added if there are multiple part studios are there.

    Hope i am clear, please let me know if more details needed. Thanks.

  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,339
    @Kiran_Thimmegowda

    Maybe the best way is to just ask the user to input a unique string identifier?
    Jake Rosenfeld - Modeling Team
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 928
    Inside the feature, id[0] is a string that is unique for that feature (except feature patterns -- then construct the variable name concatenating all components of id) within the part studio.  It'll remain the same if other features are deleted.  You can also use it in conjunction with your numbering scheme.
    Ilya Baran \ Director, Architecture and FeatureScript \ Onshape Inc
  • Kiran_ThimmegowdaKiran_Thimmegowda Member Posts: 6
    I later discovered that,
    1. Onshape automatically updates setVariable values whenever there is change in the order of the related custom feature in part studio. Also, setVariable  will be deleted when the related custom feature is deleted. So we can fetch the setvariable value as per the order of custom feature in part studio.
    2. setVariable values are specific to part studio. So we can have setVariable with same name for multiple part studio.

    This solved my problem. Thanks all for the responses.
Sign In or Register to comment.