CADCAL & CALScript for AutoCAD and BricsCAD
  This is pure magic: create smart CAD objects and smart Lisp functions totally without any programming  
  Home Learn more Download Tutorial Pricing Order FAQ Contact  
 

Tutorial

Inhalt

CALScript und Lisp
        vorhandene Lisp Funktionen smart machen

 

 

 

 

 

 

 

 


 

 

(-> nach oben)

Make your existing Lisp functions smart

 
It's really easy and can be done in seconds without any additional programming. Most of you will have a large number of Lisp functions that can create arbitrarily complex drawing elements in a DWG by entering function arguments. The function definition shown here serves as an example.
It draws something like that:
; sample Lisp file
(defun dumblisp (p1 width height / p1 p2 p3 p4)

 (setq p2 (list (+ (car p1) width ) (cadr p1))
       p3 (list (car p2) (+ (cadr p2) height ))
       p4 (list (car p1) (+ (cadr p1) height ))
    )
 (command "._pline" p1 p2 p3 p4 "_cl")
 (command "._line" p1 p3 "")
 (command "._line" p2 p4 "")
)

; the command function asks the user for
; the arguments and calls the function

(defun c:dumblisp (/ pt wd dp)
 (if (and (setq pt (getpoint "\nstartpoint: "))
      (or (setq wd (getreal "\nwidth: ")) (setq wd 100))
      (or (setq dp (getreal "\nheight: ")) (setq dp 100))
             )
     (dumblisp pt wd dp)
   )
 (prin1)
)
Of course such a simple drawing can easily bei modified manually. But after you rotate it, it will be a bit more difficult to modify the width or height of it.

Not so, when you use CALScript. Simple call the dumblisp function from a script, and add one single line to the script to declare it's properties and the default values.

The script would look like that. Since Lisp can be used in a script, we can check if the Lisp function is loaded, and if noz, then the script will load it automatically. And the Lisp call
(dumblisp origin width depth)
gets its arguments from the cc-properties declaration. This simply is naming the variale names and the default value.
cc-properties width,80,depth,40
This is all you need. Really! Save the script on the side and save it as smartscript.scr.
; script file
cc-properties width,80,depth,40

(if (not dumblisp) (load "./calscriptdemo/dumblispsample.lsp"))
(dumblisp origin width depth)
Assuming that you already have installed CADCAL/CALScript, you can now run this script using the cc-script command.
This command will ask you for an insertion point and an angle, and then for the values of the arguments.

The CALScript command creates a smart object, which can be edited any time later. You can copy it, even to another UCS or another dwg file, and you can give it away and it keeps it's intelligence and can be edited on every AutoCAD or BricsCAD system with C&C installed.

Now play a little with these CALScript objects and the CC-MODIFY command, which let's you edit the properties of each single object.
Create copies of your CALScript objects, move them around, rotate them, scale them, and you can still modify their properties.
Since the drawing elements ar now plced inside a block definition, you need to give them the color attribute "BYBLOCK". Simply add the declarations to the script file, befor you call the Lisp:
._-COLOR BYBLOCK
(dumblisp origin width depth)
._-COLOR BYLAYER


     
  (c) 2025 Tom Berger
Feriendorfstraße 6c, D-34308 Bad Emstal, Germany
berger@archtools.de