I'm on a project that will have about a dozen of commands. Where should I put them?
For each viewmodel I have a view and a main model.
My commands only show the views, so it would make sense to be in the View part of the MVVM. But, if I put the command in the view's codebehind, autocad would instantiate the view for the whole lifetime of the document and I don't want this.
If I create a separate class for each command using a naming system like NameOfTheViewCommand, then I would practically have an MVVMC pattern, where C stand for command.
Or maybe I should create a class which includes all my commands and nothing else?
Or maybe all these approaches are wrong and there's already a well-established pattern known only by Autocad .NET experts and one of these gurus is kind enough to provide a best practice guide for this matter?
in terms of AutoCAD, we have a 3 level split...
1) Dependency on acad.exe
- define your commands that rely on the AutoCAD UI here
2) Dependency on accore.dll
- define your commands that only require the command line to work
3) Dependency on acdb19.dll
- define your DWG manipulate code here
I recommend that all of your commands define a UI version and a non-UI version - e.g. LAYER (UI) -LAYER command line only. Your UI version should be in a DLL which references acmgd.dll (acad.exe), acdbmgd.dl (acdb19.dlll and accoremgd.dll (accore.dll)
I recommend that all of your -LAYER defined commands should be in a DLL which references accoremgd.dll, acdbmgd.dll
I recommend all of your DB related functionality reside in a DLL which references acdbmgd.dll.
Doing this will ensure:
1) Your commands can be scripted
2) Your commands will work on the cloud
3) Your code will work in other non-AutoCAD DWG hostable applications (RealDWG enabled)
Access a broad range of knowledge to help get the most out of your products and services.
Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.
Upgrading to a 2015 product? Make sure to check these out 1st!