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.

Programmatic Configure Variable and Export (to STEP)

james_sleemanjames_sleeman Member, Developers Posts: 21 ✭✭
So I have designs which all have a linear pattern aspect driven from a variable, specifically in this case pin headers of various types, here is a link to the females...

https://cad.onshape.com/documents/1ea4437bed8c346720558ece/w/bc7fb334c6315ff918e1dd17/e/67d18d366270ceb0424756ad

and males...

https://cad.onshape.com/documents/3afb2288e410cc18e2dde185/w/6a7313cf65ab2b8575076093/e/ce51578e744ced5f225cbbfd

what I want to do is in total pseudocode

    for(var n = 1; n <= 40; n++)
    {  
      SetVar('NumPins', n);
      ExportPartWorkspace(N+'.step');
    }

obviously, I could do this manually, but give it takes like 30-40 seconds just to do each step (change variable, wait for regenerate, export part studio, configure export, wait for export to download, rename download file, rinse and repeat), and I've got, 40 steps per variant, and 5 variants so far just of the females and 9 of the males, well that's obviously not really a fun time, especially if I should do it, and then find I needed to make a change... oh, man, that would be painful!

Ideas?

Comments

  • owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    edited January 2017
    HI.

    I like where you're heading with this.

    I'm no expert but from what I've picked up so far:-

    (1) Featurescript is the first layer of code exposed to the user.  All users have access to it as it's native to OS.  The good news is it's perfect for building the parts you show.  Either from scratch in the code, or by importing a seed, patterning it, booleaning them together etc.  The bad news is FS can only build features, it can't export anything.

    (2) API's on the other hand I believe can.  More complicated, and one has to sign up to use them.

    (3) If it were me I think I'd write a FS that does 2 things.  Either it would make a single part of your choosing on demand and stop, or it would make one of every part.  These could then be exported in bulk or moved into a library document to be imported/derived in as required.

    Hopefully someone with a tad more experience will be along to offer a proper answer shortly.

    Cheers,

    Owen S.


    Business Systems and Configuration Controller
    HWM-Water Ltd
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,683
    Does it have to be STEP? If you export from a Part Studio in Parasolid or STL format, you have the option to "export parts as individual files". You could put all your parts in one studio using Derived feature then use that. The output is a zip file containing files named <Part Studio Name> - <Part Name>.x_t

    Not sure why you can't do it using STEP - good improvement request (log it in the forum category to the right --->)
    Senior Director, Technical Services, EMEAI
  • james_sleemanjames_sleeman Member, Developers Posts: 21 ✭✭
    edited January 2017
    Does it have to be STEP

    Realistically yes.

    You could put all your parts in one studio using Derived feature

    Hmm, I'm not sure you quite understand the task at hand, or at least I don't see how your suggestion would really work towards accomplishing the goal even if I could use stl or parasolid.

    Here's a video showing me doing a couple manual cycles of exactly what I want to automate, and at the end I flick through the other workspaces in this document, I would need to do 40 of these iterations per workspace, and there are another 9 workspaces in another document requiring the same treatment. 

    https://youtu.be/7dfQ-JR87xE


  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,683
    My suggestion wouldn't work anyway because you are effectively exporting an assembly of parts. You could do this through the API with a developer account, but it would be quicker to do it by hand (unless of course you do this day in day out).
    Senior Director, Technical Services, EMEAI
  • awkawk Member, Onshape Employees, Developers Posts: 78
    The Onshape APIs should support this type of workflow. You'd need to involve a combination of the Feature list API (to set the value of the variable) and the export APIs (to give you the STEP representation). Since this is really just an automated tool/script for your own use I'd expect you to use an API Key to authenticate yourself when using the APIs (as opposed to OAuth which is more relevant to apps that are to be shared amongst many users)

    If you visit https://dev-portal.onshape.com (sign in with the same account you use for https://cad.onshape.com) and agree to the API Agreement that's presented you'll be able to find documentation on the above items. There's also some sample code (and helper library for the API Key mechanisms) at https://github.com/onshape-public. Also if you've agreed to the API Agreement you'll be able to see the API explorer in the App store and add it to a document and use it to test/try out some of the API calls.
    Director of API, Appstore, and App Partner Technical Support
  • james_sleemanjames_sleeman Member, Developers Posts: 21 ✭✭
    The Onshape APIs should support this type of workflow. You'd need to involve a combination of the Feature list API (to set the value of the variable) and the export APIs (to give you the STEP representation).
    Thanks, I took a quick look, a couple thoughts

      1. That looks like heavy arcane work unless you are intimately familiar with the internals 
      2. Doesn't seem to support step export anyway (only methods I saw were for stl and parasolid)

    Looks like it's really just not going to be feasible, so I'll probably just put it on the back burner for now or use a different package, maybe one day we might get some simple in-browser scriptability to do this sort of operation.



Sign In or Register to comment.