Jump to content

CADCAL: GeomCAL replacement, smart scripts, Lisp translation ...


Recommended Posts

Posted

this is CADCAL:
- full replacement for GeomCAL with enhanced functionality for AutoCAD, BricsCAD and all apps that can load 'VLX
- DDCAL: DCL frontend for CAL with history
- Create scripts from DDCAL history
- Scripts that create editable CALSCRIPT objects (easier and more powerful than dynamic blocks)
- CALSCRIPT objects can communicate to each other and build dynamic models
- CALSCRIPT->LISP: Translate CALSCRIPT scripts to full working Lisp and create applications


A new beta of CADCAL is available for free from www.archtools.de/cadcal.zip. 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.

Start with the script file ./demo/nickshouse.scr. You can execute that script using the CALSCRIPT command, and it will create an editable drawing of nickshouse. You can move, copy, rotate this object, and every object instance remains editable by the CC-MODIFY command. You can give away a DWG file containing CALSCRIPT objects, and the receiver also will be able to modify these objects.

 

The objects are created from simple scripts, which also can be run by the standard ._SCRIPT command of AutoCAD and BricsCAD, but this only craetes the drawing, and not an editable CALSCRIPT object. A single line in the script makes the CALSCRIPT objects editable:

cc-import width,100,height,100

This line (or the line  "(command "cc-import" "width,100,height,100")" or the line "CAL import(width,100,height,100)") fills the arguments width and height with the default values 100. And this line is all you need to enable your script to create an editable CALSCRIPT object.

 

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. Simply switch on the light using CC-MODIFY on a switch object which is connected to lamp objects. Just create a new switch und/or lamp object with the CALSCRIPT command, and connect them with the CC-CONNECT command. CC-MODIFY your switch ans see the object communication at work.

 

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.

 

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 …

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...