|
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 @@ |
|