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.

Passing a variable from Part Studio A to Part Studio B

HuguesLessardWRIHuguesLessardWRI Member Posts: 14 PRO
Hi,
I am wondering if there was a way to pass a variable from a Part Studio to another one in the same document, at least passing only its value... I would expect that a Derive would work, but nope.

P.S. Variable can have a few different meanings in Onshape, The one I am questionning here is the one that appears as an (x) in toolbar / the feature tree.

Thanks in advance for your help,
Greetings,
Hugues Lessard
Ingénieur de produits / Product Engineer
Waste Robotics Inc. / www.wasterobotic.com

Tagged:

Best Answer

  • Alex_KempenAlex_Kempen Member Posts: 244 EDU
    Answer ✓
    My variable library FeatureScript should work pretty well for things like this, especially if you don't feel like dabbling with FeatureScript. Declare your variables in the variable library UI, then import the corresponding cube into your other part studio (using another instance of the variable library feature).

    Ilya Baran's Super Derive FeatureScript also has an option to bring in variables when you use it to derive something from another part studio, so that might also work reasonably well for you.
    CS Student at UT Dallas
    Alex.Kempen@utdallas.edu
    Check out my FeatureScripts here:



Answers

  • Alex_KempenAlex_Kempen Member Posts: 244 EDU
    Answer ✓
    My variable library FeatureScript should work pretty well for things like this, especially if you don't feel like dabbling with FeatureScript. Declare your variables in the variable library UI, then import the corresponding cube into your other part studio (using another instance of the variable library feature).

    Ilya Baran's Super Derive FeatureScript also has an option to bring in variables when you use it to derive something from another part studio, so that might also work reasonably well for you.
    CS Student at UT Dallas
    Alex.Kempen@utdallas.edu
    Check out my FeatureScripts here:



  • HuguesLessardWRIHuguesLessardWRI Member Posts: 14 PRO
    Thanks @Alex_Kempen, that was exactly what I was looking for.
    Hugues Lessard
    Ingénieur de produits / Product Engineer
    Waste Robotics Inc. / www.wasterobotic.com

  • matthew_stacymatthew_stacy Member Posts: 475 PRO
    @Alex_Kempen, I haven't tried Super Derive but checked out your Variable Library FS.  That is extremely useful.  Thanks for the tip.
  • rune_thorsen229rune_thorsen229 Member Posts: 179 ✭✭
    Alex_Kempen I am struggling with the same problem (https://forum.onshape.com/discussion/16566/how-to-make-a-master-configuration-driving-other-assemblies-linking-sync-assembly-configurations#latest) and have looked into your featurescript because it seem to do what I was looking for. Unfortunately I don't understand how to use it. Do you have a video or could you make an example of how to fetch the configuration setting?

    Please

  • Alex_KempenAlex_Kempen Member Posts: 244 EDU
    My variable library FeatureScript is useful for creating variables which can then be shared across part studios. Use the create tab to declare one or more variables, which will become attached to a corresponding library cube part. You can then use the import tab of another variable library feature in a different part studio to "derive" the created library cube part, which results in the variables attached to it becoming available in that part studio. However, it doesn't work in assemblies, so it probably won't be helpful for your purposes.

    For your use case, you might be able to create a workaround by adding a print layout configuration boolean to your master assembly. You could have users check it, then export their parts from the master assembly directly. Depending on how your assembly is set up, you might have to jump through some hoops with changing mate definitions and/or underlying configurations to get it to work, and the other configuration options wouldn't be hideable (since the visibility of configuration inputs can't be configured), but it might actually end up being easier for end users to use than your original solution.
    CS Student at UT Dallas
    Alex.Kempen@utdallas.edu
    Check out my FeatureScripts here:



  • rune_thorsen229rune_thorsen229 Member Posts: 179 ✭✭
    Alex_Kempen, thanks for your answer. It sounds like a good solution and thanks for clarifying that I can't use featurscripts for the assembly.
    I understand the logic with the boolean but don't know how to implement it. Basically the parts should be layed out flat and separated for the 'printlayout' so how can the boolean change the positions?
  • rune_thorsen229rune_thorsen229 Member Posts: 179 ✭✭
    Alex_Kempen, you just saved the day. Thankyou very much. 
    You gave me a solution: Double all the pieces. 
    One set shows the assembly in assembled form
    The other shows the assembly in printlayout form with that set of pieces layed out on for 3D printing.
    A boolean configuration allows the user to suppress one or the other set.
    Works great. However I think its a workaround that onshape could easily implement by allowing truely global variables out of the box. ;-)
  • matthew_stacymatthew_stacy Member Posts: 475 PRO
    However I think its a workaround that onshape could easily implement by allowing truely global variables out of the box. ;-)
    @rune_thorsen229, global variables (accessible across document tabs and even between documents) would be a great addition to Onshape.  I would also like to see addressable sketch dimensions and feature parameters (e.g. d1@extrude1 = 2*d17@sketch1)  SolidWorks has offered that functionality for years.

    And why the heck can't we utilize variables in assemblies?

  • martienmartien Member Posts: 13 ✭✭
    Global variables have now been implemented in OnShape, as a Variable Studio: https://cad.onshape.com/help/Content/variable_studio.htm

  • matthew_stacymatthew_stacy Member Posts: 475 PRO
    Global variables have now been implemented in OnShape, as a Variable Studio: https://cad.onshape.com/help/Content/variable_studio.htm

    @m@martien_verbruggen, thanks for pointing this out.  It appears to be a big improvement.  The inserted variable table does appear to be versioned, but I have yet to experiment to determine how updates are handled (presumably similar to inserting external parts into an assembly).

Sign In or Register to comment.