TurboCAD Forums

The Ultimate Resource for TurboCAD Knowledge

Register
 
All posts discussing pricing or where to buy TurboCAD will be deleted.

Better structured SDK and more detailed and up-to-date SDK documentation
Read 2824 times
* October 01, 2010, 07:35:35 AM
The .NET SDK should be updated so that it provides interfaces for:
1) regen methods
2) tools

Take a C# SDK example for a tool or regen method. What immediately become obvious is that the tool/regen method does not derive from an interface/class which should be called ITurboCADTool/IRegenMethod for example.
Thus a TurboCAD plug-ins' developer would know what method he/she is supposed to implement, what functional variety is provided by the plug-in.

What is the current situation:

namespace TCCSharpTool
{
   public class SampleTool
   {
           public SampleTool()
      {
      }

      public string Description
      {
         get
         {
            return "TurboCAD CSharp Tool";
         }
      }

                ...
         }
}

Look at this code of a sample TurboCAD tool written in C#. The whole source code for the tool is available usually at:
%PROGRAMFILES%\IMSIDesign\TCWP17\SDK\Samples\C#\Tools\TCCSharpTool\TCCSharpTool\

... or whatever directory you have chosen to install TurboCAD at.

Do you notice that the property named "Description" jumps out of nowhere. I mean, how could I know that I should implement such property to give my TurboCAD tool a description? This style of programming leads me back to procedural programming where you cannot put constraints and requirements to implement a given functionality. This code would have looked much better if written this way:

public interface ITurboCADTool
{
      public string Description { get; }

      ...
}

namespace TCCSharpTool : ITurboCADTool
{
   public class SampleTool
   {
           public SampleTool()
      {
      }

      public string Description
      {
         get
         {
            return "TurboCAD CSharp Tool";
         }
      }

      ...
         }
}

Having the requirement to inherit from the ITurboCADTool interface, I would know that my tool has a Description property and I could derive from it. This way, I won't even have to read documentation to know what functionality a given tool offers for implementation.

What steps have I taken to find out what is the functionality offered by a tool:

1) Get a sample SDK project and see all of the tool class' methods. All of these methods just come out of nowhere.
2) Next, I needed to support  I searched for whether there are additional methods offered by an SDK tool since I needed some specific behavior. I found out what I was looking for in the SDK documentation - a tool could offer even greater level of control through IToolEvents interface which is only available for C++ COM plug-ins. Probably, I should manually import and wrap this COM interface in a .NET class and thus take control of these additional tool events provided by IToolEvents interface in .NET environment.
I haven't found how to listen to the events offered by the IToolEvents COM interface in .NET environment. Neither I have found a sample nor I have found a way to "guess" the method's names. By saying "guess" I mean translating the IToolEvents COM interface methods to .NET tool class' methods.

Look again in the sample tool's code:

namespace TCCSharpTool : ITurboCADTool
{
   public class SampleTool
   {
      public int GetToolInfo
      (out object CommandNames,
       out object MenuCaptions,
       out object StatusPrompts,
       out object ToolTips,
       out object Enabled,
       out object WantsUpdates)
      {
         string[] SCommandNames = new string[NUM_TOOLS];
         string[,] SMenuCaptions = new string[NUM_TOOLS,2];
         string[] SStatusPrompts = new string[NUM_TOOLS];
         string[] SToolTips = new string[NUM_TOOLS];
         bool[] BEnabled = new bool[NUM_TOOLS];
         bool[] BWantsUpdates = new bool[NUM_TOOLS];

         

         CommandNames = SCommandNames;
         MenuCaptions = SMenuCaptions;
         StatusPrompts  = SStatusPrompts;
         ToolTips = SToolTips;
         Enabled = BEnabled;
         WantsUpdates = BWantsUpdates;

         return NUM_TOOLS;
      }

      

      const short NUM_TOOLS = 1;
   }
}

How could a developer know that MenuCaptions is actually a rectangular array of strings?

out string[,] this looks much much better.
_______________________________________________

The SDK needs:
1) Better interfaces for plug-in collaboration with the main application.
2) More detailed and up-to-date SDK documentation - C++/C#/VB.NET/script languages.
3) More sample SDK projects. If there is a C++ COM sample project for something specific, let there be a C#/VB.NET/VC++.NET equivalent.

Logged