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

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   SolidWorks二次开发 (http://www.dimcax.com/hust/forumdisplay.php?f=111)
-   -   【转帖】how to grey out a customized macro button (http://www.dimcax.com/hust/showthread.php?t=4769)

yang686526 2009-04-12 09:20 PM

【转帖】how to grey out a customized macro button
 
how to "grey out" a customized macro button
hi,
i have created a macro that i use to save a drawing file in a pdf format and i assigned it to a custom button on my toolbar.
i am interested in "greying out" the button so it only works when a drawing file is open and not a part or an assembly. is there any way to do this? that is, i don't want to be able to accdently click on the button when i am working on a part
it is possible, but pretty difficult, to gray out the button. i would recommend placing the button on some toolbar that is only visible when you are in a drawing. i would also advise to add code (if you haven't already) that checks what type of document is active at the beginning of the macro and to exit if the document is wrong...
if application.sldworks.activedocument.gettype <> swdocdrawing then exit sub
i'll get you eh steve, if it's the last thing i dooooo!
thanks josh,
that will work fine. i ended up writing
set swapp = createobject("sldworks.application")
set model = swapp.activedoc
if model.gettype <> swdocdrawing then
msgbox ("this can only be used in drawing files.")
exit sub
end if
quick


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