Author Topic: VB.NET use the same FORM for AutoCAD, ZwCAD and BricsCAD  (Read 3411 times)

0 Members and 1 Guest are viewing this topic.

FELIX

  • Bull Frog
  • Posts: 242
VB.NET use the same FORM for AutoCAD, ZwCAD and BricsCAD
« on: August 18, 2015, 11:51:04 PM »
I have a project that uses a Form and need to generate a DLL for AutoCAD other for ZwCAD and one for the BricsCAD.
Currently I made a copy for each but when I change a FORM have to update other forms to create the DLLs.
Its use the same FORM to create DLLs 3 CADs for compiling only one at a time or create the same DLL for 3 CADs?
I'm using VB.NET Express 2010!
OK.

MickD

  • King Gator
  • Posts: 3637
  • (x-in)->[process]->(y-out) ... simples!
Re: VB.NET use the same FORM for AutoCAD, ZwCAD and BricsCAD
« Reply #1 on: August 19, 2015, 02:55:16 AM »

Your best bet is to use conditional compilation directives in each of your code files.

eg.
Code - C#: [Select]
  1. #if Bricscad
  2. //ODA
  3. using Teigha.Runtime;
  4. using Teigha.DatabaseServices;
  5. using Bricscad.ApplicationServices;
  6. using Bricscad.EditorInput;
  7. using Teigha.Geometry;
  8. using _AcRx = Teigha.Runtime;
  9. using _AcAp = Bricscad.ApplicationServices;
  10. using _AcDb = Teigha.DatabaseServices;
  11. using _AcGe = Teigha.Geometry;
  12. using _AcEd = Bricscad.EditorInput;
  13. using _AcGi = Teigha.GraphicsInterface;
  14. using _AcClr = Teigha.Colors;
  15. using _AcWnd = Bricscad.Windows;
  16.  
  17. #elif AutoCAD
  18. using Autodesk.AutoCAD.Runtime;
  19. using Autodesk.AutoCAD.ApplicationServices;
  20. using Autodesk.AutoCAD.DatabaseServices;
  21. using Autodesk.AutoCAD.Geometry;
  22. using Autodesk.AutoCAD.EditorInput;
  23. using Autodesk.AutoCAD.GraphicsInterface;
  24. using Autodesk.AutoCAD.Colors;
  25. using Autodesk.AutoCAD.Windows;
  26. using _AcRx = Autodesk.AutoCAD.Runtime;
  27. using _AcAp = Autodesk.AutoCAD.ApplicationServices;
  28. using _AcDb = Autodesk.AutoCAD.DatabaseServices;
  29. using _AcGe = Autodesk.AutoCAD.Geometry;
  30. using _AcEd = Autodesk.AutoCAD.EditorInput;
  31. using _AcGi = Autodesk.AutoCAD.GraphicsInterface;
  32. using _AcClr = Autodesk.AutoCAD.Colors;
  33. #endif
  34.  

you will also need to set the compilation symbols in your project Properties/Build page.

So, in your autocad build you would define AutoCAD and in the Bricscad project you would define Bricscad.

The trick is now to develop your code in one project and 'link' these files to the other cad projects - https://msdn.microsoft.com/en-us/library/windows/apps/jj714082(v=vs.105).aspx

Linking the form files can be a bit tricky at times but you will get it.

hth
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Jeff H

  • Needs a day job
  • Posts: 6150
Re: VB.NET use the same FORM for AutoCAD, ZwCAD and BricsCAD
« Reply #2 on: August 19, 2015, 04:13:16 AM »
The new shared projects in visual studio 2015 automate "linking files" and to make it easier to handle.
Shared projects can be created with .NET 2.0 and up.

http://www.theswamp.org/index.php?topic=49961.0

n.yuan

  • Bull Frog
  • Posts: 348
Re: VB.NET use the same FORM for AutoCAD, ZwCAD and BricsCAD
« Reply #3 on: August 19, 2015, 09:35:54 AM »
My understanding is that the said form or forms should be the same (the looks, the events raised by user interactions) in AutoCAD, ZwCAD and BricsCAD. So, the form(s) should be in its own project (DLL) so that it can be shared among the 3 products. However, in order to share the View (the form), you should completely separate the business process/data from the view, so that the view only plays the role of presenting data and taking user interaction (and passing the interaction to business layer).

You may want to look into the MVC pattern. That is, the View(form) project only includes Views that can be shared, maybe the data Model (if the 3 products can share the same data model). Most likely, the Controller will be different for each products. In the shared View project, you can define a IController interface, and then implement 3 different Controllers, and so on.

FELIX

  • Bull Frog
  • Posts: 242
Re: VB.NET use the same FORM for AutoCAD, ZwCAD and BricsCAD
« Reply #4 on: August 19, 2015, 04:49:54 PM »
Thank you very much.
I had forgotten conditional compilation directives.
OK.
OK.

CADbloke

  • Bull Frog
  • Posts: 342
  • Crash Test Dummy
Re: VB.NET use the same FORM for AutoCAD, ZwCAD and BricsCAD
« Reply #5 on: August 23, 2015, 07:30:32 PM »
There are a few ways to do this with varying degrees of complexity. See...

http://www.theswamp.org/index.php?topic=49298.msg543961#msg543961
http://www.theswamp.org/index.php?topic=41868.msg497358
http://www.theswamp.org/index.php?topic=49961  (Jeff already linked this above)

Norman's advice is well worth heeding - put your common things in the common place and the specific things in their specific place. I'm not a fan of multiple DLLs but that's just me and I don't think it's necessarily clever given that is how DLLs work.

====== EDIT October 2, 2015 ====

I'm having another crack at this at https://github.com/CADbloke/CodeCloner

This time around I'm focusing on propagating source code to destination Projects which control all their own build settings. Apparently some (all) of us though that 72 builds in one project was a little unmanageable </YesItWas>.

There's an extensive readme there so I won't duplicate it here. I'd love to hear any thoughts, suggestions, WTFs.
My earlier works left here to serve as a warning for others..and also because there are a couple of useful tips in there.
...
« Last Edit: October 02, 2015, 08:01:16 AM by CADbloke »