几何尺寸与公差论坛------致力于产品几何量公差标准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, 08:38 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】declaring objects and setting objects

declaring objects and setting objects
hi all,
i should probably know this by now but i am still a little bit uncertain.
when to set and declare objects.
example #1 dim swapp as sldworks.sldworks is used to declare swapp, and at the begining of your macro you set it to "createobject("sldworks.application")" to get the handle on solidworks.
does that need to be done only once in the whole macro and then at the very end of the macro set it to nothing ?
example #2 say i am in a function and i have the handle on the active part now i call another function should i:
a. declare the part again and set it again in the function that i am calling or does it still know which part i am refering to.
b. pass the handle to the function i am calling then once the function is complete it will be passed back to the function it was called from.
i hope this is not too confusing. i am just a little bit undecided as to how often i need to declare objects.
any help is great. thanks
solidworks 2006,2007,2008,2009 (office premium.)
core 2 duo e6850 @ 3.00 mhz
window xp pro sp3 32 bit
ati firegl v7350
hi ben,
it all depends where you declare your objects.
if you declare them globally in your module or class then you only have to set them once (unless for example if you have your modeldoc and change the active document then you will have to re-capture the new modeldoc).
so for example #1
doing it once is sufficient
example #2: if your functions are in the same module/class and the part is declared globally thwn once should be sufficient.
hope this helped,
cheers,
--stav.
in this world i am nobody...
and nobody is perfect !!!
---------
solidworks office 2008 sp4.0
dell precision pws390
nvidia quadro fx 3450/4000 sdi
hi stavros,
thanks. that makes sence to declare something globally and have it work for all the functions, what about setting the part ?
i have a module in which i have 2 functions in the first function i am setting swapp and swpart then in that function i am calling the second function that is in the same module as the one that i am calling it from and in there i am setting swfeature but i get an error unless i set swpart again. but i did not need to set swapp again.
can you explain to me a little why i have to reset it or why i don't need to reset it ?
solidworks 2006,2007,2008,2009 (office premium.)
core 2 duo e6850 @ 3.00 mhz
window xp pro sp3 32 bit
ati firegl v7350
hi ben,
try making your subroutines or functions public
i.e
public sub mysub()
end sub
by doing so what you set within the sub will be visible for the whole macro and then you can re-use it.
let me know if it works.
--stav.
in this world i am nobody...
and nobody is perfect !!!
---------
solidworks office 2008 sp4.0
dell precision pws390
nvidia quadro fx 3450/4000 sdi
yes that works good, thank you.
solidworks 2006,2007,2008,2009 (office premium.)
core 2 duo e6850 @ 3.00 mhz
window xp pro sp3 32 bit
ati firegl v7350
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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



所有的时间均为北京时间。 现在的时间是 06:16 PM.


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