TurboCAD Pascal Script Engine first created 08/10/05 - last modified xx/xx/xx Page Author: Ty Harness
Project: Design and build an in-process Pascal macro system for TurboCAD. Allow users to develop macros along the lines of Visual Basic for Applications(VBA). Sadly the VBA implementation was dropped from TurboCAD v11. This non-commercial project is just a bit of fun to see if a Pascal Editor and compiler could used to help TurboCAD users get over the shock of losing the VBA.

My aim is now to write a replacement for the VBA editor/compiler/debugger.

RemObjects give away a free pascal compiler http://www.remobjects.com/ where you register functions, com objects so that the pascal script can execute it.

Each custom object inserted will be a script and the property page of the regen object will be an editor where you can type the pascal or load a file. And when the property page is closed the script will be executed which in turn draws geometry, creates layers or what ever.

I probably haven't got all the skills to do a really sleek job of this but I hope IMSI will replace VBA with another in process compiled macro system- an embedded scripting engine.
Here's my first attempt - I'm not going to deploy the regen dll at this stage but if you have a Delphi compiler and download the RemObjects Pascal script VCL then you should be able to recreate the dll from the source code provided here. Make sure you can compile the Rounded Rectangle example provided by IMSI in the SDK Delphi folder. I've derived the in process server from TAutoObject which was the IMSI Delphi example from the version 7 of the SDK. TC 10.51 has a newer example using dispinterfaces which has the advantage of ID binding over the variant technique used below. Plus you get code insight. I've slipped back to the earlier ways because I'm not fully up on my COM prgramming.

I haven't been able to register the Application object yet for use in the Pascal Script but I have made wrapper functions and registered these. Just call the wrapped functions with in your script. I'm pretty sure I'll get the Application Object registered - the Pascal Script Engine documentation states it is possible.

This example has taken me 4 to 5 hours to produce - it's rough but has potential. A proper COM programmer could do a good job of this.
Source Code Version 1 {Marco Cantu PastoWeb generated html}
TY_Script_Engine_dpr
IMSI_TurboCAD_AutoObject_pas
EmbeddedScriptEngine_pas
Ty_Script_Editor_pas
Ty_Script_Editor_dfm

FirstEffort_pas.pas - {Demo Script file}

Destructions
First compile the dll

text here
Figure 1 - Delphi IDE showing all the units needed


Copy the dll to the TurboCAD regens folder.

text here
Figure 2 - Place dll in the regens folder


Open or Restart TurboCAD and start a new drawing.

From the TC Menus: Addons

SDK Samples

Custom Object

{Tip - set up a SEKE}

text here
Figure 4 - How to insert a smart object


Choose Tscripter.version1 from the SDK External Objects Dialog

and press insert

text here
Figure 5- Inserting the Tscripter Regen Object


Close the External Objects dialog box

To access the script:

RB on the Object

Properties

Other

Choose Additional Pages

GotoPage to display the script

text here
Figure 6- Script Editor Page


You can edit the script or load another pas file and when the properties page is closed the script is recompiled and the Object is regenerated.

[Home] [Mechanics] [Welding] [Software] [CAD] [Math]

Tested in Firefox 1.07: FireFox homepage