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

calling a sw addin from exe-file
hello,
i've written a sw-addin in vb.net, which makes any calculations from assemblies and parts.
my dll has many functions, they do not need solidworks and a few functions, where i need informations from sw (calculations, etc.)
so, i decide to rewrite my addin to a standalone .net-exe and connect it at start-time to sw to get my informations. but now, the calculations takes a extreme long time. for the same calculations, where the dll needs milliseconds, needs the exe-module minutes. it's crazy
can i do any changes to improve the performance for an outstanding vb.net-exe-file?
or another question. is it possible to implement a dll in solidworks, which makes my calculations (in milliseconds) and call this dll from a exe-modul? and when it is possible, how can i do this?
thanks for any help.
best regards,
juergen
i have written a simple c# example of loading in dlls and calling a method (with no parameters for simplicity of the example)
hi luke,
thanks for your quick answer. i can't test your sample, because i work with visual studio 2005 not 2008, but i step through your code and i unterstand, that my first idea is not so easy to realize.
hmm, but what other possibility do i then have from outside of solidworks to improve my performance? when my exe starts i make a
getobject(,"sldworks.application") and work with the returned handle.
the rest of the exe works exactly in the same way as in the previous version as sw addin, but it tooks a extreme longer time to do the same steps (calculate the dimension and the point of origin of all components).
generally, why tooks it a longer time for the exe as for the addin?
juergen
what happens if you create the solidworks application this way:
private oswapp as sldworks
'-----
'-----
private sub startapp()
oswapp = new sldworks
if oswapp is nothing then
msgbox("could not start solidworks.")
exitapp()
end if
oswapp.visible = true
end sub
this launches a solidworks process, separate from your .net process.
also, making the sw application visible is necessary for certain api functions to work correctly. (see the api help file.) perhaps that is all you need to do--make the sw app visible.
hi matthew,
thanks for your answer.
i tried your your solution, but it makes no difference, whether i launch a new solidworks process with
---- oswapp = new sldworks (i made sw visible)
or i launch a existing process with
---- oswapp = getobject(, "sldworks.application")
it tooks a significant longer time, to do same calculations as in my addin. maybe my calculation is too complex for running out-of-process. i calculate the dimension of components by stepping through all faces and tesselations.
i think, i should split my application in two parts. one part is the addin for solidworks. that makes any calculations and put the values in a text-file. the other part is the exe-application. that reads the text-file and work with this values.
if i do so, is there a possibility to start my sw-addin from the exe-application?
regards,
juergen
you can load the addin using sldworks::loadaddin but not directly call a function, that would take some trickery if required
hi luke,
thanks for your info. to load the addin is very helpful.
so, i can open a window in the startup-phase of the dll and the user can decide, which function he wants to use.
to start the function directly, without the need of a extra windows is the most excellent solution. is it very trickery?
regards, juergen
well as there are no direct ways for the exe and dll to communicate you need to create an common intermediate point of any form that both programs monitor.
for example, a very simple raw method would be to have your dll monitor a special folder on the harddrive for files to be created within it. your exe could create a plain text file whenever it wants the dll to run a certain function, and if your dll is monitoring this folder it will pick up that file and know to act.
there are much more efficient communication methods other than this but that is just a very crude simple way i can think of.
yes, that sounds good.
i can write a setup-routine, where i install the exe and dll in one step in the same program-directory. then i decide to exchange informations about a fix special file in that program directory. therefore my user has no need to configure anything. it runs complete in the background.
luke, thats really a good idea and isn't much complicated to design. that's another important reason
many, many thanks to you luke.
regards, juergen
hi luke !
i can't connect to your's exams.
please give we direct links or u redireck link for me please
many thanks u!
hainc
hi all !
now, i want to create a file has the extention is exe,
when running this file, i can call addinsw into .new program
if you have any examples, please send to me
thanks for help @@
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】dll学习(资料收集) huangyhg vc编程 0 2008-05-17 09:24 PM
最难清除木马 Dll木马揭秘 huangyhg vc编程 0 2007-04-12 07:31 PM


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


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