Let there be light ... a new CADCAL beta is available

A new beta of CADCAL is available, all you need is attatched to this post. Simply extract the ZIP to any directory, and - if not already done so - add this to the search path of AutoCAD or BricsCAD. In AutoCAD load the CADCAL VLX, in BricsCAD load the CADCAL.DES.

When CADCAL is loaded you can test the sample files in the ./demo subdirectory.

This new beta now supports object communication, which allows the user to create simple models for simulations. A very simple sample ist defined by the ./demo/switch.scr and ./demo/lamp.scr. Both use blocks, and these are available in the switch-and-lamp.dwg file. You need to do this sample in this dwg file.

Since the last beta version the syntax and structure of CADCAL objects have changed significantly and are adapted to that of other object oriented languages. So simply setting in a script
(setq SELF.LAYER "MyNewLayer")
will cause that the object is placed on that layer.

The Lisp which is created by (setq myfun (C:CALSCRIPT->LISP)) now has an additional argument SELF. SELF can either be the entity name of a CALSCRIPT object, and then this object is modified according to the other arguments, i.e. a NICKSHOUSE object with ename EN can get new properties WIDTH and HEIGHT this way:
(apply myfun (list width height EN)).

The ./demo/NICKSHOUSE.LSP shows how you can create your own apps using automatically created CALSRIPT Lisp code. A new object can be created at insertionpoint and insertionangle this way:
(apply myfun (list width height (list insertionpoint insertionangle))
The insertion angle must be given in radians.
(apply myfun (list width height nil))
will create a new object at (0 0 0) and angle 0.

The communication between CALSCRIPT objects is created by the user with the command CC-CONNECT. One single master object can communicate to many slave objects. Every slave can only have one master. A slave object can also be a master to other slaves. Caution: at the moment the beta version does not check for recursions. Don't create communication circles which will never end.

A slave object reads all the properties of the master object, and can use these for calculations, or to overwrite it's own properties. See the local variables in the LAMBDA created by command CALSCRIPT->LISP from the lamp.scr for a list of properties, which can be changed:

(LAMBDA (POWER SELF / SELF.ENAME SELF.DATA SELF.ORIGIN SELF.ANGLE SELF.SCALE SELF.XSCALE SELF.YSCALE SELF.ZSCALE SELF.LAYER SELF.OCS SELF.COLOR       SELF.LINETYPE SELF.LINEWEIGHT  SELF.PROPERTIES  SELF.NAME  SELF.POWER MASTER.DATA MASTER.ORIGIN MASTER.ANGLE     MASTER.SCALE     MASTER.XSCALE MASTER.YSCALE    MASTER.ZSCALE    MASTER.LAYER  MASTER.OCS       MASTER.COLOR     MASTER.LINETYPE MASTER.LINEWEIGHT                 MASTER.PROPERTIES MASTER.NAME      MASTER.ENAME

…))

The lamp.scr ist really very simple:

(setq self.name "LAMP")
;;
cc-import power,0
cc-overwrite power
;;
(if (zerop power) (setq bn "lamp-off")(setq bn "lamp-on"))
(if master.origin (command "._line" origin master.origin ""))
._INSERT !bn !ORIGIN 1 1 0

The SELF.NAME declaration is opional. When it is set, CADCAL adds a xdata-marker to the object with the appname of this name. This enables a programmer to easily find and filter these objects in a dwg, or to filter communication data.

The import declaration has changed to a script command call, but the previous syntax
CAL import(power,0)
can also be used. With "cc-import power,0" we declare an object argument "power" and give it a default value of 0 (= "off").

The "cc-overwrite power" declaration tells that when communication with a master object is established, the script variable "power" and the object variable self.power are replaced by the master.power. A declaration like that would have the same effect:
(if master.power (setq power master.power self.power master.power))
When more than one property should be overwritten by master properties, than add the other properties with a comma:
cc-overwrite power,layer
will overwrite the layer property too and place the object on the same layer as the master object. This declaration would have the same effect:
(if master.layer (setq self.layer master.layer))

The script line "(if (zerop power) (setq bn "lamp-off")(setq bn "lamp-on"))" sets the block name BN for the insert according to the power property.

The line "(if master.origin (command "._line" origin master.origin ""))" draws a line from the master's insertionpoint to the object's insertionpoint.

Now open the switch-and-lamp.dwg, and CC-MODIFY a switch object. Since the CADCAL beta only supports numbers as arguments, 0 means off and 1 means on. Let there be light ...

The nickshouse-comm.dwg shows how the nickshouse object reflects communication. When connected with CC-CONNECT, the slave object will place itself at the right side of the master in the same angle as the master, and it will overwrite it's own self.layer and self.color with the data from the master.

You can build long communication chains between objects, and so you can model simple simulations. Just think of gear objects where on gear meshes with another, and they rotate at different speeds according to their sizes ...

Have fun …

Comments

  • A new Beta is available, now with all necessary Lisp functions exported from the separate namespace of the CADCAL application. Just do a test:

    (xdata-get (car (entsel)) "CALSCRIPT")

    and pick an object in one of the demo dwg files.

  • Unfortunately it turned out that the BricsCAD feature "separate namespace" is implemented in a very poor way and can't be used for CADCAL. The main command functions of CADCAL did work, but, despite the fact that the necessary functions have been exported from the separate namespace to the global namespace, not so the LAMBDA which is automatically created by (c:calscript→lisp). BricsCAD simply renames all variable names to "<appname>:<varname>, i.e. the variable "self.origin" to "cadcal:self.origin". So a Lisp which refers to "self.origin" can't be run from autoside the separate namespace, even when all functions are available.

    So a modified CADCAL.DES which is working in the global namespace is integrated in the new CADCAL.ZIP.

    Please use only this new version for testing CADCAL.