几何尺寸与公差论坛

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

【转帖】macro for loadunload of cosmosworks pro addin

[复制链接]
发表于 2009-4-13 12:36:22 | 显示全部楼层 |阅读模式
macro for load/unload of cosmosworks pro addin
here at our place of business we have many seats of solidworks office premium and one seat of cosmosworks advanced professional floating. the problem we have is setting engineers to use the cosmosworks designer seat by default from solidworks office premium and use the cosmosworks advanced professional when required. the add-in that comes with solidworks is duel role add-in. it runs both types of seats (cosmosworks designer and cosmosworks advanced professional) from the add-in depending on the order in the solidnetwork license administrator order which is stored only in the current_user hive. so i created a macro that allows the engineer to unload the add-in if loaded, switch the license order and reload the add-in so when ran (i.e.: macro button assignment) will with one click load that seat and another click unload that seat and return it to the license pool without exiting solidworks so that another engineer may have that seat. the only issue i've have so far is if that seat (cosmosworks advanced professional) is in use it automatically switches the requestor back to the cosmosworks designer seat without notification. so until i can have this code verify what seat is in use and add it into this code you'll have to have the engineer check the solidnetwork license administrator license usage tab. hopefully i'll get this figured out. heres the code below .... enjoy! maybe this will give some a good example of manipulating add-ins. let me know what you think.
see below
cadcam systems analyst
-solidworks office premium 2009 sp3.0
-solidworks simulation premium 2009 sp3.0
-solidworks flow simulation 2009 sp3.0
-2 cpu (fx-62), 2.0 gb of ram
-window xp pro sp2
-nvidia geforce 7950 gx2 (512mb) 6.14.11.6921
edited: 05/21/2008 at 04:39 pm by william crosby
correct me if i am wrong but wont the hkcu\software\solidworks\licenses\settings\license order tell you which add-in is currently loaded, as each time it the add-in is loaded/unloaded, it changes this order.
nope. the add-ins listed here in the "hkcu\software\solidworks\licenses\settings\license order" list what licenses are available to you based on the increments/features of the license manager. this hive entry is populated the first time you launch solidworks under this profile and it acquires its first seating from the license manager. this hive entry is controlled through the solidnetwork license administrator license order tab and this is only populated upon first launch and the order changed only by that user. the add-ins loading and unload have no affect on the order.
cadcam systems analyst
-solidworks office premium 2009 sp3.0
-solidworks simulation premium 2009 sp3.0
-solidworks flow simulation 2009 sp3.0
-2 cpu (fx-62), 2.0 gb of ram
-window xp pro sp2
-nvidia geforce 7950 gx2 (512mb) 6.14.11.6921
hey luke is there a way to tap into the api of the solidnetwork license administrator license usage to query a product seat free licenses count? i might be able to finish my code above if so.
update:
luke,
i almost forgot, i wrote code before using this prceedure and didn't think of using it, duh for me. i found out that the solidnetwork license administrator is not part of solidworks. its a separate object created by macrovision located in the "c:\program files\solidworks\solidworks\setup\i386" directory. so i need to use the output from "lmutil lmstat -c port@ipaddress -f cae_cwadvpro" and find if that feature is available then notify requesting engineer if not.
cadcam systems analyst
-solidworks office premium 2009 sp3.0
-solidworks simulation premium 2009 sp3.0
-solidworks flow simulation 2009 sp3.0
-2 cpu (fx-62), 2.0 gb of ram
-window xp pro sp2
-nvidia geforce 7950 gx2 (512mb) 6.14.11.6921
edited: 05/09/2008 at 11:28 am by william crosby
sorry never replied been really busy lately. like you said the license manager is totally separate from sw. have you managed to solve this yet? if not where are you up to?
luke,
i had to do some rewrite and still working out some code. i messed up in the prior code doing a load of add-in which i shouldn't causing a pull of seat when i just want to check its load see below. remember its not finished yet.
' check load status of add-in
addinstatus = swapp.loadaddin(swaddinname)
if addinstatus <> 0 then
so i changed that to a getaddinobject to test if the feature is available which means if true the add-in is installed if false it's not. now if you notice i have to parse the output text file that i have lmutil capture for usage of the seat. also another issue arose, which i thought and apologize for, that statement above "hive entry is populated the first time you launch solidworks under this profile" is incorrect. only when you run the solidnetwork license administrator and select the license order tab does this occur, which means the order is a random choice. so i had to put a piece of code to say if this hive entry doesn't exist, then create it for the reorder to occur. question, can i capture the output of the lmutil directly into an array instead of a text file (which i have to delete afterwards)? below is where i'm at and all i have to do is finish the parse the lmutil output for the arresults(14) line which determines the licenses available and in use. right now all i have it do is pop up.
see below
cadcam systems analyst
-solidworks office premium 2009 sp3.0
-solidworks simulation premium 2009 sp3.0
-solidworks flow simulation 2009 sp3.0
-2 cpu (fx-62), 2.0 gb of ram
-window xp pro sp2
-nvidia geforce 7950 gx2 (512mb) 6.14.11.6921
edited: 05/21/2008 at 04:39 pm by william crosby
yes you can redirect output straight to your program
help me understand here luke. why would i do this is c#? can't the vb ide do this natively or does it take creating class wrapper to capture shell output? i noticed that most use the creation of an output file, which seems crude. is it because (without creating new class objects) this is the only means of control of a non-registered dos object?
cadcam systems analyst
-solidworks office premium 2009 sp3.0
-solidworks simulation premium 2009 sp3.0
-solidworks flow simulation 2009 sp3.0
-2 cpu (fx-62), 2.0 gb of ram
-window xp pro sp2
-nvidia geforce 7950 gx2 (512mb) 6.14.11.6921
well the method i showed you does not create a class wrapper it simply starts a new process and redirects its output to your calling program. you can do this in vb.net also by doing exactly the same thing as shown in c#.
luke,
thank you for explaining. i'm still green in multi-code proging. what reference object/library from within vba is required to use .net or c# calls?
cadcam systems analyst
-solidworks office premium 2009 sp3.0
-solidworks simulation premium 2009 sp3.0
-solidworks flow simulation 2009 sp3.0
-2 cpu (fx-62), 2.0 gb of ram
-window xp pro sp2
-nvidia geforce 7950 gx2 (512mb) 6.14.11.6921
what you need to do in order to call a c# function from vba is to make a c# dll class library that is com registered, and then create a new object of that registered com and call its functions like you do for sw. not exactly a 2 line explanation so i shall write a topic on a6 when i get a bit of time.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-23 18:51 , Processed in 0.036543 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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