HiCAD-API (Application Programming)

C#

HiCAD can process several programming languages suitable for the writing of API scripts, e.g. Visual Basic, Delphi und C#.

To ensure an efficient support, the ISD uses (for current and future versions of its scripts) the program-ming language C# ("C sharp"). The writing of API scripts in C# is taught in a separate training course.

 

Example

Below you will find an example of a short script written in C#:

// <debug />

// <assembly>API/System.Data.dll</assembly>

using System;

using ISD.Scripting;

using ISD.CAD.Data;

using ISD.BaseTypes;

using ISD.CAD.Contexts;

using ISD.CAD.Creators;

namespace Api_Scripts

{

    class Script : ScriptBase

    {

        [Context(typeof(UnconstrainedContext))]

        public static void Main()

        {

            // Create Cuboid

            BlockCreator bc = new BlockCreator();

            bc.Length = 100;

            bc.Width = 150;

            bc.Height = 50;

            bc.Name = "Block";

            Part prt = Context.CreatePart(bc);

        }

        public static UnconstrainedContext Context

        {

            get { return BaseContext as UnconstrainedContext; }

       } 

    }

}

A source file of C# is saved with the file extension "cs", e.g. 'Example script.cs'. This script, which can be called directly in HiCAD, creates a new cuboid with the name “Block”, and the dimensions 100x150x50.

 

API in HiCAD

In HiCAD, the API can be used in different ways, e.g. as an individual script, as an auxiliary tool or even as an independent application. It depends on the respective usage in which way the API is deployed.

An individual script can be best compared to a HiCAD macro. Like a macro, an individual script can be called manually in HiCAD (CTRL+J), and will then perform one or several working steps. If required, a menu can be programmed in a script, prompting the user to enter particular data.

Example of an individual script: Automatically count all coloured surfaces of all parts in a drawing and save the result to the attributes of a selectable element. If the script is frequently used, a button for the script start can be added to the toolbar:

API scripts can be inserted into the feature log of a part.

A Plugin is a supplement to a computer program. Generally, plugins are developed in order to expand the functionality of a program, or to make it more versatile. Plugins require a Host application; they cannot be operated independently. In HiCAD, plugins can be generated with the help of the API. Plugins have the extension .dll and not .cs. The plugins are activated and deactivated via the Settings menu:

API

An example of such a plugin is the “Metal Construction" plugin that is included in HiCAD. This plugin allows a creation of sketches for Metal and Steel Engineering constructions that can be used later for an accurate placing of beams and profiles in the construction. Plugins are used in HiCAD like docking windows, which can be placed somewhere on the screen or attached (“docked”) onto the border of the screen. If desired, Plugins can also be defined as “Fly-outs”, which means that the plugin will be shown when you move the cursor over the retracted, hidden menu.

API

APIFUNC ObjectsMacro Technique