API Quick Start



Visual CADD™ says "Hello World!"

The code samples below show how to say "Hello World!" using the Visual CADD™ API with C++, C#, Visual Basic .NET, VBScript, JScript, and AutoIt.  These samples are so simple they only use 5 lines of functional code, all the rest are comments.  They show how easy it is to use the Visual CADD™ API to make an add-on tool perform a simple task in Visual CADD™.



C++ C# VB.NET VBScript JScript AutoIt
// C++ to say Hello World!
//   lines starting with a // are comments
void WINAPI HelloWorld(char* szDllCommandLine)
{
    // used for error returns from the API
    short iError;	
	
    // construct a point object
    Point2D pt;
 
    // set the point to the origin
    pt.x = 0.0;
    pt.y = 0.0;
 
    // set text string
    VCSetTextString(&iError, "Hello World!");
 
    // place the text in the drawing at the given point
    //   -1 means in the drawing, other options 
    //   can place it in a symbol definition
    VCAddTextEntity(&iError, -1, pt);
 
    // zoom all to see the text
    VCZoomAll();
}
// C# to say Hello World!
//   lines starting with a // are comments
public class HelloWorld
{
    // construct a Visual CADD object
    static VCadd32.Automation vcadd = new VCadd32.Automation();
 
    public static int Run(string szDllCommandLine)
    {
        // construct a point object
        VCadd32.VCPoint2D pt = new VCadd32.VCPoint2D();
 
        // set the point to the origin
        pt.X = 0.0;
        pt.Y = 0.0;
            
        // set text string
        vcadd.SetTextString("Hello World!");
 
        // place the text in the drawing at the given point
        //   -1 means in the drawing, other options 
        //   can place it in a symbol definition
        vcadd.AddTextEntity(-1, pt);
 
        // zoom all to see the text
        vcadd.ZoomAll();
 
        return 1;
    }
}
' VB.NET to say Hello World!
'   lines starting with an apostrophe are comments 
Public Class HelloWorld
 
    ' create Visual CADD object
    Shared WithEvents vcadd As New VCadd32.Automation
 
    Public Shared Function Run(ByVal str As StringAs Integer
 
        ' create point object
        Dim pt As New VCadd32.VCPoint2D
 
        ' set the point to the origin
        pt.X = 0.0
        pt.Y = 0.0
 
        ' set text string
        vcadd.SetTextString("Hello World!")
 
        ' place the text in the drawing at the given point
        '   -1 means in the drawing, other options 
        '   can place it in a symbol definition
        vcadd.AddTextEntity(-1, pt)
 
        ' zoom all to see the text
        vcadd.ZoomAll()
 
        ' return
        Return (True)
 
    End Function
 
End Class
' VBScript to say Hello World!
'   lines starting with an apostrophe are comments
 
' create Visual CADD and point objects
set vcadd = CreateObject("VisualCADD.Application.9")
set pt = CreateObject("VisualCADD.Point2D.9")
 
' set the point to the origin
pt.x = 0.0
pt.y = 0.0
 
' set text string
vcadd.SetTextString "Hello World!"
 
' place the text in the drawing at the given point
'   -1 means in the drawing, other options 
'   can place it in a symbol definition
vcadd.AddTextEntity -1, pt
 
' zoom all to see the text
vcadd.ZoomAll
 
' release Visual CADD and point objects
set vcadd = Nothing
set pt = Nothing
// JScript to say Hello World!
//   lines starting with a // are comments
 
// create Visual CADD and point objects
var vcadd = new ActiveXObject("VisualCADD.Application.9");
var pt = new ActiveXObject("VisualCADD.Point2D.9");
 
// set the point to the origin
pt.x = 0.0;
pt.y = 0.0;
 
// set text string
vcadd.SetTextString("Hello World!");
 
// place the text in the drawing at the given point
//   -1 means in the drawing, other options 
//   can place it in a symbol definition
vcadd.AddTextEntity(-1, pt);
 
// zoom all to see the text
vcadd.ZoomAll();
; AutoIt script to say Hello World!
;   lines starting with a semicolon are comments

; create Visual CADD™ and point objects
$vcadd = ObjCreate("VisualCADD.Application.9")
$pt = ObjCreate("VisualCADD.Point2D.9")

; set the point to the origin
$pt.x = 0.0
$pt.y = 0.0

; set text string
$vcadd.SetTextString ("Hello World!")

; place the text in the drawing at the given point
;   -1 means in the drawing, other options
;   can place it in a symbol definition
$vcadd.AddTextEntity (-1, $pt)

; zoom all to see the text
$vcadd.ZoomAll

; release Visual CADD™ and point objects
$vcadd = 0
$pt = 0
                        


Scripts in Visual CADD™

The samples below show how to assign a script in Visual CADD™ to say "Hello World!" using the Visual CADD™ API with C++, C#, Visual Basic .NET, VBScript, JScript, and AutoIt.  You may assign a script using the menu >Utilities>Assign Script or the native/shortcut of ScriptAssign/AS.  These samples show how simple it is to assign your custom add-on tools to 2-letter shortcuts or hot-keys and get the full benefit and productivity of your custom tools at the click of a button or two.


C++ C# VB.NET VBScript JScript AutoIt
DllName;API_Help_C.dll;DllFunName;HelloWorld;DllRun;
DllName;API_Help_CSharp.dll;DllFunName;API_Help_CSharp.HelloWorld.Run;DllRunNET;
DllName;API_Help_VB.dll;DllFunName;API_Help_VB.HelloWorld.Run;DllRunNET;
FileName;HelloWorld.vbs;AutoMacro;
FileName;HelloWorld.js;AutoMacro;
FileName;run::HelloWorld.au3;AutoMacro;


Programming Languages

The need for additional Windows applications to develop Visual CADD™ API tools varies from requiring nothing more than a simple text editor, such as Notepad, all the way to advanced programming and development environments.  Free development applications are available even for the more advanced languages of C++, C#, and Visual Basic .NET.


C++ C# VB.NET VB/JScript Other

Microsoft provides a free development environment for C++ called Visual Studio Community 2022 for Windows Desktop.  Earlier free versions of Visual Studio Express may also be available.  All of the C++ samples shown in the API Help can be built using this free application.  If you are undecided about a programming language, Visual Studio Community 2022 for Windows Desktop has the advantage of supporting C++, Visual Basic .NET, and C#, all of which can be used to develop Visual CADD™ API tools.

There are other alternatives available for free or inexpensive C++ compilers and programming environments.

Microsoft provides a free development environment for C# called Visual Studio Community 2022 for Windows Desktop.  Earlier free versions of Visual Studio Express may also be available.  All of the C# samples shown in the API Help can be built using this free application.  If you are undecided about a programming language, Visual Studio Community 2022 for Windows Desktop has the advantage of supporting C++, Visual Basic .NET, and C#, all of which can be used to develop Visual CADD™ API tools.

There are other alternatives available for free or inexpensive C# compilers and programming environments.

Microsoft provides a free development environment for Basic called Visual Studio Community 2022 for Windows Desktop.  Earlier free versions of Visual Studio Express may also be available.  All of the Visual Basic .NET samples shown in the API Help can be built using this free application.  If you are undecided about a programming language, Visual Studio Community 2022 for Windows Desktop has the advantage of supporting C++, Visual Basic .NET, and C#, all of which can be used to develop Visual CADD™ API tools.

There are other alternatives available for free or inexpensive Basic compilers and programming environments.

Creating and running Visual CADD™ API tools using VBScript or JScript requires nothing more than a text editor, such as Notepad.  The VBScript saved as file extension VBS or JScript saved as file extension JS are run by the built-in Windows Script Host.  VBScript and JScript are the quickest and easiest way to get started creating Visual CADD™ API tools.  If you want to progress to something more advanced, the skills you learn with VBScript and JScript will be easily transferred to Basic, C++, Delphi, or others.

Many other languages can be used to create Visual CADD™ API tools.  Delphi is a Pascal-based programming language and can be used to develop API tools.  AutoIt is a freeware Basic-like scripting language including several other useful features.  Fortran is another possible language.  There are many, many other alternatives for programming languages you can use with the Visual CADD™ API.