;Design Vocabularies: perg_round_shaft.lsp ;Autolisp file for 4.207 prepared by Lee, Hee Won ;Date: 11/29/96 ;This file draws 3 dimensional round shaft for pergola. ;Use of functions defined in this file ;(perg_round_shaft x y z r h nrow gap_row gap_col) ;(demo) ;Load a file to use 'rotate3d' and 'mirror3d'. ;(xload "geom3d") (load "nagakura") ;Load a function " rarray (ent n_row n_col gap_row gap_col ; / M N result_ss new_ent)" ;(load "rarray") (defun rarray (ent nrow ncol gap_row gap_col / M N result_list new_ent) (setq result_list (list ent)) (setq M 0) (setq nrow (fix nrow)) (setq ncol (fix ncol)) (repeat nrow (progn (setq N 0) (repeat ncol (command "copy" ent "" (list 0 0 0) (list (* N gap_col) (* M gap_row) 0)) (setq new_ent (entlast)) (if (and (= N 0) (= M 0)) (command "erase" new_ent "") (setq result_list (cons new_ent result_list)) ) (setq N (+ N 1)) ) ;end repeat ncol ) ;end progn (setq M (+ M 1)) ) ; end repeat nrow result_list ) ; Set up drawing for architectural unit. ;(command "units" 4 "" "" "" "" "") ;This is setting up a new layer. (command "layer" "new" "round_shaft1" "color" "red" "round_shaft1" "") ;This function allows a shaft to be drawn parametrically at ;a desired location with array. (defun perg_round_shaft (x y z r h nrow gap_row gap_col) ; Set up local coordinate system (command "ucs" "origin" (list x y z) ) ; Set layer "round_shaft1" (command "layer" "set" "round_shaft1" "") ; Draw 2d_shaft (command "circle" (list x y) r) (setq ent1 (entlast)) ;Copy to a specified height (command "copy" ent1 "" (list x y z) (list x y (+ z h))) (setq ent2(entlast)) ;Set the number of tabulations (command "surftb1" "12") ;Create 3d_shaft (command "rulesurf" ent1 ent2) (setq ent3(entlast)) ;Varible 'elist' gets the result of 'rarry' function (setq elist (rarray ent3 nrow 2 gap_row gap_col)) ;Create axonometric view. (command "vpoint" (list -1 -1 1) ) ;Reset the ucs to world-coordinate-system (command "ucs" "world") ;Make 'elist' as a block for "nagakura" program (nt_make_ablock elist) ) ; end of defun ;Define a type with its symbolic contents and shape specification (nt_def_type "perg_round_shaft" 'perg_round_shaft '(("xo" . 0) ("yo" . 0) ("zo" . 0) ("r" . 12) ("h" . 240) ("nrow" . 14) ("gap_row" . 120) ("gap_col" . 120))) ; Test the function defined above with various parameter values. (defun demo() (command "limits" (list -300 -300) (list 300 300)) (perg_round_shaft 0 0 0 12 240 14 120 120 ) (command "hide" ) (redraw) ) ;Print message in double quotations (princ "(perg_round_shaft x y z r h nrow ncol gap_row gap_col ) (demo)") ;Outputs a carriage return to the screen and returns 'nil' (terpri)