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.
Suggestions on approach for fully parametric model
eric_schimelpfenig
Member Posts: 75 EDU
in General
Hello all! I'm a new OnShape user, but not so new to CAD.
In the past I've built parametric models in other modelers like Inventor and Fusion. In most of those I load up the model in the beginning with a lot of variables that I want to reference later on as I model each part.
Here's my first "real" OnShape model:
https://cad.onshape.com/documents/43d856d66fd0c29bbe2b8830/w/b501db5c0fb256fbfc1ced5c/e/8f5c282ac7a8fa8ff3ec26f9
This is a dovetailed shipping crate. The idea is that I want to be able to punch in some dimensions and other variables and have a crate built to my exact dimensions on the fly. Thanks to OnShape, it's actually working reliably (not my experience in other modelers)
I did it by drawing all of my parts in this part studio:
https://cad.onshape.com/documents/43d856d66fd0c29bbe2b8830/w/b501db5c0fb256fbfc1ced5c/e/73bb0f71302ddfee1b1bd58f
I just laid them all out flat and drew each one. This was done because it appears that it's the only way to have master variables that every part can reference. As you can see in the timeline all of my variables are first. This is where I go when I'm about to cut out a new crate. Once the model recalculates I can check it in the assembly tab. From there I can email out a drawing if I need and export the STEP files for each part and bring them into my CAM software.
This all works really well, great in fact.... However I can't help but think that my approach might have been a little off... It seems to me that OnShape really wants you to design each part as a separate part file and then combine each part into an assembly. This makes logical sense to me, but where I got a little stuck was on how to reference those master variables that I want.
I'd love to hear from some of you the pros and cons to the approach I took here. I'm about to start building a fully parametric cabinet and I'm going to take the same approach. I'm wondering if I should change before I get too deep on that one.
In the past I've built parametric models in other modelers like Inventor and Fusion. In most of those I load up the model in the beginning with a lot of variables that I want to reference later on as I model each part.
Here's my first "real" OnShape model:
https://cad.onshape.com/documents/43d856d66fd0c29bbe2b8830/w/b501db5c0fb256fbfc1ced5c/e/8f5c282ac7a8fa8ff3ec26f9
This is a dovetailed shipping crate. The idea is that I want to be able to punch in some dimensions and other variables and have a crate built to my exact dimensions on the fly. Thanks to OnShape, it's actually working reliably (not my experience in other modelers)
I did it by drawing all of my parts in this part studio:
https://cad.onshape.com/documents/43d856d66fd0c29bbe2b8830/w/b501db5c0fb256fbfc1ced5c/e/73bb0f71302ddfee1b1bd58f
I just laid them all out flat and drew each one. This was done because it appears that it's the only way to have master variables that every part can reference. As you can see in the timeline all of my variables are first. This is where I go when I'm about to cut out a new crate. Once the model recalculates I can check it in the assembly tab. From there I can email out a drawing if I need and export the STEP files for each part and bring them into my CAM software.
This all works really well, great in fact.... However I can't help but think that my approach might have been a little off... It seems to me that OnShape really wants you to design each part as a separate part file and then combine each part into an assembly. This makes logical sense to me, but where I got a little stuck was on how to reference those master variables that I want.
I'd love to hear from some of you the pros and cons to the approach I took here. I'm about to start building a fully parametric cabinet and I'm going to take the same approach. I'm wondering if I should change before I get too deep on that one.
1
Best Answer
-
john_mcclary Member, Developers Posts: 3,936 PROThat level of featurescript is very basic.
var Name = value; this defines a variable in the scope of featurescript.
setVariable(context, "partstudioName", Name); this exposes the variable to be used in the partstudio.
now you would insert the FS in the part studio then use any variable by calling #partstudioName.
Configs are powerful, but with great power....
Try not to over do it, it can lead to slower performance in some cases. And you will need to enter the values with every part insert into everydrawing view and assembly, if the value is not default.
Also you cannot share config values between part studios like you can with FS method.
Modeling the parts in position as @owen_sparks says is the norm in Onshape too.
I'm just showing a simple way to communicate values between tabs.5
Answers
Inside the script add all your variables and calcs.
Then in every partstudio you can insert this FS on the top of the tree.
If you want to override a value Onshape allows you to have multiple variables with the same name, and the next usage will read from the last modified value.
Twitter: @onshapetricks & @babart1977
HWM-Water Ltd
@john_mcclary Ok, so there is a way to have global variables. I didn't want to dive into featurescript programming on my first, second or even third time out modeling in a new system. I feel like it's important to really understand the basics before you start programming on top of something. That doesn't look hard though, that being said I'm not the best coder!
@owen_sparks I'm glad I wasn't too far off in thinking that modeling all of the parts in the same part studio was the way to go. The way I approached the fit problem was to rough in the parts and at a very early stage get them assembled. This was especially helpful as the 6 sided crate only has 4 unique parts so assembling them early on really let me visualize them together. That being said it was a bit of a pain to have to switch back and forth between part studio and assembly. I only recently discovered "edit in context" which is helpful.
Here's a question for you: There's really not way to "assemble" in part studio is there? Other than referencing sketches and such on op of each other and drawing that way?
Also, plagiarize away! This design is a hack I've done on top of someone else's hack
var Name = value; this defines a variable in the scope of featurescript.
setVariable(context, "partstudioName", Name); this exposes the variable to be used in the partstudio.
now you would insert the FS in the part studio then use any variable by calling #partstudioName.
Configs are powerful, but with great power....
Try not to over do it, it can lead to slower performance in some cases. And you will need to enter the values with every part insert into everydrawing view and assembly, if the value is not default.
Also you cannot share config values between part studios like you can with FS method.
Modeling the parts in position as @owen_sparks says is the norm in Onshape too.
I'm just showing a simple way to communicate values between tabs.
(love these threads)
Owen - please tell Eric how Onshape is spelt!
I may start on this little 3D printable battery holder I made:
https://cad.onshape.com/documents/6d302d8e837059f0dee43fb3/w/3cdec4859f17e789b14b3ccc/e/9b56eb5b0750b2c4f9d49fff
I could put some options in there for battery amount and size (I've already done that, but with variables)
I've started playing with configurations.. I wish I knew about these before I got deep into my crate model (and this battery holder). It's exactly what I was looking for: Variables with Min/Max, suppression sets, and table configurations.
Here's where I'm a little fuzzy:
I can implement these configurations into my part studio:
https://cad.onshape.com/documents/43d856d66fd0c29bbe2b8830/w/b501db5c0fb256fbfc1ced5c/e/73bb0f71302ddfee1b1bd58f
But as you can see, my parts aren't assembled here, they're assembled in an "assembly"
https://cad.onshape.com/documents/43d856d66fd0c29bbe2b8830/w/b501db5c0fb256fbfc1ced5c/e/8f5c282ac7a8fa8ff3ec26f9
I did this because it seems like that's what assemblies should be used for... Assembling things
In my part studio it looks like it will be hard/impossible to really assemble the crate like i want, due to lack of joints and such...
So here's the question about workflow:
These crates are a base. I often add things to them like latches, feet, handles, and interior padding. It seems to me that the best workflow would be to insert a crate into an assembly, and configure it's dimensions when I drop it into an assembly. From there I could drop in other accessories. The problem is that if I drop it in now, it's flat....
So am I doing the right workflow here or is there a better way? It seems like I want to be able to do more assembly in part studio...
You can then use in-context to add your holes for your accessories.
You don't want your part studio to have too many features because it becomes harder to edit, and can slow things down. Because it will need to generate the whole studio every edit
I'll start with stating that @john_mcclary is a far more experienced engineer than me, with superior design and CAD skills that I'll not get close to matching anytime soon, so by default you should always believe him over me. That said I'm going to disagree with him here.
That's not wrong, but it could be more right! Assemblies can indeed be used to assemble things but so can Partstudios. What assemblies have a monopoly on is movement, ie slider mates and the like. There is nothing wrong with assembling things in Partstudios, in fact I'd encourage it...
There are two techniques I'd get to grips with here:-
(a) Transform by mate connector, this will allow you to snap parts together in a partstudio in much the same way as you do in an assembly.
(b) Don't model them flat in the first place! You can place a sketch on any flat surface you care to. (Part, default plane or custom plane). As such assuming we model the base of the crate first, we can draw the side of the crate on the edge of he base. This allows us to project the geometry of the base onto the side without having to draw everything from scratch.
We can then transform them from assembled to flat in a feature we can suppress with a config to get an auto flat pattern...
Yes, I'd do as much as I could in the PS, with the aim of a single group mate being added in the assy just to keep things together. I'll do an example doc after this post. (This advice will probably change when we have assembly configurations.)
In my mind what you've got is a great start but there are better ways.
General rules of thumb:-
(i) This aint SolidWorks so model things that are geometrically related to each other in the same partstudio and in their relative positions.
(ii) Model extra components that are not related in a new PS (for performance as there is no need to regenerate them each time the model rebuilds)
(iii) Only model one of each unique part in a PS, add duplicates in the Assy (this way they're seen as instances of the same part not individual parts).
OK example file on its way later.
oh and with regard to this:-
Owen - please tell Eric how Onshape is spelt!
So I'll leave the choice up to Erio. Either bend the knee and conform to "Onshape" or join the revolution (currently of one) and we'll convert the all the users to the "right thinking, far more mighty sounding OnShape" community. Your call.
Cheers,
Owen.
(Off to draw a box.)
HWM-Water Ltd
So here is the document;-
clicky
The premise is the same, we want a crate, we want to see it either assembled or flat, and we want it parametric.
Excuse that lack of joints / tabs, this waffle is more concerned with the method rather than the detail.
(1) It's drawn with the pieces assembled as mentioned in earlier post:
(2) We can uncheck the "build duplicate parts" to just show unique parts
(3) We can select the "flat" option to lay all the parts out for cutting. (The spacing shouldn't overlap as it's parametric but the layout isn't intelligent.)
(4) We can Add accessories, in this case feet...
(5)... or Castors
(6) We can edit the appearance.
This is a bit of a workaround. Configs have a native method to set appearance that is awesome, other than the fact it requires all configurations to be set. (So if we have variables like our width etc the config has to be set for each value a user might set. ) OS are aware of this and are working on it and such is the calibre of the work they do they supplied a custom feature to use in the mean time, hence the "Set Color" in the tree.
Continued in new post...
HWM-Water Ltd
Now this is where it gets really interesting!!
OK, so far we have a nice parametric crate with some extra twidely bits, but if we want to use it we still have to set a bunch of values each time...
If we have a some favourite settings for this crate we could make duplicates of the tab and leave the options filled in, or remove the variables from the front and have a pick list for the user to select from, but then it's not universal anymore. Meh.
So, did you know you can configure configurations with configurations?
@ilya_baran mentioned this at the beginning and it went straight over my head; only now have I just woken up.
Let me demonstrate:-
All the above is in the "universal Crate Builder" partstudio of the sample doc. Further along is a "Specific Crate Builder" PartStudio. This has a single derive of one of the crates from the first studio, and it drives the configurations from the first PS from its own Configuration Table.
The premise is we're doing a bank job, and we want some specific crates for different purposes.
(1) A suitable size to carry off some gold.
(2) A smaller portable crate for diamond heists
(3) Something to transport unconscious security guards.
(7) We don't want to have to do all that from scratch so let's set up some favourites as configurations:-
(8) We're nice robbers, we don't want the guard to suffocate, so we can add custom features (in this case air holes) to just one configuration.
(9) Finally we can drop one of each into an assembly with just a couple of clicks.
The instance tree is a mess as I've not used sub assemblies. Ooops.
Nested configurations are potentially mind-blowing in scope and are hands down my favourite update to OS since it started. So to any OS folks about a heartfelt thank you for all your inspiration and perspiration.
@philip_thomas, if you're still lurking on this thread is it possible to derive and configure parts using FS? Being able to select nothing but a sketch vertex and having a configured part appear from one custom feature would take this to the next level. (Our own company/user specific version of standard content if you will.)
Hope some of that is of interest to folks,
Cheers,
Owen Sparks.
HWM-Water Ltd
Take a look at https://cad.onshape.com/FsDoc/library.html#module-instantiator.fs -- it's exactly for bringing in configured part studios via FS.
We're also working on a FeatureScript-related improvement to make this type of thing even more flexible, but that's as much as I'll say until we release it
I'm really torn about the right solution here.... I went back and re-worked my crate so that I had each unique part in a separate part studio. This had the immediate effect of making each part much faster to recalc, and also it's a LOT easier to debug parts as the history is much shorter for each part.
The downside is that I don't have those universal variables which I know I could do with FeatureScript, but I'm just not there yet on hacking Onshape, I really want to get good at using the "the way it is" first.
The other very minor downside is that now I have to configure each part as I bring it into an assembly. Not that hard, but still an extra thing I have to do.
The more I think about this the more I think the ideal solution would be (for me) is this:
You create all of your parts in separate part studios, but your ASSEMBLY can have variables that you can reference in each part studio. This way when you bring a part into an assembly, it matches up a variable in that part with a variable in your assembly. If you assembly calls for #Width to be 30in, and the part has the same variable but it's currently set to 20in, it would be changed automatically.
Doing it this way would let me design other parts I could swap in, like a different lid (which I intend to do).
I'm essentially doing this now, but the variables live in each part, and if I'm not careful they can get out of sync.
Not to hijack my own conversation, but this is really getting me thinking about the right way to build this in Onshape:
This is a soundproof phone booth that I built (am building) out of 80/20. The next version is going to be parametric. I'm wondering what would be the best way to approach this one.... There's a lot going on here...
have a look, hope it helps. Sorry for the rambling, I didn't script it out
https://www.youtube.com/watch?v=vEGsP-ftDGM&feature=youtu.be
I just uploaded it and I'm on my way to a ball game, so can't wait to post this when it's done uploading. If you can't see it, give it a minute to process.
The text and audio are in spanish but i think you can figure it out
https://www.youtube.com/watch?v=aCjkPs2fGp0&t=505s
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
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
HWM-Water Ltd
Owen S.
HWM-Water Ltd
Actually it is an old FeatureScript (26 feb. 2017) and we will create a new release soon that will include:
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
https://youtu.be/iaCfeuH2TzI
Great video and thanks for the insight into your thought process, interesting stuff.
When assembly configs are released this will get easier!
In the mean time:-
(1) At the 5 minute mark you talk about "a configuration of a configuration". This is exactly one of the points I was intending to get across in my post above It's only for the Partstudio, but in the assembly you then call the "configuration of a configuration" so you drop all the parts in in one go. Demo file above.
(2) I agree on the simplicity of debug with one part per PS, but fundamentally disagree that this is what OS want you to do.
Geometrically related parts in one studio modelled off each other parametrically (for ease), and geometrically unrelated parts modelled separately (for performance) is the message we see from the devs.
(3) If you have some I'd love to see some photos of the cut parts and have an appreciation of how long they take to cut. (I'm in the early stages of learning a bit of CNC work.)
All the best,
Owen S.
HWM-Water Ltd
Here's a sample milling job:
https://www.youtube.com/watch?v=jsJ9xcFYMEM&t=165s
Normally when I make these crates each one takes about an hour from raw plywood to fully assembled. I cut them at a pretty aggressive pace on my machine because I'm more concerned about speed on these than edge quality.
I'll post a design update when I clean it up. Thanks again!
I'm rebuilding this in Onshape:
http://www.digitallyfabbed.com/#/x-table/
It's a little more complex than the crate. Basically the way it works is that there are two X's on either side. They're actually made of of 6 parts, 3 of which are unique. (I just laminate and glue them together.
Then there are three identical horizontal stretchers that are double laminated plywood (two parts mirrored) and there are two stretchers that are underneath the table top.
I started modeling it here:
https://cad.onshape.com/documents/c8e505f1a9fd03ee50066c27/v/8b066aeec9a070e09ebfa955/e/c1aa61811a031ea11a0a2413
Based on what I learned from the crate I followed your suggestion @owen_sparks (And others) in that I modeled the three parts that are unique, copied them and mated them together. This works great and totally makes sense to me.
Here's what I'm thinking is the right way to go from here:
Start a new part studio for the horizontal stretchers (the three on the bottom) and model those. Do the same for the top two stretchers, and one for the top. Then assemble it all in an assembly?
Does that seem like a good approach?
I can't imagine that making every part in one part studio is the right way to go here...
(1) Great video, thanks very much for putting it up.
Love the approach.
I was wondering how you'd set up the 3D toolpath. I was initially wondering if a 2.5D method would be "less good but good enough", but having recently made the switch myself from Vectric to a certain orange and grey themed bit of software I love what you've done there. Nice work sir.
Begs the question though of why not build it parametrically in that other software and have associative toolpaths?
(2) With regard to the bench.
Love it.
Some of the advice on the forum falls under "generally accepted good practice" and other times it's "here's what I like to do based on what I've learned so far".
Here is a dumbed down example:-
The whole thing is driven by one layout sketch:-
If we change the sketch all the parts rebuild in one go.
Here we have a depth of cut into the stringer driven by how thick the existing leg is using "up to face". Sure we could set up a variable, frig it to be global and design in an empty studio but that's waaaay harder and way more likely to introduce a numpty error if we forget to transfer a change to the other part.
Here we're creating a countersunk hole in the leg and a pilot hole in the stretcher in one feature, and driven from one sketch point:-
When projects get more complicated then by all means split them up, but for something with a low face count (simple extrusions like this) then I'd have no reservations about having a feature tree with 100 features generating 50 parts in one studio.
Add some configurations and we're really cookin'
Hope some of that is of interest,
Owen S.
HWM-Water Ltd
So I sorta did what you said but in a different way...
What I did was draw the X legs in one part studio and assembled them. Then for that stretcher that you drew I just used the sketch from the X legs that has the slots in a new part studio (IE I referenced the sketch from the original X legs). Now the two part studios are geometrically related and react to one another but to me it's a bit cleaner.
Where this is going to fall off the rails a tiny bit is that I'm still going to have to marry all of these parts back together as one model. I'm thinking I'll do that in an assembly. I will have to alter some variables across a few part studios to work together though...
https://cad.onshape.com/documents/c8e505f1a9fd03ee50066c27/w/f7f3d2dbcefb2407d741fc15/e/0c3c739c3cb1644ea30ba4c5
If you check the "Master Parts" tab I'm modeling all of the parts in context so that they have geometric relation to one another. There's lots of copies of parts that go into the "real" model so I'm just doing one of each in this part studio.
An example is that X leg. It's 3 unique parts, but it takes 6 parts total to make one leg. So what I'm doing is taking those parts for the X leg and making an assembly with them. I'm doing the same with the stretcher which is just two of the same part glued together. That stretcher is also an assembly.
Then, in the "master assembly" tab I'm marrying all of the sun assemblies together.
So far this seems to be working really well. It's not an obvious workflow at first, but it's working now. I've got more work to do to this table, I'll post if anyone wants to see when it's done.
I think this is the "right" way to do this. As someone who's an avid SketchUp user, I can't help but think that mashing up Part Studio and Assembly into one tab would be awesome.. But, I'm trying to learn the right way to do it here before I go re-inventing a product