Author Topic: Loading .NET .dll In Startup Suite??  (Read 5726 times)

0 Members and 1 Guest are viewing this topic.

wannabe

  • Guest
Loading .NET .dll In Startup Suite??
« on: June 01, 2009, 02:21:11 PM »
Hi Everyone,

I'm just inquiring about the range of possibilities for auto-loading a .NET .dll when CAD starts up, potentially via a start up script, maybe?

This month's blog from Kean includes how to update the registry; I doubt this would apply to where I work with I.T permissions etc. Although I do plan to converse with the group CAD manager, and the CADD systems Manager to see if it would be possible.

However, I think for the time-being, just being able to load via  a start-up script would suffice for the one or two commands that are used frequently.

Any suggestions or ideas swampers currently implement?

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Loading .NET .dll In Startup Suite??
« Reply #1 on: June 01, 2009, 02:31:59 PM »
Hi,

You can call the command LISP function in the S::STARTUP function

(defun-q S::STARUP () (command "_.netload" "MyLibrary.dll") (princ))

If you have yet a S::STARTUP function (defined with defun-q) in your acad.lsp or acaddoc.lsp or MNL file, you can append the (command "_.netload" ...) expressions.

(setq S::STARTUP (append S::STARTUP '((command "_.netload" "MyLibrary.dll") (princ))))
Speaking English as a French Frog

wannabe

  • Guest
Re: Loading .NET .dll In Startup Suite??
« Reply #2 on: June 01, 2009, 02:39:17 PM »
Thanks for the riposte. I'll let you know how I get on and express further gratitude sometime tomorrow.

wannabe

  • Guest
Re: Loading .NET .dll In Startup Suite??
« Reply #3 on: June 02, 2009, 03:28:01 AM »
My ACAD2008.LSP file now appears as follows:

Code: [Select]
(if (not (=  (substr (ver) 1 11) "Visual LISP")) (load "acad2008doc.lsp"))


;; Silent load.
(princ)

(defun-q S::STARUP () (command "_.netload" "C:\Documents and Settings\39925NT\My Documents\Nick's CAD\CAD Dev\C#\dotNet Code\2.0 Files\PolyDist\CurveQuery\CurveQuery.dll") (princ))


However, my command is not being recognised.

I also tried the following:

Code: [Select]
(setq S::STARTUP (append S::STARTUP '((command "_.netload" "C:\Documents and Settings\39925NT\My Documents\Nick's CAD\CAD Dev\C#\dotNet Code\2.0 Files\PolyDist\CurveQuery\CurveQuery.dll") (princ))))

Also to no avail.

Can  you give me a slight nudge in the right direction, please? :-)


Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Loading .NET .dll In Startup Suite??
« Reply #4 on: June 02, 2009, 04:37:43 AM »
What happens if you change the folder delineators to \\ in place of \  ??
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Loading .NET .dll In Startup Suite??
« Reply #5 on: June 02, 2009, 04:46:59 AM »
perhaps try something like this ..

Code: [Select]
(defun kdub_startup ()
    (load "C:/PROG/LISP/MyStuff.LSP")
    (Command "_.netload"  "C:\\whatever\\kdub\\MyStuff.dll")
    (princ)
)
(if s::startup
    (setq s::startup (append s::startup (quote ((kdub_startup)))))
   ;; (defun s::startup () (kdub_startup))
    (defun-q s::startup () (kdub_startup) (princ))
)
« Last Edit: June 02, 2009, 08:39:32 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

wannabe

  • Guest
Re: Loading .NET .dll In Startup Suite??
« Reply #6 on: June 02, 2009, 05:24:32 AM »
Thanks for  your help, but my lack of LISP knowledge is inhibiting me here.

Here's how I amended my ACAD.LSP file to look:

Code: [Select]

;;;************************************************************************
;;;                                 STARTUP
;;;************************************************************************
(defun S::STARTUP ( / )
(princ)
(command "-vbarun" "Loadtimestamp")
(setvar "modemacro" (strcat

" <> D=$(if,$(getvar,pstylemode),COLOUR MODE,STYLE MODE)"))
(princ)
);endfun

(defun kdub_startup ()
    (load "C:/PROG/LISP/MyStuff.LSP")
    (Command "_.netload"  "C:\\Documents and Settings\\39925NT\\My Documents\\Nick's CAD\\CAD Dev\\C#\\dotNet Code\\2.0 Files\\PolyDist\CurveQuery\\CurveQuery.dll")
    (princ)
)
(if s::startup
    (setq s::startup (append s::startup (quote ((kdub_startup)))))
    (defun s::startup () (kdub_startup))
)


I wasn't sure what the second line of  your code did, the call to "load", so I left it for now.

Cheers.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Loading .NET .dll In Startup Suite??
« Reply #7 on: June 02, 2009, 06:35:40 AM »
Comment it out
or remove it
or replace it with a file you WANT to load at startup

added;
does the file appload ?
does the .dll file netload ?

« Last Edit: June 02, 2009, 08:35:54 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

wannabe

  • Guest
Re: Loading .NET .dll In Startup Suite??
« Reply #8 on: June 02, 2009, 07:17:26 AM »
"Appload"ing, responds with the following, via the command-line:

mmand: ; error: Invalid attempt to access a compiled function definition. 
You may want to define it using defun-q: #<SUBR @07bab938 S::STARTUP>

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Loading .NET .dll In Startup Suite??
« Reply #9 on: June 02, 2009, 08:59:00 AM »


So, what happens when you change the defun do defun-q


??
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

wannabe

  • Guest
Re: Loading .NET .dll In Startup Suite??
« Reply #10 on: June 02, 2009, 09:05:59 AM »
When I change the intial defun to defun-q it loads without command-line error; the command still does not load into AutoCAD, though.

The netload definitely works.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Loading .NET .dll In Startup Suite??
« Reply #11 on: June 02, 2009, 09:21:18 AM »
from above
Quote
dotNet Code\\2.0 Files\\PolyDist\CurveQuery\\CurveQuery.dll
you neeed to add 1 more \ between PolyDist and CurveQuery.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

wannabe

  • Guest
Re: Loading .NET .dll In Startup Suite??
« Reply #12 on: June 02, 2009, 10:28:44 AM »
Sorry for that, gents. Cheers for your input.

wannabe

  • Guest
Re: Loading .NET .dll In Startup Suite??
« Reply #13 on: June 02, 2009, 10:43:31 AM »
Arghhhhh. It's still giving me hassle.

What about a command that will netload the file, and I call that from within the ACAD.LSP.

Can anyone help me with that??

sinc

  • Guest
Re: Loading .NET .dll In Startup Suite??
« Reply #14 on: June 02, 2009, 02:42:30 PM »
I typically just do something like this in my acad.lsp file:

Code: [Select]
(command "._netload" "C:/MyDLLs/myprog.dll")
As a result of this thread, I tried replacing the above line with this:

Code: [Select]
(defun-q MYSTARTUP ()
    (command "._netload" "C:/MyDLLs/myprog.dll")
) ;_ defun-q
(setq S::STARTUP (append S::STARTUP MYSTARTUP))

I seemed to get the exact same results either way, with no difference I could discern.

wannabe

  • Guest
Re: Loading .NET .dll In Startup Suite??
« Reply #15 on: June 02, 2009, 04:03:27 PM »
I've got it working at home....first time.

The setup at work is a bit obfuscating with all the customisation folders and the recent migration to a new I.T setup. I'll talk to the guys higher up and see what I can come up with.

So cheers for all the help. On my way now, cheers. :-)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Loading .NET .dll In Startup Suite??
« Reply #16 on: June 03, 2009, 03:23:03 AM »
wannabe ,
just a thought .. are you netloading from a local drive or from a Network ??
I know your sample is from C:\\ .. BUT you posted that from home, yes ??
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

wannabe

  • Guest
Re: Loading .NET .dll In Startup Suite??
« Reply #17 on: June 03, 2009, 05:54:58 AM »
It's been a local drive on each location.

I think the errors may have occured due to the fact we have the ACAD2008 and ACADDOC2008 as-well-as another ACAD.LSP and ACADDOC.LSP in our customisations folder.

I reset the latter 2 the original files, and just updated the ACAD2008.LSP as per the load in Sinc's last post that specified the .dll on a local drive.

When I get chance I'll add your original code to this file and see what the return is.

Cheers all.


sinc

  • Guest
Re: Loading .NET .dll In Startup Suite??
« Reply #18 on: June 03, 2009, 10:13:58 AM »
You shouldn't modify ACAD2008.lsp or ACADDOC2008.lsp.  Those should be left untouched, and you should always use the default files, because Autodesk may make important changes to those files in service pack updates.

wannabe

  • Guest
Re: Loading .NET .dll In Startup Suite??
« Reply #19 on: June 03, 2009, 11:14:25 AM »
Thanks. Lesson learnt and error rectified.