PDA

View Full Version : Window for 3D Autocadders



ARKLisp
6th Mar 2006, 10:48 pm
Hi folks!

Is anybody interested in building automatically a 3d solid window?...

copy the following code into a ascii file, then rename it as Wind3d-eng.lsp
and finally load it with "_appload" autocad built-in command.

;;;Wind3d-eng.lsp [English release] <(c)ARKLisp TNT - Fabrizio Battistini_2001/2006>
;;;
;;; This autolisp macro is a little sample extracted
;;; from the "ARKsolid" module (ARKLisp TNT plug-in for AutoCAD).
;;;
;;;
;;; Author web site:
;;; http://webspace.omniway.sm/fbattistini/
;;;
;;;*********************************************** **********************************
;;; YOU ARE ALLOWED TO FREELY DISTRIBUTE AND MODIFY THIS VERSION.
;;; However provide that my copyright informations are always visible!
;;;*********************************************** **********************************
;;;
;;;
;;;
;;;
(Alert "WIND <enter> to launch ! -Window builder-
(c)ARKLisp TNT-(C) Fabrizio Battistini *Freeware release*")
;;;
;;;Routine WIND
;;; Internal error handler
(defun WFerror (m) ; If an error (such as CTRL-C) occurs
; while this command is active...
(setvar "cmdecho" 0)
(command "_.Redraw")
(if (/= m "Function cancelled")
(princ (strcat "\nError: " m))
)
(princ"\n Command cancelled: Please enter WIND again!.")
(setvar "cmdecho" 1)
(setq *error* olderr) ; Restore old *error* handler
(princ)
)
;;;
;;;
;;;
(DEFUN C:WIND(/ S S1 S2 SX1 SX2 SX2b SX22 Sa1 HH PP Pt1 Pt2
Pt3 Pt4 pt5 Pt6 Pt7 Pt8 Pt9 K3 K4 HI LI Sa2 Sv P PP Pv
L L1 L2 L3 H1 H2 K K2 k3 k4 KG HM PtA PtM PtM1
PtM2 PtM3 PtM4 las PtG LG var)
(setq olderr *error*
*error* WFerror)
(prompt"
This LISP builds a 3d solid Window.")(setq L (Getdist "\nInsert Window WIDTH <1300>: "))(IF (null L)
(setq L 1300))(setq HH (Getdist "\nInsert Window HEIGHT <1300>: "))
(IF (null HH)
(setq HH 1300))(setq K (getdist "\nInsert THICKNESS of Window frame<80>: "))
(IF (null K)
(setq K 80))(setq KG (* (/ K 8) 3))(setq P (Getdist "\nInsert DEPTH of Window frame <80>: "))(IF (null P)
(setq P 80))(setq Pv (- 0 (/ P 2) ))(setvar "CMDECHO" 0)(setq var (getvar "OSMODE"))(setvar "OSMODE" 0)(setq PP (- 0 P))(setq K2 (/ K 2))
(setq pt1 (Getpoint "\nSelect bottom-left opening point to start: "))(command "_UCS" "_o" Pt1)(command "_ucs" "_X" 90)
(command "_ucsicon" "_OR" )(setq Pt1 (list 0 0 0))(setq Pt2 (list (+ (nth 0 Pt1) K)(nth 1 Pt1)))(setq H2 (- HH K))(setq Pt3 (list (nth 0 Pt2)(+ (nth 1 Pt2) H2)))(setq L2 (/ L 2))(setq Pt4 (list (+ (nth 0 Pt1) L2)(+ (nth 1 Pt1) H2)))
(setq pt5 (list (+ (nth 0 Pt1) L2)(nth 1 Pt1)))(setq L3 (- L2 K))(setq Pt6 (list (+ (nth 0 Pt5) L3)(nth 1 Pt5)))(setq Pt7 (list (nth 0 Pt2)(+ (nth 1 Pt2) K)))(setq K3 (- L (* 2 K)))
(setq K4 (- L2 K2))(setq HI (- HH (* 2 K)))(setq LI (- L (* 2 K)))(setq Pt8 (list (+ (nth 0 Pt1) K4)(+ (nth 1 Pt1) K)))
(setq Pt9 (list (nth 0 Pt5)(+ (nth 1 Pt5) K)))(command "_BOX" Pt1 "_Length" K HH PP)(command "_BOX" Pt2 "_Length" K3 K PP) (command "_BOX" Pt3 "_Length" L3 K PP)(command "_BOX" Pt4 "_Length" L3 K PP)(command "_BOX" Pt5 "_Length" L3 K PP)(command "_BOX" Pt6 "_Length" K HH PP)(command "_BOX" Pt8 "_Length" K2 HI PP)(command "_BOX" Pt9 "_Length" K2 HI PP)(setq Sv (- 0 (/ K 8) ))(command "_ELEV" Pv"" )(command "_BOX" Pt7 "_Length" LI HI Sv) (setvar "ELEVATION" 0)(command "_ucs" "_X" -90)(command "_ucs" "z" -90)(command "_WEDGE" Pt1 "_Length" KG L KG)(command "_ucs" "_W")(command "_REDRAW" )(setvar "OSMODE" var)(setvar "CMDECHO" 1)(prompt"\n 3d Solid Window (ACIS) is ready; visualize it better in 3D view!") (setq *error* olderr) (princ))
;;;
;;;
(princ"\nWIND <enter>. 3d Solid Window Maker.(C)ARKLisp TNT-F. Battistini")
;;;
;;;

p.s. Pay attention to the copyright infos...otherwise :twisted:


;-)

ARKLisp