.NET

Reply
Member
andreiim
Posts: 5
Registered: ‎03-25-2013
Message 1 of 2 (261 Views)

Best practice with MVVM

261 Views, 1 Replies
07-08-2013 04:37 AM

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?

ADN Support Specialist
fenton.webb
Posts: 352
Registered: ‎07-24-2007
Message 2 of 2 (208 Views)

Re: Best practice with MVVM

07-11-2013 09:33 AM in reply to: andreiim

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)





Fenton Webb

Developer Technical Services

Autodesk Developer Network


Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.