几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » SolidWorks二次开发
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-12, 06:55 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】macro to figure open area of a face

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
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】inserting and mating parts in an assembly yang686526 SolidWorks二次开发 0 2009-04-12 06:43 PM
Draft International Standard Iso/dis 10303-108 huangyhg ISO standards 2 2007-01-02 12:55 PM
En 14350-1:2004 (e) huangyhg ISO standards 0 2006-12-02 04:36 PM


所有的时间均为北京时间。 现在的时间是 11:44 AM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多