Monday, February 18, 2013

solidworks: variable global to assembly

lately i've taken to the "make rough sketch of parts on paper, then in solidworks, make solidworks assembly, then add all the features at the correct location with the help of CAD" method of making things. With the lasercutter especially, something you want is that if you decide to change your stock (or you measure incorrectly), you can change the thickness of  your features all at once.

This puzzled me a while back, because if you try to enter an "equals" sign into the extrude feature to create a variable like you would when dimensioning a sketch, you get an error:

error to the left
Uh, so...? What? You can't use equations in features? That's dumb.
Thankfully that's not the case. Turns out you input whatever for the feature and click the check mark. Then you go back and double-click on that feature (in this case boss-extrude) in the feature tree,


 which pops up the "extrude" feature dimension on your model, 


which you can then double-click to edit. And insert an "=" sign to create a variable.

Okay, so that's great. But this variable only exists within this one file. How do I get it into other files?
I thought there would be some assembly feature, but instead solidworks does this with good ol' fashioned text files.

Tools > Equations > Export




There's the "material_thickness" variable I created as = 12.5, and then there's the "first extrude = material_thickness" which is sort of optional for exporting. All my features are meant for lasercutting so I may as well export the fact that the first extrude-boss should be of "material_thickness" thickness.

(That is, when I import in the future, I have to make sure the new file has an extrude already, or else the "equation is invalid" error will pop up because it's like "wtf there is no extrude thickness dimension to link to in this file". So probably best actually not to export that extrude thickness dimension, or else un-check that equation when importing).

This saves it as equations.txt

Then I create a new part (for demo purposes) and import the equations file:

And voila, everything has carried over.

NOTE: Watch your units! As you can see, the equations file doesn't have units. So if you export as 12.5 mm in one document and then import in a document that is set to work in inches, you get a 12.5 in part.

If I want to edit the variable, I have to do so externally. At the bottom of Tools > Equations, there's an "open file" button that I use and it pops open the equations.txt file in the default text editor (in this case notepad)




Voila, I can now edit that thickness and just hit "rebuild" (ctrl-b) 



and the new dimension is propagated in all the files.

If you want, going through this post as a slideshow may be flow better:
https://picasaweb.google.com/113942194695013581888/SolidworksGlobalVariable


2 comments:

  1. I have a part that I made a drawing for. I now have edited the part. When I go back to the drawing, the drawing doesn't update with the change of the solid model. The two are linked because when I right click on the part in an assembly and click "open drawing" the drawing opens. Any suggestions?. . Thank you for any help.

    Solidworks

    ReplyDelete