几何尺寸与公差论坛

 找回密码
 注册
查看: 686|回复: 0

【转帖】from macro to add-in

[复制链接]
发表于 2009-4-13 10:58:36 | 显示全部楼层 |阅读模式
from macro to add-in
i have a macro that i have created with a userform and a set of modules. i would like to "convert" the macro to an add-in for solidworks. using vb express 2008 and the sw add-in included in the api sdk, i am able to create a new project. how can i bring the macro into the project so i can compile it as a dll add-in? should i export each module and userform individually, or is there a way to import it collectively? my understanding of add-ins are weak at best, so please be gentle.
thanks!
to defeat the wheat, go against the grain.
tom,
the macros that are created in solidworks use vba. vba and vb.net are similar, but it won't be a direct conversion. i do believe that there is a way to launch a macro from a solidworks add-in. i think that was discussed somewhere on this forum about a month or so ago. i know it's not what you are after, but i just wanted to throw it out there. sorry i couldn't be of much more help than this.
tony szuta
cswa, cswp, cswp-smtl
i start conversions by exporting modules from macro and importing into vb (i'm still on vb6!). then i write a class module for the addin functionality.
i think vb.net has a wizard that will convert exported modules for you.
i have a project for converting macros to vb6 addins. it's getting a bit dated, but may still have useful info for you.
tony, thanks for the info. do you know which thread it is? there's been a few, and it is hard to pinpoint which one. i will keep looking and working with your idea.
roland, i have made the project by following your steps, such as dragging the modules and form into the project and creating a class module with the implement code. however, my form is not being shown when i click on it. it has the code, but not the form. i wonder what i am missing? may i email you the code and you can tell me what i need to do?
thanks!
to defeat the wheat, go against the grain.
here is how you can call a solidworks macro:
retval = swapp.runmacro ( filepathname, modulename, procedurename )
tony szuta
cswa, cswp, cswp-smtl
how does the form look in you project pane (where the modules are listed)? does the form show as a "form" or as a "designers" object?
instead of drag-drop, try adding the form using "file --> import".
roland, i have exported each model as .bas files and the form as .frm and .frx files. to compile as i dll, i am hoping to use visual basic express 2008. this does not have a file>import option per se, though it does have a project>add existing item function. however, it doesn't directly import the form, though it can import the modules. is there a way to convert the form to vb.net?
to defeat the wheat, go against the grain.
i am looking at the swaddin and i am starting to understand how it works. i was initially frightened and intimidated by creating an add-in, but i believe it is starting to sink into my skull. i will let ye know if there be any skullduggery afoot.
ahhrrr! (why am i a pirate? one piece!)
to defeat the wheat, go against the grain.
edited: 06/13/2008 at 03:41 pm by tom fosler
quick
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-24 02:04 , Processed in 0.034802 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表