CAD/CAM discussion forum > CAD Tutorial & Tips > zwcad autocad lisp routines, lisp tutorial for beginners, how to use lisp

zwcad autocad lisp routines, lisp tutorial for beginners, how to use lisp

    
  Subscribe Topic

Rank: 1

maker

Newbie

posts: 0

Registered: 2008-8-15

Message 1 of 4

 zwcad autocad lisp routines, lisp tutorial for beginners, how to use lisp
31-05-2008 03:12 . pm   |   View his/her posts only
Hi,
Some zwcad autocad lisp routines for you, you can learn how to use lisp by following lisp tutorial for beginners. Unfortunately no error checking in it - since my knowledge is only basic. Still I hope it is of some help to anybody. Perhaps someone more knowledgeable can develop it further
(just copy - paste it into a blank notepad file; save it as starter.lsp - or whatever. Use the 'appload' command to load it...). Please test it, if possible. Comments (after the ;;) indicate the nature of the command. to call the command from ZwCad just type the name (after the 'c:' - eg vs for 'save view' vr for 'restore view' etc.



;;VIEW COMMANDS (vs, vr, vst, vrt)
(defun c:vs() ;;Saves view (of name to be supplied by user).
(command "-v" "s"))
(defun c:vr() ;;Use this to restore Named View created by 'vs' (Type in the name supplied earlier)
(command "-v" "r"))
(defun c:vst() ;;Creates view called 'temp'.
(command "-v" "s" "temp"))
(defun c:vrt() ;;Restores view "temp"
(command "-v" "r" "temp"))

;;ZOOM COMMANDS (z7, z12, ze, za, zp)
(defun c:z7() ;;Zooms (out) 0.7x
(command "zoom" ".7x"))
(defun c:z12() ;;zooms (in) 1.2x
(command "zoom" "1.2x"))
(defun c:ze() ;;Zooms extents, then zooms out 0.9x
(command "zoom" "e" "zoom" ".9x"))
(defun c:za() ;;Zoom all
(command "zoom" "all" "zoom" ".9x"))
(defun c:zp() ;;Zoom previous
(command "zoom" "p"))

;;VPORT COMMANDS (vps, vpr, vps1, vpst, , vpr1, vprt)
(defun c:vps() ;;Save vport with whatever name you want. Use 'vps' to restore
(command "-vports" "s"))
(defun c:vpr() ;;Use this to restore the vport created with prev command.
(command "-vports" "r"))
(defun c:vps1() ;;Saves viewport '1'
(command "-vports" "s" "1"))
(defun c:vpst() ;;Saves viewpot 'temp'
(command "-vports" "s" "temp"))
(defun c:vpr1() ;;Restores vport '1'
(command "-vports" "r" "1"))
(defun c:vprt() ;;restores viewport 'temp'
(command "-vports" "r" "temp"))

;;BREAK COMMANDS (brf, bra)
(defun c:brf() ;;selects 'first' point of entity to 'break'
(command "break" pause "f"))
(defun c:bra() ;;breaks entity at point you select
(command "break" pause "f" pause "@"))

;;UCS COMMANDS (uro, uro90, uro90x, ug, upr, uwo)
(defun c:uro() ;;rotates UCS around z axis
(command "ucs" "z"))
(defun c:uro90() ;;rotates UCS 90 degrees around z axis (Use it for creating side elev, etc)
(command "ucs" "z" "90" ))
(defun c:uro90x() ;;rotates UCS -90 degrees around z axis (Use it for creating side elev, etc)
(command "ucs" "z" "-90" ))
(defun c:ug() ;;creates 'orthographic' ucs. Right-click and select the 'view' you want.
(command "ucs" "g"))
(defun c:upr() ;;restores previous UCS
(command "ucs" "p"))
(defun c:uwo() ;;changes UCS to 'world' UCS
(command "ucs" "w"))


;;LAYER COMMANDS (lnc, lse, lne, lco)
(defun c:lnc() ;;new layer current
(command "-layer" "make" ))
(defun c:lse() ;;makes layer current
(command "-layer" "set" ))
(defun c:lne() ;;new layer
(command "-layer" "new" ))
(defun c:lco() ;;change layer color: use number between 1-255 OR red/green etc.
(command "-layer" "color" ))

Rank: 1

OldForumPost

Newbie

posts: 0

Registered: 2012-1-14

Message 2 of 4

05-05-2008 02:31 . am   |   View his/her posts only
Hello, Maker. Thank you! Hopefully, more and more visitors can share their experience on CAD software.


You might also like these posts:
How to load CAD LISP application on startup? how to load vba startup?
ZWCAD Lisp FAQ
use lisp to convert line or arc to polyline
command alias editor for ZWCAD, CAD lisp program with dialog box
add support file search path lisp



Try ZWCAD+ free for 30 days:
http://www.zwsoft.com/zwcad+/

Rank: 1

maker

Newbie

posts: 0

Registered: 2008-8-15

Message 3 of 4

31-05-2008 03:12 . pm   |   View his/her posts only


Hello,
Just thought I'd attach a version for International language users. It's the first time I'm trying something like this, so I'm no too sure if it works okay. If you're using the "international (/local) version" of Zwcad, please try it and give your comments ;).

To use, just unzip to your Zwcad path (the easiest way is to copy to the Zwcad folder). Load it using "Appload" command. Once loaded, click on "load" button in the "Appload" window. If you 'd like it to load everytime with Zwcad ;), load it in the "startup suite" in the box.


Quick view the "shortcuts" supplied (the actual commands and lisp code is after this block) Smile
***********************************************************
VIEW COMMANDS:
vs - Creates view (name to be supplied by user. Eg 1, 2, 3...)
vr - Restores view (use this to restore view 'name' as supplied in previous command.Eg 1, 2, 3..)
vst - Saves current view as "temp"
vrt - restores view "temp"
[Note copy-paste this bit of code and replace "temp" by "1" or "2"...to create your own view named "1", "2"...etc]

ZOOM COMMANDS:
z7 - Zooms out 0.7x times
z12 - Zooms in 1.2x times
ze - Zooms extents; then zooms out 0.9x
zp - Zoom Previous

VPORT COMMANDS:
vps - Saves current viewport configuration with user-supplied name (eg vp1, vp2...)
vpr - restores named viewport config (as supplied in last command. eg vp1, vp2...)
vps1 - Saves vport configuration as "1"
vpr1 - restores vport configuration "1"
[Note copy-paste this bit of code and replace "1" by "2" or "3"...to create your own vport configurations]
vpst - saves vport configuration as "temp"
vprt - Restores vport "temp"

BREAK COMMANDS:
brf - Selects "first" point of object (entity) to "Break".
bra - Breaks object at selected point.

UCS COMMANDS:
uro - Rotates UCS around z-axis.(Type in rotation angle)
uro90 - Rotates UCS around z-axis by 90 degrees (anti-clockwise, of course ;). Useful e.g. when you want to make Right-side Elevation.
uro90x - Rotates UCS around z-axis by -90 degrees.
ug - Creates "Orthographic" UCS (Front, Back, Right...)
upr - restores Previous UCS (You can use this and "ug" to quickly shift between "Plan view" and "Orthographic View"
uwo - restores world UCS.

LAYER COMMANDS:
lnc - makes new layer and makes it "current" layer.
lse - makes layer current (You'll have to type in the name, unfortunately ;(
lco - changes layer colour (Type in a number between 1-255 (1 is red, 255 is grey...) OR type red, blue...)
********************************************************

THE ACTUAL FILE (I'm afraid to upload the actual file, as there may be a virus in my comp)
please copy-paste this to a "notepad" file as "zwcad-starter.lsp" (without quotes ;)



;;VIEW COMMANDS (vs, vr, vst, vrt)
(defun c:vs() ;;Creates view (of name to be supplied by user).
(command "_view" "_save"))
(defun c:vr() ;;Use this to restore Named View created by 'vs' (Type in the name supplied earlier)
(command "_view" "_restore"))
(defun c:vst() ;;Creates view called 'temp'.
(command "_view" "_set" "temp"))
(defun c:vrt() ;;Restores view "temp"
(command "_view" "_restore" "temp"))


;;ZOOM COMMANDS (z7, z12, ze, za, zp)
(defun c:z7() ;;Zooms (out) 0.7x
(command "_zoom" ".7x"))
(defun c:z12() ;;zooms (in) 1.2x
(command "_zoom" "1.2x"))
(defun c:ze() ;;Zooms extents, then zooms out 0.9x
(command "_zoom" "_extents" "_zoom" ".9x"))
(defun c:za() ;;Zoom all
(command "_zoom" "_all" "_zoom" ".9x"))
(defun c:zp() ;;Zoom previous
(command "_zoom" "_previous"))


;;VPORT COMMANDS (vps, vpr, vps1, vpst, , vpr1, vprt)
(defun c:vps() ;;Save vport with whatever name you want. Use 'vps' to restore
(command "_vports" "_save"))
(defun c:vpr() ;;Use this to restore the vport created with prev command.
(command "_vports" "_restore"))
(defun c:vps1() ;;Saves viewport '1'
(command "_vports" "_save" "1"))
(defun c:vpst() ;;Saves viewpot 'temp'
(command "_vports" "_save" "temp"))
(defun c:vpr1() ;;Restores vport '1'
(command "_vports" "_restore" "1"))
(defun c:vprt() ;;restores viewport 'temp'
(command "-vports" "_restore" "temp"))


;;BREAK COMMANDS (brf, bra)
(defun c:brf() ;;selects 'first' point of entity to 'break'
(command "_break" pause "_first"))
(defun c:bra() ;;breaks entity at point you select
(command "_break" pause "_first" pause "_@"))


;;UCS COMMANDS (uro, uro90, uro90x, ug, upr, uwo)
(defun c:uro() ;;rotates UCS around z axis
(command "_ucs" "_z"))
(defun c:uro90() ;;rotates UCS 90 degrees around z axis (Use it for creating side elev, etc)
(command "_ucs" "_z" "90" ))
(defun c:uro90x() ;;rotates UCS -90 degrees around z axis (Use it for creating side elev, etc)
(command "_ucs" "_z" "-90" ))
(defun c:ug() ;;creates 'orthographic' ucs. Right-click and select the 'view' you want.
(command "_ucs" "_orthographic"))
(defun c:upr() ;;restores previous UCS
(command "_ucs" "_previous"))
(defun c:uwo() ;;changes UCS to 'world' UCS
(command "_ucs" "_world"))


;;LAYER COMMANDS (lnc, lse, lne, lco)
(defun c:lnc() ;;new layer current
(command "_layer" "_make" ))
(defun c:lse() ;;makes layer current
(command "_layer" "_set" ))
(defun c:lne() ;;new layer
(command "_layer" "_new" ))
(defun c:lco() ;;change layer color: use number between 1-255 OR red/green etc.
(command "_layer" "_color" ))










maker2008-05-31 15:45:03

Rank: 1

ava_lee

Newbie

posts: 0

Registered: 2011-12-5

Message 4 of 4

05-12-2011 08:52 . pm   |   View his/her posts only
Thanks for you share!
See also
X