PDA

View Full Version : Scripting DLL calls in AMS project


SGW
02-17-2009, 07:33 AM
Hi,

I am trying to test using a DLL for drawing (VeCAD DLL). The VeCAD DLL trial version can be downloaded here: http://www.kolbasoft.com/vecad6.zip.

A newbie, I have written script, following the DLL scripting requirements and DLL samples in the AMS User Guide, and I've added this script to a button to call 2 functions. As far as I can understand from reading the VeCAD help guide (Re: VeCAD Object and VeCAD Window) these 2 function calls are needed first in order for the DLL's drawing canvas to display in a Window, so additional functions for drawing can then be called and drawing can be done.

DLL.CallFunction ("C:\\Program Files\\Kolbasoft\\VeCAD61\\Vecad.dll","CADCreate",DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
DLL.CallFunction ("C:\\Program Files\\Kolbasoft\\VeCAD61\\Vecad.dll","CadWndCreate","hDwg", "hWndParent","Style", "Left", "Top", "Width", "Height",DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);

I'm not sure of 2 things: (1) are these the correct function calls and syntax to get a drawing canvas to display? and (2) is my LUA script correct?

I must be doing something wrong since when I preview the AMS project and click the button that contains this script, nothing happens. No drawing canvas Window displays.

I would much appreciate any help so that I can get this DLL working in AMS and learn how to script these and additional function calls to set up DLL drawing features for an eLearning project.

I am attaching the AMS file. The VeCAD DLL and VeCAD help files are included in the package that can be downloaded using the above link.

Thanks very much for your help.

Kind Regards,

SGW

Imagine Programming
02-17-2009, 08:10 AM
DLL.CallFunction("C:\\Program Files\\Kolbasoft\\VeCAD61\\Vecad.dll", "CADCreate", "", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
DLL.CallFunction("C:\\Program Files\\Kolbasoft\\VeCAD61\\Vecad.dll","CadWndCreate","\"hDwg\",\"hWndParent\",\"Style\",\"Left\",\"Top\",\"Width\",\"Height\"",DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);


The lua script is now correct, but i don't know how this DLL should be called. It could be possible that wit will draw directly to your project's window. But just parsing the string Style, Left, Top, Width, Height won't do anything right?

The arguments should be escaped at all times :) (if it's a number parse it like: 6 ..",".. 10 .. "," .. 11, or else AMS will see it as arguments for the lua function.)

SGW
02-17-2009, 09:12 AM
H,

Thanks for your reply and suggestions. I gave it a try, but unfortunately, no joy, and this time the preview crashed.

I have also tried the script with placing a copy of the DLL in the AMS project working folder, without better results.

As a newbie, and retired social worker without a programming background, trying, on the VeCAD side, to determine the critical calls to get a window/canvas to display plus its required syntax (VeCAD help guide calls are written in C++), and then trying on the AMS side to "translate" these into correct LUA syntax , has been a challenging experience.

The VeCAD help guide states:

"In your application you must create at least one VeCAD object. Afterward, you can load a drawing from file or create it programmatically, manipulate the graphical objects (entities) and apply changes by way of the nongraphical objects in the drawing. You may instantiate a VeCAD window on any form/dialog of your application."

So, I have been trying to first create a blank VeCAD Object and then create a VecAD Window. Unfortunately, I don't understand C++ language and syntax or what is meant by instantiating a VeCAD window or how.

Still lost, I'm afraid. Not sure what to do next.

Again, thanks for your help.

Kind Regards,

SGW

Imagine Programming
02-17-2009, 10:01 AM
It's not that it doesn't understand the C++ lang or syntax, it could be that the DLL is ByRef instead of ByVal (the way you parse variables to the dll must be ByVal if you call them from AMS).
And it also could be that this DLL is an ActiveX object.

You can call ActiveX by using the luacom action plugin. (http://indigorose.com/forums/showthread.php?t=10156&highlight=LuaCom)

SGW
02-17-2009, 10:31 AM
Hi,

I think the VeCAD download package has both a useable ActiveX (OCX) and a DLL.

I had already inquired about using the ActiveX with the luacom plugin but had been told that there is no way to create a display drawing canvas window in AMS with the ActiveX. I am too new and unknowledgeable about this, so I gave up on trying to use the VeCAD ActiveX in AMS (via luacom).

The VeCAD user guide does say that the ActiveX includes a default display of a drawing canvas which should show if the ActiveX is loaded into the main app. But, I do not know how to load the ActiveX and get it to display the default canvas in an AMS project.

Is it possible for you to take a look at the VeCAD (download it) and suggest if and how I can accomplish this. It's a very well written, full-featured, world-class drawing ActiveX (and drawing DLL), likely useful in many AMS projects. :)

Any help would be much appreciated.

Kind Regards,

SGW

Imagine Programming
02-17-2009, 10:38 AM
Well, I'm more fond of the non object type ActiveX libraries. I've never even tried to draw an object from ActiveX (nor DLL) to an AMS Window. That's why we have the Object Plugin :)

SGW
02-17-2009, 10:52 AM
Hi,

Thanks for your reply.

The goal of all this drawing effort is to add a drawing tool to an eLeraning projcet that will allow the user to draw a fairly complex family tree diagram. This would help them track family health conditions to share with their medical doctor to improve health and prevention. I give away these eLearning health improvement projects as a community service.

These diagrams follow a conventional design and include symbols (squares for male family members, circles for female family members) divided into 4 quadrants with different color fills to track different conditions. Plus many other symbols, connecting lines (solid, dotted, arrow-headed, different colors).

Given my limited scripting skills, I figured inporting a drawing ActiveX or DLL with many of these features would be easier than trying to script these. Not even sure if AMS LUA could draw these complex shapes, lines, etc.

I would value your thoughts about this, how best to proceed.

Again, thanks for your continued help.

Kind Regards,

SGW

Imagine Programming
02-17-2009, 12:14 PM
Well, I'm not that experienced in drawing rare shapes onto windows, all I use is GDLua and the Shape plugin for stuff like that. But going as far as drawing family trees, never done that sorry.

What you could do is somehow create an application where users can input the family tree data (birthdates, couples etc.) and from that generate an HTML page or PDF file. This way users won't have to draw the trees themselves.

I't a complex way of doing this though.

Bas

SGW
02-17-2009, 12:27 PM
Hi Bas,

Thanks for your reply and thoughts. It's been a challenge to say the least.

Very complex to take data entered by a user and generate a family tree diagram from it, given the variety of family structure, relationships.

I already have a fairly good drawing tool done in a form of JS, using another software package. Does a very good job with symbols, shapes, text, but line drawing is not as good. JS has some limitations for line drawing. If I can figure out a smoother line drawing tool to add in, then success!

I'll keep at it, trying to figure the best way.

Again thanks.

Kind Regards,

SGW