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.

Options

exporting variables from one feature studio to another

prajwal_shankarprajwal_shankar Member, Developers Posts: 11
for example if i have a variable as var pp = 1+5; in 'feature studio 1' and i want to use this variable in 'feature studio 2' as var pp1 = pp+1; 

can this be done? as in exporting values and quires from one feature studio to another? if so how should it be done and what is the syntax of coding to be followed? I'm kind of a 'newbie' to coding....so please go easy on the technical stuff on programming ;)
Tagged:

Comments

  • Options
    Dylan_StewartDylan_Stewart Member, Developers Posts: 107 PRO
    I'm sure one of the OS employees will chime in here shortly but, I have asked the same thing and (if I understand correctly) there is no possible way to do this at this time. They are working on getting this issue resolved as there have been many requests to add this functionality. 
    Digital Engineering
  • Options
    ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,178
    You can't export variables, but you can export constants if you do:

    In FS1:

    export const pp = 1 + 5;

    in FS2:

    import(... FS1 ...); // generated by clicking the import button

    const pp1 = pp + 1;
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • Options
    prajwal_shankarprajwal_shankar Member, Developers Posts: 11
    @Dylan_Stewart -  thanks for the reply.... duly noted ;)

    @Ilya_baran  - my question here was basic but let me state my exact problem. lets say i create two points on a sketch using   feature script in 'feature studio 1' and lets say i want to create a line between these two points but using a separate feature script i.e. in 'feature studio 2' . how can i reference the points in feature studio 1 to feature studio 2?????
  • Options
    ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,178
    I'm still not entirely clear on what you're trying to do.  Why not just define (and export) a function in FS1 that returns two 2D Vectors of lengths (sketch coordinates), call it from FS2, and pass the results to skLine?  Or do you need the sketch points themselves created in FS1 for some reason?
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • Options
    prajwal_shankarprajwal_shankar Member, Developers Posts: 11
    @ilya_baran

    yes you are right at the end and that is what i want to achieve. i want the sketch with two points in FS1 and using those two points i want to create a line in FS2 . how do i 'reference' features from one FS to another and i know that FS's arent interactive but atleast there should be a one way connection somehow!!!!!


    is this possible to achieve this at the moment?????

  • Options
    korikori Onshape Employees Posts: 25
    A feature definition in a Feature Studio is just a special kind of function, one that can be called from either a Part Studio or another Feature Studio, so what it seems like you're asking for is simple to do.  You can also use one feature in a Feature Studio to create a variable in the context and then use a different feature from a different Feature Studio to read or modify that same variable (using a shared variable name) in the context.  If you use both of these features in a Part Studio, they will both have access to the Part Studio context and thus can share variables.  

    However, since I'm missing the context and intent of what you want to accomplish, I'm not sure if this is what you're looking for.
  • Options
    prajwal_shankarprajwal_shankar Member, Developers Posts: 11
    kori said:
    A feature definition in a Feature Studio is just a special kind of function, one that can be called from either a Part Studio or another Feature Studio, so what it seems like you're asking for is simple to do.  You can also use one feature in a Feature Studio to create a variable in the context and then use a different feature from a different Feature Studio to read or modify that same variable (using a shared variable name) in the context.  If you use both of these features in a Part Studio, they will both have access to the Part Studio context and thus can share variables.  

    However, since I'm missing the context and intent of what you want to accomplish, I'm not sure if this is what you're looking for.
    this is what i want to do : i want two points to be created on a sketch in FS1 and i want to create a line in FS2 with the points i created in FS1. I know this dosent seem logical but, im trying something out and would love to have this option in my arsenal on ONshape. Can this be accomplished???

    ** It has to be reactive in such way that if i change the coordinates of the points in FS1 then the Line created thru FS2 should be updated accordingly.
  • Options
    ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,178
    Ok, I think this is what you mean: https://cad.onshape.com/documents/d56cc15cd6068e88cda32eab/w/ba06983f26760837545f0f45/e/b183b724bcc4cc49d7e51612

    I can't think of why doing it that way would be useful, so there's a second (much simpler) feature in there that makes a line controlled by coordinates in another feature studio.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • Options
    prajwal_shankarprajwal_shankar Member, Developers Posts: 11
    @ilya_baran

    This is perfect.....exactly what i needed. Thank you so much
Sign In or Register to comment.