.NET

Reply
Member
rowsinski
Posts: 5
Registered: ‎03-26-2012
Message 1 of 10 (684 Views)
Accepted Solution

AutoCAD 2011 .net Win X64 unknown command when run from script

684 Views, 9 Replies
03-26-2012 12:13 PM

Hi experts,

 

I developed a .net plugin that works fine both interactively any via a .scr file in a 32 bit environment.  It was build in Win7 X64 environment with VS2008 and .net 3.5.  But it fails to load the command when run from a script in my x64 environment.

 

I then built a sample project using the AutoCAD .net Wizard and get the same results using the "mycommand" and  "MySessionCmd".  It runs the script and commands correctly from VS debug mode with both dlls.

 

From my searching it appears multiple threads are involved or its a .net 3.5 issue.  First error I recieved after reinstalling 2011 was the thread issue that was resolved by adding "CommandFlags:smileyfrustrated:ession"

 

"Process Explorer" shows the dll loaded twice either interactively or via script run.

 

See notes below.  Any assistance would be much appreciated. 

 

Thanks,

 

Bob

 

       

// Application Session Command with localized name

        [

CommandMethod("MyGroup", "MySessionCmd", "MySessionCmdLocal", CommandFlags.Modal | CommandFlags.Session)]

       

publicvoid MySessionCmd() // This method can have any name

        {

           

String str = "Hello - MySessionCmd";

    

           

// Put your command code here

        }

 

script

 

FILEDIA 0

 PICKADD 1

PICKAUTO 0

CMDDIA 0

netload C:\Work\PDF_Batch\PDF_Creator\bin\Debug\PDF_Creator.dll

MySessionCmd delay FILEDIA 1 _QUIT N

 

 

C:\Progra~1\Autodesk\ACADM2~1\acad.exe /b "C:\Work\myprg\135788-0-23.scr"

 

Console Output

 

 

Loading Mechanical modules.....

Loading Modeler DLLs.

Loader application completed Regenerating model.

AutoCAD menu utilities loaded. Command: FILEDIA

Enter new value for FILEDIA <0>: 0 Enter BACKSPACE to interrupt script.

Command: PICKADD

Enter new value for PICKADD <1>: 1

Command: PICKAUTO

Enter new value for PICKAUTO <0>: 0

Command: CMDDIA

Enter new value for CMDDIA <0>: 0

Command: netload Assembly file name: C:\Work\PDF_Batch\PDF_Creator\bin\Debug\PDF_Creator.dll

Command: MySessionCmd Unknown command "MYSESSIONCMD".  Press F1 for help.

 

 

i haven't actually come across batch processing at all. (the bottom line in your initial post reminded me of problems i encountered when i used the plug-in template for the first time, always with the manual 'netload' though.)

Distinguished Contributor
VB_Autocad_guy
Posts: 136
Registered: ‎07-24-2009
Message 2 of 10 (681 Views)

Re: AutoCAD 2011 .net Win X64 unknown command when run from script

03-26-2012 12:33 PM in reply to: rowsinski

Why don't you have the DLL load on startup via registry flag.

(http://forums.autodesk.com/t5/NET/Windows-7-NET-Security-Permission/m-p/3383589)

 

Then skip the script thing. If you have the dll loaded twice yikes? that just sounds messy. No clue why.

 

I know whenever I have problems with commands not loading it's been one of two things. 

 

The DLL was erroring out on a line somewhere in the startup or it's been a duplicate named command.

 

Put a editor.writemessage statement to make sure your DLL is loading properly. 

 

 Public Sub Initialize() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize
editor.WriteMessage("<<[Finished Initializing] ClassAutocad2011.dll is Successful >>" & Environment.NewLine)
end Sub 

 

 

No expert here, may be out of my league. But I thought I'd chime in here and get the conversation going.

 

Good luck. 

 

 

 

Member
rowsinski
Posts: 5
Registered: ‎03-26-2012
Message 3 of 10 (671 Views)

Re: AutoCAD 2011 .net Win X64 unknown command when run from script

03-26-2012 01:32 PM in reply to: VB_Autocad_guy

Thanks for the quick response.

 

I just tried adding the message.  It does display but then same result.  I really want to run my command in a batch mode from the command line and not interactively.  Is there a better way than the script calling the .net command.

 

I have loaded before on startup. no joy there either.

 

Command: netload

Assembly file name: C:\Work\PDF_Batch\PDF_Creator\bin\Debug\PDF_Creator.dll

<<[Finished Initializing] MyCommand.dll is Successful >>

Command:

 MyCommand

 Unknown command "MYCOMMAND".  Press F1 for help.

Valued Contributor
FFlix
Posts: 95
Registered: ‎11-15-2011
Message 4 of 10 (665 Views)

Re: AutoCAD 2011 .net Win X64 unknown command when run from script

03-26-2012 02:17 PM in reply to: rowsinski

hi bob

 

the problem sounds vaguely familiar and i recall watching autodesk's intro on .net programming a milllion times. in there was a mentioning of the different command names and values depending on the different sections of autodesk's .net plug-in, which i understand you're using. in vs, double click mycommands.vb/mycommands.resx in the solution explorer to have a look and possibly change any values of the associated command names.

 

slightly embarassing that now after telling you about it, i can't actually find the lab, not without downloading the corresponding .zip files anyway, but i think it was one of the two under 'autocad .net labs' here http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=1911627.

 

i might be completely wrong with regards to your problem, but perhaps you find the labs interesting, if nothing else.

 

felix

Member
rowsinski
Posts: 5
Registered: ‎03-26-2012
Message 5 of 10 (658 Views)

Re: AutoCAD 2011 .net Win X64 unknown command when run from script

03-26-2012 03:00 PM in reply to: FFlix

Hi Felix,

 

I tried that link.  Was not found and took me to main AutoCad page.

 

I found a bunch of references to uninstalling .net  and re-installing from autoCAD media.  Was that it.

 

 

Valued Contributor
FFlix
Posts: 95
Registered: ‎11-15-2011
Message 6 of 10 (641 Views)

Re: AutoCAD 2011 .net Win X64 unknown command when run from script

03-26-2012 05:14 PM in reply to: rowsinski

i apologise, i tried the link i posted and get the same result, 'page not found'. after many frustrating tries, i think the reason is that the punctuation at the end of my sentence has somehow become part of the addess and corrupted the link. this should work better: http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=1911627

sorry again

Member
rowsinski
Posts: 5
Registered: ‎03-26-2012
Message 7 of 10 (637 Views)

Re: AutoCAD 2011 .net Win X64 unknown command when run from script

03-26-2012 06:32 PM in reply to: FFlix

Felix,

 

Thanks.  Got them.  Will review.  Loaded trial copy on different system same results.

 

Do you ever try and batch process with AutoCAD without GUI.  Best way?

 

Thanks

 

Bob

Valued Contributor
FFlix
Posts: 95
Registered: ‎11-15-2011
Message 8 of 10 (631 Views)

Re: AutoCAD 2011 .net Win X64 unknown command when run from script

03-26-2012 07:29 PM in reply to: rowsinski

i haven't actually come across batch processing at all. (the bottom line in your initial post reminded me of problems i encountered when i used the plug-in template for the first time, always with the manual 'netload' though.)

Member
rowsinski
Posts: 5
Registered: ‎03-26-2012
Message 9 of 10 (615 Views)

Re: AutoCAD 2011 .net Win X64 unknown command when run from script

03-27-2012 04:07 AM in reply to: FFlix

Felix,

 

I have found a workaround.  If I run my script throught ScriptPro via its command line options.  It finds the .net command and runs it.  Will need to see how ScriptPro is able to manage the threads and find the command.

 

But even a lisp routine I was given to use as a base failed when initiated from a script in x64 Win 7.

 

All work fine in Win 32 environments.

 

Thanks for all your help.

 

Cheers,

 

Bob

Distinguished Contributor
VB_Autocad_guy
Posts: 136
Registered: ‎07-24-2009
Message 10 of 10 (601 Views)

Re: AutoCAD 2011 .net Win X64 unknown command when run from script

03-27-2012 11:22 AM in reply to: rowsinski

Awesome glad you got it working!

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!