Hello,
I have this command defined in a .Net dll.
If I start Autocad in a normal manner (dbl-click on the desktop icon), I netload the dll, type the defined command and all is fine.
OTH, if I start Autocad programatically (via a console program), the dll Netloads OK, but when I type the defined command, Autocad says "Unknown command".
Even stranger, I get the same reaction for CLASSICLAYER which is of course a native command.
Acad 2012, Win XP SP3.
Anybody seen this before?
Thanks in advance,
alex
Never started ACAD programatically so not encountered that. But I have encountered a similar situation with Office2007. Start it normaly and all the addins were loaded and working. Start it programatically and, although addins looked to be loaded, for them to work I had to disable / re-enable them....
Hi,
>> OTH, if I start Autocad programatically (via a console program), the dll Netloads OK, but when I type the defined command,
>> Autocad says "Unknown command". Even stranger, I get the same reaction for CLASSICLAYER which is of course a native command.
Verify your support paths (and also your AutoCAD profile name) between both modes of starting AutoCAD. Any differences?
- alfred -
Hmm, interesting, although one should know a lot more about the internals of both programms in order to be able to verify the similarities and causes of the phenomenon.
And I do not know enough.
Thanks'
alex
Alfred,
No diffs, as far as i can see, same profile, same paths.
But, I saved the profiles and there are some differences.
I saved them (only the differences) in two files I attach.
Look at them with a diff tool, maybe it will tell you something. I couldn't understand one iota.
Anyway, why should a profile cause a native command to disappear?
As I posted, the CLASSICLAYER command is 'unknown' to Acad, although the autocomplete list shows it.
And why should a .NET dll load OK but Acad doesn't recognize the commands defined in it?
And all this happens only when starting programmatically.
Could it be something along the lines of StormyC's suggestion above?
Thank you,
alex
Hi
>> Anyway, why should a profile cause a native command to disappear?
Different paths making some tools not to load (not to be found)...
..or different handling of demandloading ... ==> you might verify the setting of sysvar DEMANDLOAD.
And I tried now with AutoCAD 2015 to start with the desktop icon and in another way to start CMD.EXE, changed the current directory to that of AutoCAD 2015 and started the ACAD.EXE one time without the parameters and the other time with the same parameters as the start-icon.
When starting only the ACAD.EXE I also see a difference ... that it asks for MNL's to be loaded as they are outside the trusted paths.
When I do the same with parameters AutoCAD runs without any differences (at least I can't see any).
I also can't find any commands that are not working then (tried CLASSICLAYER as you mentioned it)
So for now: did you try to start AutoCAD with the same parameters as your start-icon on the desktop has?
And one additional question: why don't you use the default options in Visual Studio to "start program" (in project settings) for debuging?
- alfred -
Hi, Alfred
>>Different paths making some tools not to load (not to be found)...
This is so, but it's not the problem here (at least not all the problem): If I manually load any custom .NET dll, AutoCAD doesn't recognize the commands defined in it, unless Acad can't find its own components.
.>>.or different handling of demandloading ... ==> you might verify the setting of sysvar DEMANDLOAD.
DEMANDLOAD is the same in both cases.
>>So for now: did you try to start AutoCAD with the same parameters as your start-icon on the desktop has?
Yes, nothing changed.
>>And one additional question: why don't you use the default options in Visual Studio to "start program" (in project settings) for debuging?
This is not about debugging, the program's purpose is to start AutoCAD.
I'd better explain: We need to start Acad from a user-selected (at runtime) start directory.
This worked fine with A2004 and A2008 (actually we were using a simple batch file, but this approach failed with A2012).
So I tried to build a simple console app, which does its job, except for the above.
Thanks,
alex
Hi,
>> but this approach failed with A2012)
I have tried that now with AutoCAD 2012 on Win7x64 and at least I can load my assemblies (and have the commands active), I can also start CLASSICLAYER.
So that might now be a difference between your WinXP and my Win7, it might be a difference between 32bit and 64bit, it might be a difference or our AutoCAD service packs (I'm just surprised that I have not installed a SP for my AutoCAD 2012, well, I don't need it on that (new) system so often).
BUT, when starting the ACAD.EXE from the CMD.EXE, I get some errors reported like (translated from German):
Assembly can't be loaded. Error-details:
Autodesk.AutoCAD.Runtime.Exception: eDuplicateKey at Autodesk.AutoCAD.Runtime.CommandClass.AddCommand(ICommandLineCallable ca, MethodInfo mi)
at
Autodesk.AutoCAD.ApplicationServices.AutoCADApplicationHolder.Initialize(Assembly assembly)
at
Autodesk.AutoCAD.ApplicationServices.ExtensionLoader.ProcessAssembly(Assembly assembly)
If you start AutoCAD from CMD.EXE, do you have similar messages in the command-line?
- alfred -
Hi Alfred,
>>I have tried that now with AutoCAD 2012 on Win7x64 and at least I can load my assemblies (and have the commands active), I can also start CLASSICLAYER.
You mean you actually did it with a batch file? I never succeeded with A2012. Could you post the code?
>>If you start AutoCAD from CMD.EXE, do you have similar messages in the command-line?
No, this works fine on my machine, no errors. (I suppose you mean opening a command window and typing the Acad.exe path.)
But maybe it makes sense, Win7 being more distanced from old DOS than WinXP.
Thanks,
alex
Hi,
>> You mean you actually did it with a batch file? I never succeeded with A2012. Could you post the code?
That's the content of a BAT-file I just tried, no problem with CLASSICLAYER:
c:
cd "\Program Files\Autodesk\AutoCAD 2012 - Deutsch"
acad.exe /p AN_DevNET
- alfred -
Hi,
Could you try this on your machine?:
[YourDriveForCADwork:]
cd [AnyJobDirectory]
"c:\Program Files\Autodesk\AutoCAD 2012 - Deutsch\Acad.exe"
If it works, when you try opening a dwg, AnyJobDirectory should be the default in the dialog (on condition sysvar REMEMBERFOLDERS is 0).
Thanks,
alex
Hi,
I started AutoCAD 2012, set REMEMBERFOLDERS to 0 and closed it
I modified my BAT file to the following content:
c:
cd "\TEMP"
"\Program Files\Autodesk\AutoCAD 2012 - Deutsch\acad.exe"
Then I started this BAT ==> command _OPEN brings me to "C:\TEMP" as the current folder.
- alfred -
Hi Alfred,
Thank you for the answer and for your time.
Your answer got me thinking and I decided I can't believe that all this is due to differences between OS's or Acad versions, and that it must be something much simpler (it usually is, you know). It may be due to AutoCAD and Windows distancing themselves from MS DOS (batch files etc.), but then why should it run on Win7 and not on XP?
I have an idea I'll test after the holiday here, and I'll report on the results in a couple of days.
Regards,
alex
Hi Alfred,
As promised:
I found the problem was historical: the shortcut to the bat file used to launch AutoCAD 2004 was in fact a .pif file, probably inherited from earlier days.
It was copied and modified to launch AutoCAD 2008 and worked without any problems, but it failed to work on AutoCAD 2012. The reasons are unclear at this time, as Microsoft says .pif files should work under XP.
Anyway, replacing the .pif with a regular shortcut to the .bat file solved the problem.
There remain, though, a few minor unclear items:
1. If we use the the 8.3 DOS format ("C:\Progra~1\...") to launch Acad (in the batch file), any form of the LAYER command is command line only, we can't launch the dialog; this does not happen if we use the full quoted path ("C:\Program Files\...") to launch Acad.
2. No matter how we launch Acad, after we Open a drawing the crosshairs freeze (or sometimes are missing alltogether) and only a REGEN (from the menu - the command line is frozen too) restores the input system to normal. This does not happen on the initial drawing (Drawing1) or on any subsequent drawings (after performing the Regen on the first drawing opened).
It seems that AutoCAD does not perform the usual Regen after opening the first drawing and waits for the user to do it.
Thus, there is no more need to use a .NET program to launch Acad, the batch file approach works well enough, the plug-ins load ok, etc.
Of course the whole exercise raised some questions which remain unanswered.
Maybe some Autodesk guru will care to comment on this.
Regards,
alex
Hi,
great that you come back with what you found out, thank you!
And yes, I never ever would have thought about pif, too historical 😉
>> 1. If we use the the 8.3 DOS format
Is there any reason you need 8.3 file naming? At least I see that as not safe: if you use such a short name on different systems the "Program~1" might point to everything else, but not "C:\Program Files".
>> 2. No matter how we launch Acad, after we Open a drawing the crosshairs freeze
Is your application automatically loaded and has some type of form or palette. If so: check one time to start AutoCAD without loading your application and see if the cursor freezes too. I had a case that a control on a palette (which was automatically loaded) grabed the focus.
- alfred -
Hi Alfred,
You answered before I had time to edit a bit my answer (not important).
There is no reason to use the DOS format (although in this case it points to the right file and launches Acad).
I just think it very strange that the file name format should cause differences in AutoCAD's behaviour.
About the crosshairs problem: there is no connection with my app. Even on a clean launch, without any apps loaded, it happens.
Thanks,
alex
Hi,
>> Even on a clean launch, without any apps loaded, it happens.
Well, than I would try now:
and if all failes, try with another Windows user account so it starts with a brand new profile.
Good luck, - alfred -
i think this is the problem about File Path. there are 2 different dynamic paths: DllPath and ExePPath, which may varies according to the way they are loaded . i suggest 2 things you check:
1. make sure that your program had really netload the dll correctly. sometimes it may fail.
2. the main app(which shells the autocad and netloads the dll) is in the same dir as the acad.exe and yourAddIn.dll.
and you can put all the relative files in the same dir as acad.exe, then check the result, if still the same problems, we look for other bugs.
may this be helpful to you!
Can't find what you're looking for? Ask the community or share your knowledge.