Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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_sleeman
Member, Developers Posts: 21 ✭✭
in General
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?
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?
0
Comments
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.
HWM-Water Ltd
Not sure why you can't do it using STEP - good improvement request (log it in the forum category to the right --->)
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
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.
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.