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

using enum to turn off modify dimension box
hi,
i have created a macro to create a hole in a part. however, the macro stops everytime a dimension is added to the hole as the modify dimension box appears.
i know that turning off "input dimension value" system setting solves this problem but i want to be able to turn off this feature only when the macro is running.
so far i am trying:
public enum swuserpreferencetoggle_e
swinputdimvaloncreate = 1
end enum
sub main()
set swapp = application.sldworks
set part = swapp.activedoc
set swselmgr = part.selectionmanager
set swmodext = part.extension
swapp.setuserpreferencetoggle swinputdimvaloncreate, false
i get no error message but it does not change the system value.
i saw that sldworks::setuserpreferencetoggle is void in the api. is that the problem? i have a feeling it is that i don't understand how to enumerate parameters.
also, a general follow up question. how are the numbers picked when enumerating lists of only one or two settings? in api example there is sometimes only one item in the list but it might be set to 18, for example.
thanks for any help.
assuming you are using sw > 2005 or so, all of those enums are automatically included by default when you edit a macro. they are in the solidworks 200x constants type library. what you are doing when you add
public enum swuserpreferencetoggle_e
swinputdimvaloncreate = 1
end enum
is you are overriding the enumeration that is already included in your project! get rid of that enumeration and your code should work fine. if you'll type "swinputdimvaloncreate" all in lower case and then move the cursor away from the line, the vba editor will change it to the proper capitalization. that's how you can know that vba already knows what the value of that constant is supposed to be. by the way, by adding that enumeration at the top, you are saying that swinputdimvaloncreate is equal to 1. this is not the case. the correct value for that constant is 10. by using 1 instead, you are actually toggling display of arc center points (swdisplayarccenterpoints).
a lot of the examples in the help were created before swconst.tlb was included by default with all macros, so they include an abbreviated enum at the beginning just using the values that will be used in the code. however, swconst pretty much includes every single enum and constant listed in the help.
i'll get you eh steve, if it's the last thing i dooooo!
hi josh,
when i stopped using the enumeration state, it worked.
just the statement
swapp.setuserpreferencetoggle swinputdimvaloncreate, false
is all i needed.
i looked in the object browser and found the constants library, thanks.
if i did an enumeration with 10, what would happen (i suppose i'll try this)? i am still unclear if it would turn it on or off.
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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



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


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