You may ask why use
Cadvance as an environment for your CAD based applications?
There are various compelling reasons for choosing
Cadvance.
Cadvance provides a complete set of tools for customization.
You have many choices for creating applications that run as macros from within
Cadvance
or as external function libraries in the form of DLL's.
You can choose your favorite Windows software development platform from any product that can create a Windows DLL.
Delphi is one such product which we use to develop applications.
Even those that can't create DLL's like Microsoft Visual Basic can be accessed as OLE servers from
Cadvance macros or DLL's.
Most applications written for
Cadvance
LiTe will run in the full version of
Cadvance, full version applications will run without 3D specific code.
The Cadvance Developer Interface (CDI) is used to access Cadvance's internal functions.
Similar to using ARX in AutoCad, this has been a feature of
Cadvance for Windows since 1993.
Calls are made to the Cadvance's CDI are similar to using the Windows API in a Windows application.
All systems used to develop applications for
Cadvance use the same set of functions.
Applications written using Delphi can easily be translated into C or BASIC.
procedure DrawLine;
var
i_ret:integer;
l_ret:LongInt;
i_term:integer;
i_menu:integer;
startPoint:CDI_DD_POINT;
endPoint:CDI_DD_POINT;
begin
CdiDeleteCursor;
i_ret:=CdiGetPoint('Line point #1', startPoint, i_term, i_menu);
i_ret:=CdiGetPoint('Line point #2', startPoint, i_term, i_menu);
i_ret:=CdiObjStartLine(startPoint,CdiGetActLayer,CdiGetStyle,CdiGetWeight,CdiGetCurColor);
l_ret:=CdiObjAddtoLine(endPoint,CDI_DRAWTO);
l_ret:=CdiObjEnd(CDI_TRUE,CDI_TRUE,CDI_OBJECT_COLOR);
end;
Sub DrawLine()
Dim i_ret as Integer
Dim l_ret as Long
Dim i_term as integer
Dim i_menu as integer
Dim startPoint as CDI_DD_POINT
Dim endPoint as CDI_DD_POINT
CdiDeleteCursor
i_ret:=CdiGetPoint('Line point #1', startPoint, i_term, i_menu)
i_ret:=CdiGetPoint('Line point #2', startPoint, i_term, i_menu)
i_ret:=CdiObjStartLine(startPoint,CdiGetActLayer(),CdiGetStyle(),CdiGetWeight(),CdiGetCurColor())
l_ret:=CdiObjAddtoLine(endPoint,CDI_DRAWTO)
l_ret:=CdiObjEnd(CDI_TRUE,CDI_TRUE,CDI_OBJECT_COLOR)
End sub
AutoCad's ARX is limited to Microsoft C due to the MFC libraries it uses.
None of the standard products like Delphi or Visual Basic can use AutoCad's ARX environment directly.
Cadvance's programming interface doesn't suffer from the problems encountered in creating an application using AutoCad as a development platform.
If you program using AutoLisp you can't make calls to the Windows API without writing an ARX function call.
An ARX function call can only be written in Microsoft C and its libraries can only be used by Microsoft C.
Translating your code from AutoLisp to VBA or ARX is impossible.
You would have to completely rewrite your routines.
Your VBA routine can't call your AutoLisp routines and or even pass information back and forth without having to resort to writing temporary files or using functions to stuff the keyboard buffer.
If you were to write your application in AutoCad's VBA you would be missing many of the functions that were available to you using AutoLisp.
Cadvance doesn't limit your development environment to a particular programming language or set of limited function calls.
In
Cadvance mixing languages is easy by calling a DLL from a macro or accessing an application server using Active-X functions or running a macro from your DLL.
procedure DrawLine;
var
i_ret:integer;
begin
i_ret:=CdiRunMacro(‘DrawLine.Cbx’);
end;
Cadvance Basic Language (CBL) is the macro language included with
Cadvance.
CBL is a dialect of BASIC with many of the functions of Visual Basic.
Even though forms are supported in CBL, missing are the integrated development environment features for painting forms and creating classes.
If you already know VB you can begin programming immediately.
You don't need to learn another language.
CBL Sample Code - Linesets
CBL Sample Code - Selection Sets
In
Cadvance unlike AutoCad's AutoLisp the Windows API and DLL's are accessible to your CBL macros.
Cadvance has a number of methods to access and run DLL's in the drawing environment.
Declare Function GetWindowTextA Lib "user32"(ByVal hwnd As long, ByVal lpString As String, ByVal cch As long) as long
Declare Function GetWindowTextLengthA Lib "user32" (ByVal hwnd As long) as long
Declare Function cv_viewhandle Lib "CAD1" () as long
sub main
Dim handle As long
Dim aint As long
Dim lpString as string
Dim result as long
handle=cv_viewhandle()
aint = GetWindowTextLengthA(handle)
lpString = String$(aint, Chr$(32))+Chr$(0)
result = GetWindowTextA(handle, lpString, aint+1)
msgbox lpString
end sub
In AutoCad, to access a DLL you could use Visual Lisp but you would be limited to DLL's that expose their methods as part of automation servers only.
When using Visual Lisp be ready for surprises like not even being able to create a directory without external help from an automation server application.
In addition both the full version of
Cadvance and Cadvance LiTe can run CBL routines.
AutoLisp won't run in AutoCad LT.
You can't create applications to run inside of AutoCad LT at all with the exception of scripts.
Another plus in the full version of
Cadvance is the ability to record your CBL macros.
Once you have recorded them you can then edit the source code.
Source code written for other applications using BASIC can be imported and modified quite easily to run inside a
Cadvance macro.
Macros use the same calls to the CDI as any other application written for
Cadvance.
You can write and test your macro in CBL and then convert it at a later time to Delphi or C.
CBL macros can be called from the other programming environments by using a CDI function call.
You can make calls to OLE servers from inside of your CBL macro. The code is almost identical to that in Visual Basic. Delphi or Visual Basic applications written as servers can be called.
count=CdiOslCount(0&)
if count>0 then
dim status as object
set status=createobject("CviMacroLibrary.Status")
status.caption="Please wait while this task is happening."
doevents
for osl_item=0 to count
status.percent=(100*osl_item\count)
next osl_item
status.hide
set status=nothing
Similarly you could call the same OLE server using Delphi.
var
Utility:Variant;
begin
Count:=CdiOslCount(0);
if (count>0) then
begin
status:=CreateOleObject('CviMacroLibrary.Status');
status.caption:='Please wait while this task is happening.';
for osl_item:=0 to count do
begin
status.percent:=(100*osl_item\count);
end;
status.hide;
end;
end;
An AutoLisp routine can't do this, you would have to use Visual Lisp still another environment in AutoCad with a different set of function calls and rules.
The plain fact is AutoLisp in AutoCad is braindead when it comes to accessing any Windows functionality, AutoLisp was created for use in a DOS only environment.
CBL is so powerful that you could write a whole new interface for
Cadvance using the CBL macro language alone. One user did just that and created a Macintosh like user interface inside of
Cadvance.
The sample source code for this really hot CBL application is included on the
Cadvance CD-ROM along with many other examples.
Cadvance also supports custom objects called
auxiliary objects or widgets.
Any application development environment that can create a DLL can be used to create an
auxiliary object.
DLL's can be activated from the
Cadvance menu by adding the references to the Cadvance.ini file.
[3rd Party (cadvance.ini)]
&EZAToolbar=BasicToolbar EZATAttr.dll 2D
The object programming interface is extremely easy to use, CDI provides the interface necessary to create an object, the custom DLL manages the object.
Many functions found in
Cadvance are
auxiliary objects.
Associative dimensions and textures, TrueType fonts and bitmaps all are
auxiliary objects in
Cadvance.
Using the CDI interface you can also create your own objects using C, C++, or Delphi.
In AutoCad you can only use ARX or Visual Lisp to create objects and you can't mix.
If you aren't happy programming in C or C++, you can switch to Delphi or vice versa when using CDI.
Drawings created in Cadvance 7 which is a 16bit application containing an object written using Delphi 1, can be used in Cadvance 1999 a 32bit version having a Delphi 5 version of the object.
The drawings can be moved back an forth between the two versions seemlessly as long as Delphi has an equivalent function available in each of the object DLL's.
Cadvance 2002 uses a newer file format, can read the data but cannot be read by earlier versions of
Cadvance.
A technical discussion and source code for auxiliary objects is at:
http://visual-engineerign.com/cadvobjs.html
A technical discussion about The Other Macro Language for Cadvance (Cadvance News October 2003):
go to top of page
Updated: November 2, 2006