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.

Read and write part properties or document properties

emagdalenaC2iemagdalenaC2i Member, Developers, Channel partner Posts: 863 ✭✭✭✭✭
Can we get or set part properties or document properties with FeatureScript?
Un saludo,

Eduardo Magdalena                         C2i Change 2 improve                         ☑ ¿Por qué no organizamos una reunión online?  
                                                                     Partner de PTC - Onshape                                     Averigua a quién conocemos en común

Comments

  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,215
    With our API you'll be able to get and set part and document properties -- if you want write a program that does something like "go through this document and make all the parts purple" the API would be the way to do this.

    With FeatureScript (in other words, at regeneration time), the story is a little more complicated.

    Document properties will not be accessible for reading (because they may break determinism) and writing (because Part Studio regeneration should not affect the document state).

    For part properties, depends on what you mean: you can use setAttribute and getAttribute (see https://cad.onshape.com/FsDoc/library.html) to attach (and read later in the same regeneration) arbitrary data to a part (or an edge, face, or vertex).  However, if you would like Onshape to interpret these attributes as color, name, or material, we have yet to add support for that.  It seems unlikely that we'll be able to add support for reading interactively-set part properties during regeneration except possibly when deriving from another Part Studio.

    Let me know if that makes things more clear or more confusing  :)
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • jaschaaajaschaaa Member Posts: 21 PRO
    I would like to create a FeatureScript to determine the center of gravity of a selection of bodies and draw it in the model. I found this:


    For part properties, depends on what you mean: you can use setAttribute and getAttribute (see https://cad.onshape.com/FsDoc/library.html) to attach (and read later in the same regeneration) arbitrary data to a part (or an edge, face, or vertex).  However, if you would like Onshape to interpret these attributes as color, name, or material, we have yet to add support for that.  It seems unlikely that we'll be able to add support for reading interactively-set part properties during regeneration except possibly when deriving from another Part Studio.

    Does this mean I will not be able to get density data from the bodies? And is this still the case? 


  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,215
    edited August 2016
    With FeatureScript, yes I don't expect you will be able to access the interactively-set density (because in the regen process, the density is assigned after the relevant FS runs).  The API, however is not subject to this type of restriction.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
Sign In or Register to comment.