TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Peter Guappa on July 27, 2012, 09:52:17 AM

Title: Netload and run dll at startup
Post by: Peter Guappa on July 27, 2012, 09:52:17 AM
I'm completly stuck  :-(

I have a dll (mytest.dll) with a commandmethod ("cmdtest")

When I paste (command "_netload" "C:\\Test\\mytest.dll") and (command "cmdtest") in the commandline it works!

When I create a lisp , appload and run it , it works!
(defun c:test ()
  (command "_netload" "C:\\Test\\mytest.dll")
  (command "cmdtest")
)


But when I copy these 2 lines into my S::STARTUP, it doesn't work !!! (everything else in my startup works just fine)

Offcourse I can use the lisp, but I want the dll to be loaded and RUN AT STARTUP without an extra command


I've been surfing theswamp whole night, tried almost everything I could find, but nothing seems to work.

Any suggestions? (did I do something wrong building it???)

Thanks !!!!!
Title: Re: Netload and run dll at startup
Post by: Lee Mac on July 27, 2012, 10:25:19 AM
http://www.theswamp.org/index.php?topic=31173.0;all (http://www.theswamp.org/index.php?topic=31173.0;all)
Title: Re: Netload and run dll at startup
Post by: Peter Guappa on July 27, 2012, 10:54:59 AM
Thx Lee,

Tried it, but I just can't manage to get it to work, maybe I'm just to tired and not thinking clearly.
Title: Re: Netload and run dll at startup
Post by: ElpanovEvgeniy on July 27, 2012, 11:00:08 AM
Another way to check the files lying in a folder and run them all.
Includes menu lisp. Net arx
Title: Re: Netload and run dll at startup
Post by: Peter Guappa on July 27, 2012, 11:10:29 AM
I used the lisp from Lee's link, and everything is imported into the registry.

When I run 'cmdtest' in the commandline it works, so I would think adding (command "cmdtest") in my startup, the dll would run automatically, but it doesn't. Or am I confused?

Title: Re: Netload and run dll at startup
Post by: BlackBox on July 27, 2012, 11:20:01 AM
Peter,

DLL's need only be NETLOADed once per session.

If you're not going to demand load assemblies (http://through-the-interface.typepad.com/through_the_interface/2006/09/automatic_loadi.html), you can do so manually using ACAD.lsp... Following your stated assembly location:

Code - Auto/Visual Lisp: [Select]
  1. ;;;--------------------------------------------------------------------;
  2. ;;; Load multiple .NET assemblies from ACAD.lsp
  3. ((lambda (loadList)
  4.    (terpri)
  5.    (foreach dll loadList
  6.      (if (findfile dll)
  7.        (command "._netload" dll)
  8.      )
  9.    )
  10.    (terpri)
  11.  )
  12.   '(
  13.     "Test\\mytest.dll"
  14.  
  15.     ;; <- Other assemblies here
  16.  
  17.    )
  18. )
  19. ;;;--------------------------------------------------------------------;
  20.  

** Code assumes "C:\\" is included in Support File Search Path (SFSP).

Not sure what your .NET CommandMethod does, but if it needs to run on each drawing opened, consider adding your (command "cmdtest") call to your ACADDOC.lsp file.

HTH
Title: Re: Netload and run dll at startup
Post by: Peter Guappa on July 27, 2012, 11:47:32 AM
Thx RenderMan,

but no luck.

I still have to launch it by typing cmdtest or (command "cmdtest")
Title: Re: Netload and run dll at startup
Post by: BlackBox on July 27, 2012, 11:51:39 AM
Thx RenderMan

You're welcome.  :-)

... if it needs to run on each drawing opened, consider adding your (command "cmdtest") call to your ACADDOC.lsp file.

but no luck.

I still have to launch it by typing cmdtest or (command "cmdtest")

 :wink:
Title: Re: Netload and run dll at startup
Post by: Peter Guappa on July 27, 2012, 07:17:25 PM
....... I give up   :-(
Title: Re: Netload and run dll at startup
Post by: BlackBox on July 27, 2012, 07:38:44 PM
Peter,

Either add your Command call to ACADDOC.lsp, or append it to S::Startup. Note the differences in the startup sequence:


Consider the load order at startup:
linky (http://www.blog.cadnauseam.com/2008/09/01/what-is-loaded-at-autocad-startup-and-when/)

Quote
A. CUI files loaded:
1. Enterprise
2. Main
3. Partials to Main
4. Partials to Enterprise

B. acad*.* files loaded:
1. Files listed in acad.rx
2. acad2009.lsp
3. acad.lsp  <--  
4. acad2009doc.lsp
5. acaddoc.lsp
6. acad.dvb

C. CUI-associated MNL and LSP files loaded:
1. Enterprise named MNL
2. Enterprise loaded LSP and MNL
3. Main named MNL
4. Main loaded LSP and MNL
5. Partials to Main named MNLs
6. Partials to Main loaded LSPs and MNLs
7. Partials to Enterprise named MNLs
8. Partials to Enterprise loaded LSPs and MNLs

D. Startup suite files loaded

E. Startup routines run:
1. AcadStartup() called (AutoCAD startup)
2. AcadDocument_Activate() called (Drawing startup)
3. (S::STARTUP) called
4. SCR loaded from /b switch

I don't know how better to assist you, without more information.

Title: Re: Netload and run dll at startup
Post by: Kerry on July 27, 2012, 07:46:21 PM

Peter,
Is your command meant to run in the Application once at startup
or
run in each document.
??

Title: Re: Netload and run dll at startup
Post by: Peter Guappa on July 27, 2012, 08:10:38 PM
Thx for trying to help me out.

I tried everything, erased everything, rewritten everything,rebuid dll, renamed dll,.........

I also build different dll's for AutoCad 2010,2011,2012,2013 32bit/64bit and every dll loads just fine.

When I launch these dll's from the commandline (with cmdtest or (command "cmdtest"))  on different Autocad versions.... no problem.

But adding it to acad.lsp or acaddoc.lsp or S::startup or a lisp that is being loaded from a *.mnl file with the same name as my cui(x), AutoCad just won't run it automatically.

And what is very strange: everything I try in AutoCad, I also try in Bricscad (of course with other refferences in the dll), and it works 100% in BC.

I don't think there's is much more you can do for me,

Thanks for your help and time, I really appreciate it.


If I ever find the solution, I will post it.


Title: Re: Netload and run dll at startup
Post by: Peter Guappa on July 27, 2012, 08:13:06 PM
@ Kerry,

Run in each document.

The dll I'm using is a tooltip that shows extended data, attached to points, when hovering the mouse.
Title: Re: Netload and run dll at startup
Post by: BlackBox on July 27, 2012, 08:39:53 PM
I'm not sure that I know enough about .NET to help more at this time.

As I understand it, once the assembly has been loaded into the application, it is available for the life of the session. However, to the best I my limited experience, for the CommandMethod call to not work with either AcadDoc.lsp, *.mnl, or S::Startup, that suggests to me that something about the document object hasn't been instantiated, that the code requires to execute.

Perhaps additional Exception handling is needed? Again, more information (the source code that's been rewritten?) is needed.

Sorry I cannot be of further assistance.
Title: Re: Netload and run dll at startup
Post by: Peter Guappa on July 30, 2012, 08:07:08 AM
FIXED

I encountered another problem and noticed that QAFLAGS was allways set to 1.

A 3th party lisp-routine we use on all our pc's running Autocad was causing this.

Removed it, set qaflags to 0 and now everything runs smoothly.  :-) :-) :-)