;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; type1-iceray.lsp ;; ;; pentagon ice-rays ;; ;; may 21, 1999 ;; ;; haldane liew ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; supplemental utility programs ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; take an polyline entity and returns a list of the points. ;; example ((0 1) (1 1) (1 0)) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun entity_to_points (entity / index entity_info numsides) (setq index 12) (setq entity_info (entget entity)) (setq numsides (cdr (assoc 90 entity_info))) (repeat numsides (setq point (cdr (nth index entity_info))) (if (= index 12) (setq pointslist (cons point ())) (setq pointslist (cons point pointslist)) ) (setq index (+ index 4)) ) (reverse pointslist) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; big function to make the iceray ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun make-pentagon-iceray (x y ss_image) ;; create necessary layers (command "layer" "new" "boundingbox" "color" "blue" "boundingbox" "") (command "layer" "new" "wireframe" "color" "red" "wireframe" "") (command "layer" "new" "boundarypoint" "color" "white" "boundarypoint" "") (command "layer" "new" "shape" "color" "green" "shape" "") (command "ucs" "") ;; sort the pieces gathered by layer ;; pline = boundingbox, line = wireframe, point = boundarypoint (setq index 0) (setq num_entities (sslength ss_image)) (repeat num_entities (setq current_ent (ssname ss_image index)) (setq type (cdr (assoc 0 (entget current_ent)))) ;;(print type) (if (= type "LINE") (command "chprop" current_ent "" "layer" "wireframe" "")) (if (= type "LWPOLYLINE") (progn (command "chprop" current_ent "" "layer" "boundingbox" "") (setq bbox current_ent) ) ) (if (= type "POINT") (command "chprop" current_ent "" "layer" "boundarypoint" "")) (setq index (+ index 1)) ) ;; figure out the x and y axes (setq bboxpointlist (entity_to_points bbox)) (setq index 0 maxx (car (nth 0 bboxpointlist)) maxy (cadr (nth 0 bboxpointlist)) minx (car (nth 0 bboxpointlist)) miny (cadr (nth 0 bboxpointlist)) ) (repeat (length bboxpointlist) (setq curx (car (nth index bboxpointlist)) cury (cadr (nth index bboxpointlist)) ) (if (< curx minx) (setq minx curx)) (if (< cury miny) (setq miny cury)) (if (> curx maxx) (setq maxx curx)) (if (> cury maxy) (setq maxy cury)) (setq index (+ index 1)) ) ;;(print index) ;;(print maxx) ;;(print maxy) ;;(print minx) ;;(print miny) (setq x-dist (- maxx minx)) (setq y-dist (- maxy miny)) (command "ucs" "origin" (list minx miny)) ;; make x-rows by mirroring and flipping (repeat (- x 1) (command "copy" ss_image "" (list 0 0) (list 0 0)) ;; this makes it bilaterally symmetrical (command "rotate" ss_image "" (list x-dist (/ y-dist 2)) "180") (command "ucs" "origin" (list x-dist 0)) ) (command "ucs" "") (command "ucs" "origin" (list minx miny)) ;; grab a row of the shapes. (setq oneline (ssget "CP" (list (list 0 0) (list 0 y-dist) (list (* x x-dist) y-dist) (list (* x x-dist) 0)))) ;; make y-rows by arraying up. (if (> y 1) (command "array" oneline "" "rectangular" y "1" y-dist)) (command "ucs" "") (command "ucs" "origin" (list minx miny)) (command "layer" "set" "wireframe" "") (command "rectangle" (list 0 0) (list (* x x-dist) (* y y-dist))) (command "layer" "off" "boundingbox" "") (setq ss_points (ssget "cp" (list (list 0 0) (list 0 (* y y-dist)) (list (* x x-dist) (* y y-dist)) (list (* x x-dist) 0)) '((0 . "POINT")))) (command "layer" "set" "shape" "") (command "ucs" "") (setq index 0) (repeat (sslength ss_points) (setq cur_point (entget (ssname ss_points index))) (if (/= cur_point nil) (progn ;; original line of code ;;(command "-boundary" (cdr (assoc 10 cur_point)) "") (command "ucs" "origin" (list minx miny)) (setq boundaryset (ssget "cp" (list (list 0 0) (list 0 (* y y-dist)) (list (* x x-dist) (* y y-dist)) (list (* x x-dist) 0)))) (command "ucs" "") (command "-boundary" "a" "b" "n" boundaryset "" "x" (cdr (assoc 10 cur_point)) "") ;; needs this line if the over a certain number of elements ;;(command "-boundary" (cdr (assoc 10 cur_point)) "y" "") (setq last_polygon (entlast)) ;;(print (entget last_polygon)) (setq ss_set (ssget "cp" (entity_to_points last_polygon) '((0 . "POINT")))) (if (> (sslength ss_set) 0) (progn (setq i 0) (repeat (sslength ss_set) (setq nex_point (entget (ssname ss_set i))) ;;(print "next")(print nex_point) ;;(print "cur") (print cur_point) (if (/= (cadr (assoc 10 nex_point)) (cadr (assoc 10 cur_point))) (entdel (ssname ss_set i)) ) (setq i (+ i 1)) ) ) ) ) ) (setq index (+ index 1)) ) (command "layer" "off" "wireframe" "") (command "ucs" "") ;; option to make the shapes into 3d shapes below (setq totalminx minx totalminy miny totalmaxx (+ minx (* x x-dist)) totalmaxy (+ miny (* y y-dist))) (setq boundarylist (list (list totalminx totalminy) (list totalminx totalmaxy) (list totalmaxx totalmaxy) (list totalmaxx totalminy))) (setq offset_thickness (* (distance (list totalminx totalminy) (list totalmaxx totalmaxy)) 0.008)) (setq total (ssget "CP" boundarylist '((0 . "LWPOLYLINE")))) (setq num_objects (sslength total)) (setq i 0) (repeat num_objects (setq cur_entity (ssname total i)) (setq cur_points (entity_to_points cur_entity)) (setq getinnerpoint (ssget "WP" cur_points '((0 . "POINT")))) (setq innerpoint (cdr (assoc 10 (entget (ssname getinnerpoint 0))))) (command "offset" offset_thickness cur_entity innerpoint "") (setq innerframe (entlast)) (command "extrude" innerframe "" offset_thickness 0) (setq innerframe (entlast)) (command "extrude" cur_entity "" offset_thickness 0) (setq outerframe (entlast)) (command "subtract" outerframe "" innerframe "") (setq i (+ i 1)) ) (command "pline" (list totalminx totalminy) (list totalminx totalmaxy) (list totalmaxx totalmaxy) (list totalmaxx totalminy) "c" "") (setq cur_entity (entlast)) (command "offset" offset_thickness cur_entity (list (- minx 1) (- miny 1)) "") (setq innerframe (entlast)) (command "extrude" innerframe "" offset_thickness 0) (setq innerframe (entlast)) (command "extrude" cur_entity "" offset_thickness 0) (setq outerframe (entlast)) (command "subtract" innerframe "" outerframe "") ;; tidy up (command "layer" "on" "*" "") (command "layer" "off" "shape" "yes" "") (command "erase" "c" (list totalminx totalminy) (list totalmaxx totalmaxy) "") (command "layer" "off" "boundarypoint" "") (command "layer" "on" "shape" "") (setq total (ssget "CP" boundarylist)) (command "union" total "") (command "zoom" "extents") ) ;; end of make-pentagon-iceray ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; drivers for function ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun c:pentice () ;; get user input (print "\nSelect initial shape:") (setq ss_init_rect (ssget)) (setq x_size (getint "\nX-dimension:")) (setq y_size (getint "\nY-dimension:")) (make-pentagon-iceray x_size y_size ss_init_rect) ) (defun pentice() (print "\nSelect initial shape:") (setq ss_init_rect (ssget)) (setq x_size (getint "\nX-dimension:")) (setq y_size (getint "\nY-dimension:")) (make-pentagon-iceray x_size y_size ss_init_rect) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; demo ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun c:demo () (command "pline" (list 0 0) (list 0 36.1803) (list 28.5317 36.1803) (list 28.5317 0) "c") (command "line" (list 0 18.0902) (list 4.7553 32.7254) "") (command "line" (list 0 36.1803) (list 14.2658 25.8156) "") (command "line" (list 14.2658 25.8156) (list 28.5317 36.1803) "") (command "line" (list 23.7764 32.7254) (list 28.5317 18.0902) "") (command "line" (list 2.5101 25.8156) (list 26.0216 25.8156) "") (command "point" (list 14.2658 9.0451)) (command "point" (list 6.5716 29.2705)) (command "point" (list 21.9601 29.2705)) (command "point" (list 2.9721 31.7597)) (command "point" (list 25.5596 31.7597)) (command "point" (list 14.2658 32.7254)) (command "zoom" "extents") (command "zoom" ".1x") (pentice) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; end of file ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;