|
macro to figure open area of a face
in case you haven't read my post in the general section i will explain my situation. i work for a company that designs parts for pet food extruders. this will only apply to two components that we make. we have set blanks that we cut various shapes into and i am needing to get solidworks to figure the open area and populate a custom property which will drive a note in a drawing.
i talked with my var today and they told me that this wasn't as simple as making an equation to drive a custom property, that it would require a very in depth macro. i don't know and really don't have the time learn right now. if anyone could lead me in the right direction, it would be great.
thanks in advance,
brian - cswa
dual 20" monitors
dell t5400
intel xeon e5405 @ 2.00 ghz
4 gb ram / 3 gb switch
windows xp
nvidia 1700 w/ certified driver
solidworks 2009 sp 1.0
autocad mech desktop 2005
a couple of questions:
1. you are really only interested in the area of the cutout, right?
2. is the cutout generated by a single sketch?
3. is there always only one closed contour? like you don't have multiple open areas?
if the above conditions are true, there may be a way to get a simple macro embedded into an equation to figure this area for you, although you'd have to sort of meet it halfway.
you would have to re-use the sketch that generates the cutout to create a planar surface, then you would have to give that surface body some specific name. the macro embedded in the equation would go look for the surface, get its area, and put that value into a custom property.
i'll get you eh steve, if it's the last thing i dooooo!
brian,
have a look at the attached file. it uses a surface feature and some very simple vba in an equation to get the area of the cutout. the equation is:
"openarea"= part.featurebyname("mysurface").getbody.getfirstface.getarea * "scalefactor"
it works by looking for a feature called "mysurface". to work properly, mysurface must be a "planar surface" feature that is defined by the boundary of the cutout. if your cutout is a single sketch then you can use the sketch to define the surface. if you use multiple sketches/cuts to create the cutout you'd have to select all the edges of the cutout to define the surface. you can even put chamfers or whatever on the edges afterward and they won't affect the surface as long as they come after the surface in the feature tree.
of course, sw reports the area in square meters, so you need a scale factor to convert to whatever you really want it in. i used 1e6 to convert to mm^2.
if your cutout has multiple open areas then the macro becomes a bit more complicated. not much, but a bit. the code would also have to be embedded into a custom property because it would need multiple lines, limiting the functionality to sw2009 or later.
i'll get you eh steve, if it's the last thing i dooooo!
to answer your questions:
1. yes, i am only interested in the open area of the cut out
2. yes, with the exeption that some times we create the cutout and then do a
circular pattern.
3. no, with the inserts that we are making there will be anywhere from one-four shapes cut into the insert, as far as the wearplates, there can be any number of shapes cut into it.
i am attaching two sample files. please don't distribute.
brian - cswa
dual 20" monitors
dell t5400
intel xeon e5405 @ 2.00 ghz
4 gb ram / 3 gb switch
windows xp
nvidia 1700 w/ certified driver
solidworks 2009 sp 1.0
autocad mech desktop 2005
thanks, i changed a few things to make it work no matter how many shapes were cut into the face.
brian - cswa
dual 20" monitors
dell t5400
intel xeon e5405 @ 2.00 ghz
4 gb ram / 3 gb switch
windows xp
nvidia 1700 w/ certified driver
solidworks 2009 sp 1.0
autocad mech desktop 2005
mind if i ask what you ended up doing?
i'll get you eh steve, if it's the last thing i dooooo!
add these equations:
1 "scalefactor"=1550.003 (this is to convert it to inches)
2 "facearea"= part.featurebyname("mysurface").getbody.getfirstface.getarea * "scalefactor"
3 "openarea"=.7344-"facearea" (i alread know what the area of the surface is before the shapes are cut into it)
create the default (blank) part
insert offset surface 0.000" on the face that you want to configure the open area for
name it "mysurface"
hide"mysurface" and roll it back
create your cut of the shape/shapes you want in the blank
roll "mysurface" forward
"remember that equation #3 needs to be "openarea"=.????-"facearea", where .???? is the starting area of the face that you are cutting the shape out of."
i also have a custom property named "openarea", and i will use this to drive a note on my drawings automaticlly.
brian - cswa
dual 20" monitors
dell t5400
intel xeon e5405 @ 2.00 ghz
4 gb ram / 3 gb switch
windows xp
nvidia 1700 w/ certified driver
solidworks 2009 sp 1.0
autocad mech desktop 2005
if you know the weight, density, and thickness of the original blank, you can calculate open area from the weight of the final product.
yeah, i tried that one already in the other thread.
i'll get you eh steve, if it's the last thing i dooooo!
ok, i tried to link the new custom property which is driven by the equations to a note on the drawing with no luck. i will upload images of my problem when i get to work in the morning. what is happening is when i try to link the custom property to the note it gives me the text that is in the value/text expression field instead of the evaluated value field. i don't know what i am doing wrong.
brian - cswa
dual 20" monitors
dell t5400
intel xeon e5405 @ 2.00 ghz
4 gb ram / 3 gb switch
windows xp
nvidia 1700 w/ certified driver
solidworks 2009 sp 1.0
autocad mech desktop 2005 |
|