Netloading dll from a script file for batch processing

Netloading dll from a script file for batch processing

BKSpurgeon
Collaborator Collaborator
2,519 Views
4 Replies
Message 1 of 5

Netloading dll from a script file for batch processing

BKSpurgeon
Collaborator
Collaborator

Hi folks

 

this is giving me a lot of grief:

 

  1. I have Scprit Pro 2.0 (if you don't know, it's a nifty little tool which allows you to batch process drawings.
  2. I have some 40 drawings or so.
  3. I need to open all the drawings. Then Netload a dll, and to then run a custom command which I created in the dll called "WTD" - the name is not important.

 

But somewhere along the line it is stuffing up.

 

IT is working neither with Core Console, nor with the setting which actually opens autocad.

 

Here is my scriptfile:

 

;Loading the .Net module
(command "netload" "C:\\TopSecret\\MyProject.dll")
;
; Run the command
(command "WTD")

 

and here is the log file output that is produced: 

 

------------------------------------------------------------------------------
------------------------------------------------------------------------------
Project file: 	
Drawing file: 	C:\TopScret\Drawing1235.dwg

Processed by Computer: 	BARNABAS-PC

User name   : 	BKSpurgeon

[ Status summary ]
Done


A u t o C A D   C o r e   E n g i n e   C o n s o l e   -   C o p y r i g h t   A u t o d e s k ,   I n c   2 0 0 9 - 2 0 1 3 . 
 
 R e g e n e r a t i n g   m o d e l . 
 
 P r e s s   E N T E R   t o   c o n t i n u e : 
 
 
 
 C o m m a n d : 
 
 C o m m a n d : 
 
 
 
 C o m m a n d : 
 
 C o m m a n d :   ( c o m m a n d   " n e t l o a d "   " C : \ \ t o p secret \ b i n \ D e b u g \ M a i n . d l l   a s s e m b l y . 
 
 C o m m a n d :   n i l 
 
 
 
 C o m m a n d :   ( c o m m a n d   " W T D " ) 
 
 W T D   U n k n o w n   c o m m a n d   " W T D " .     P r e s s   F 1   f o r   h e l p . 
 
 
 
 C o m m a n d :   n i l 
 
 
 
 C o m m a n d :   _ q u i t 
 
 
 
 

 

I am at a complete loss. your assistance is much appreciated.

 

 

rgds

 

BK

 

0 Likes
2,520 Views
4 Replies
Replies (4)
Message 2 of 5

Dale.Bartlett
Collaborator
Collaborator

Instead of

(command "WTD")

try

(C:WTD)

 

Further to that, to debug scripts just type the lines from your script as responses in AutoCAD. You probably already know that...

Dale




______________
Yes, I'm Satoshi.
Message 3 of 5

norman.yuan
Mentor
Mentor

To me, it looks like the DLL loading is failed, thus the "unknown command" message.

 

Firstly, your scrip shows the DLL to be loaded is 

 

"C:\\TopSecret\\MyProject.dll"

 

But the log says:

 

"C:\\TopSecret\bin\debug\main.dll"

 

Please notice that not only the file name is different, but also the "\" used in the file path is not consistent: it should all be doubled.

 

Could this be the problem (sometimes a typo makes debugging very difficult before you finally see the obvious typo).

 

Then assume you have correct file path/file name, but still have the same issue, then another possible cause could be code security, unless you use core console with AutoCAD2013: the DLL has to be loaded from trusted folder. You can first try to do exactly what the script does manually with AutoCAD running stet by step, to make sure you do not have security message pops up when loading the same DLL and the command can be called manually. However, even your manul process works, your automated core console may still have issue because it may run under different AutoCAD profile. In term of trusted code location, you may want to place your dll into location always trusted by AutoCAD, such as "C:\ProgramData\Autodesk\ApplicationPlugins\"

Norman Yuan

Drive CAD With Code

EESignature

Message 4 of 5

Balaji_Ram
Alumni
Alumni

Hi

 

1) In addition to above suggestions, can you also try setting SECURELOAD to 0 in the script file.

 

If the load is failing due to trust issues, this should help identify it.

 

2) Also, you can try running AccoreConsole as a stand-alone application from the AutoCAD's install path.

 

In its prompt, try to load the dll and run the command. That should help debug the issue.

 

3) Ensure that the .Net plugin that you are trying to load does not reference acmgd.dll. 

I am sure you know this already, but wanted to remind.

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

Message 5 of 5

BKSpurgeon
Collaborator
Collaborator

thank you all.

 

i am in the process of debugging. Will post full solutions when i get it right for the benefit of future users. In the mean time, norman has identified a potential source of error: the path names. in truth i edited the path names before publicly posting etc and i forgot to do it the same.

 

the core console does not allow for cutting and pasting file names so this should come in extremely handy for you all:

 

http://stackoverflow.com/questions/131955/keyboard-shortcut-to-paste-clipboard-content-into-command-...

 

https://www.autohotkey.com/

 

and here is my script file: which allwos you to paste into console windows: 

 

; Redefine only when the active window is a console window 
#IfWinActive ahk_class ConsoleWindowClass

; Close Command Window with Ctrl+w
$^w::
WinGetTitle sTitle
If (InStr(sTitle, "-")=0) { 
	Send EXIT{Enter}
} else {
	Send ^w
}

return 


; Ctrl+up / Down to scroll command window back and forward
^Up::
Send {WheelUp}
return

^Down::
Send {WheelDown}
return


; Paste in command window
^V::
; Spanish menu (Editar->Pegar, I suppose English version is the same, Edit->Paste)
Send !{Space}ep
return

#IfWinActive

 

remember to save as a .ahk extension and save it to either you documents folder or to the place where the executable file is running from. then run program. it's a very handy utility.

 

 

debegging with core console

like the folks here had suggested, i tried debugging manually. the netloading is working. but when i used Script Pro 2.0 and a script file (see above) - with a refined path name, it was throwing an error: "Error while reading log file" which i will fully investigate a post here for the benefit of future readres.

 

rgds

 

BK

 

 

rgds

BK

0 Likes