neekcotrack Posted August 25, 2008 Author Posted August 25, 2008 Is there a way to put it in this format: (defun c:setup ( / SHEET SCALE) (initget "1 2 3 4") (setq SHEET (getkword "\nEnter Sheet [1]22X34,[2]24X36,[3]30X42,[4]36X48: ")) (initget "1 2 3 4 5 6 7 8") (setq SCALE (getkword "\nEnter Scale [1]FULL,[2]1/2,[3]1/4,[4]1/8,[5]1/20,[6]1/30,[7]1/40,[8]1/50: ")) (cond ((= SHEET "1") ;; 22X34 (cond ((= SCALE "1") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "2") (command "DIMSCALE" "24" "LTSCALE" "12") ) ((= SCALE "3") (command "DIMSCALE" "48" "LTSCALE" "24") ) ((= SCALE "4") (command "DIMSCALE" "96" "LTSCALE" "48") ) ((= SCALE "5") (command "DIMSCALE" "240" "LTSCALE" "120") ) ((= SCALE "6") (command "DIMSCALE" "360" "LTSCALE" "180") ) ((= SCALE "7") (command "DIMSCALE" "480" "LTSCALE" "240") ) ((= SCALE "8") (command "DIMSCALE" "600" "LTSCALE" "300") ) ) ;_ cond ) ;_ cond ((= SHEET "2") ;; 24X36 (cond ((= SCALE "1") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "2") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "3") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "4") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "5") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "6") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "7") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "8") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ) ;_ cond ) ;_ cond ((= SHEET "3") ;; 30X42 (cond ((= SCALE "1") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "2") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "3") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "4") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "5") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "6") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "7") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "8") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ) ;_ cond ) ;_ cond ((= SHEET "4") ;; 36X48 (cond ((= SCALE "1") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "2") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "3") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "4") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "5") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "6") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "7") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "8") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ) ;_ cond ) ;_ cond ) ;_ cond (princ) ) ;_ defun c:setup Thanks again. Quote
neekcotrack Posted August 25, 2008 Author Posted August 25, 2008 With that way it is easier for me modify in the future. I can't get everything to work that way. Like the sheets delete when I pick the sheets at the beginning and the viewport size change to the sheet. Quote
Strix Posted August 25, 2008 Posted August 25, 2008 so what does this Lisp do? (so we can have a better title in case it's useful for somebody else) Quote
Footpeg Posted August 25, 2008 Posted August 25, 2008 With that way it is easier for me modify in the future. I can't get everything to work that way. Like the sheets delete when I pick the sheets at the beginning and the viewport size change to the sheet. Try this: (defun c:setup ( / SHEET SCALE SF1) (initget "1 2 3 4 Exit") (setq SHEET (getkword "\nEnter Sheet [1]22X34,[2]24X36,[3]30X42,[4]36X48/<Exit>: ")) (if (or (not SHEET) (= SHEET "Exit")) (exit)) (initget "1 2 3 4 5 6 7 8 9 Exit") (setq SCALE (getkword "\nEnter Scale [1]FULL,[2]1/2,[3]1/4,[4]1/8,[5]1/20,[6]1/30,[7]1/40,[8]1/50,[9]custom/<Exit>: ")) (if (or (not SCALE) (= SCALE "Exit")) (exit)) (setq SCALE (cond ((= SCALE "1") 1.0) ((= SCALE "2") 24.0) ((= SCALE "3") 48.0) ((= SCALE "4") 96.0) ((= SCALE "5") 240.0) ((= SCALE "6") 360.0) ((= SCALE "7") 480.0) ((= SCALE "8") 600.0) ((= SCALE "9") (initget "Exit") (setq SF1 (getreal "\nEnter the desired scale factor/<Exit>: ")) (if (or (not SF1) (= SF1 "Exit")) (exit)) SF1 ) ;_ c9 ) ;_ cond ) ;_ setq (command ".DIMSCALE" SCALE ".LTSCALE" (/ SCALE 2.0)) (cond ((= SHEET "1") ;; 22X34 ;; DO SOMETHING FOR THIS SHEET ) ;_ c1 ((= SHEET "2") ;; 24X36 ;; DO SOMETHING FOR THIS SHEET ) ;_ c2 ((= SHEET "3") ;; 30X42 ;; DO SOMETHING FOR THIS SHEET ) ;_ c3 ((= SHEET "4") ;; 36X48 ;; DO SOMETHING FOR THIS SHEET ) ;_ c4 ) ;_ cond (princ "\nDimscale = ") (princ (getvar "dimscale")) (princ "\nLTscale = ") (princ (getvar "ltscale")) (princ) ) ;_ defun c:setup Footpeg Quote
neekcotrack Posted August 25, 2008 Author Posted August 25, 2008 I just want to use this and just add one more option under each sheet for a custom option. Is that possible. Once I get that to work I will updated the other sheets code like I did for the 22x34 sheet. This lisp will auto setup your sheet ready to add xrefs and start designing. (defun c:setup ( / SHEET SCALE) (initget "1 2 3 4") (setq SHEET (getkword "\nEnter Sheet [1]22X34,[2]24X36,[3]30X42,[4]36X48: ")) (initget "1 2 3 4 5 6 7 8") (setq SCALE (getkword "\nEnter Scale [1]FULL,[2]1/2,[3]1/4,[4]1/8,[5]1/20,[6]1/30,[7]1/40,[8]1/50: ")) (cond ((= SHEET "1") ;; 22X34 (COMMAND "_.LAYOUT" "D" "24X36" "_.LAYOUT" "D" "30X42" "_.LAYOUT" "D" "36X48") (COMMAND "_.LAYER" "S" "DEFPOINTS" "" "MODEL") (cond ((= SCALE "1") (COMMAND "RECTANG" "0,0" "34,22" "_.ZOOM" "C" "17,11" "24") (COMMAND "DIMSCALE" "1" "LTSCALE" ".5") (COMMAND "_.LAYOUT" "S" "22x34" "ORTHO" "ON" "_.VPORTS" "P" "2,2" "@30<0" "@18<90" "@30<180" "@18<270" "") (COMMAND "MSPACE" "_.ZOOM" "C" "17,11" "24" "_.ZOOM" "1/1XP" "PSPACE" "_.ZOOM" "A") (COMMAND "_.LAYER" "S" "0" "LO" "DEFPOINTS" "") ) ((= SCALE "2") (COMMAND "RECTANG" "0,0" "816,528" "_.ZOOM" "C" "408,264" "576") (COMMAND "DIMSCALE" "24" "LTSCALE" "12") (COMMAND "_.LAYOUT" "S" "22x34" "ORTHO" "ON" "_.VPORTS" "P" "2,2" "@30<0" "@18<90" "@30<180" "@18<270" "") (COMMAND "MSPACE" "_.ZOOM" "C" "408,264" "576" "_.ZOOM" "1/24XP" "PSPACE" "_.ZOOM" "A") (COMMAND "_.LAYER" "S" "0" "LO" "DEFPOINTS" "") ) ((= SCALE "3") (COMMAND "RECTANG" "0,0" "1632,1056" "_.ZOOM" "C" "816,528" "1152") (COMMAND "DIMSCALE" "48" "LTSCALE" "24") (COMMAND "_.LAYOUT" "S" "22x34" "ORTHO" "ON" "_.VPORTS" "P" "2,2" "@30<0" "@18<90" "@30<180" "@18<270" "") (COMMAND "MSPACE" "_.ZOOM" "C" "816,528" "1152" "_.ZOOM" "1/48XP" "PSPACE" "_.ZOOM" "A") (COMMAND "_.LAYER" "S" "0" "LO" "DEFPOINTS" "") ) ((= SCALE "4") (COMMAND "RECTANG" "0,0" "3264,2112" "_.ZOOM" "C" "1632,1056" "2304") (COMMAND "DIMSCALE" "96" "LTSCALE" "48") (COMMAND "_.LAYOUT" "S" "22x34" "ORTHO" "ON" "_.VPORTS" "P" "2,2" "@30<0" "@18<90" "@30<180" "@18<270" "") (COMMAND "MSPACE" "_.ZOOM" "C" "1632,1056" "2304" "_.ZOOM" "1/96XP" "PSPACE" "_.ZOOM" "A") (COMMAND "_.LAYER" "S" "0" "LO" "DEFPOINTS" "") ) ((= SCALE "5") (COMMAND "RECTANG" "0,0" "8160,5280" "_.ZOOM" "C" "4080,2640" "5760") (COMMAND "DIMSCALE" "240" "LTSCALE" "120") (COMMAND "_.LAYOUT" "S" "22x34" "ORTHO" "ON" "_.VPORTS" "P" "2,2" "@30<0" "@18<90" "@30<180" "@18<270" "") (COMMAND "MSPACE" "_.ZOOM" "C" "4080,2640" "5760" "_.ZOOM" "1/240XP" "PSPACE" "_.ZOOM" "A") (COMMAND "_.LAYER" "S" "0" "LO" "DEFPOINTS" "") ) ((= SCALE "6") (COMMAND "RECTANG" "0,0" "12240,7920" "_.ZOOM" "C" "6120,3960" "8640") (COMMAND "DIMSCALE" "360" "LTSCALE" "180") (COMMAND "_.LAYOUT" "S" "22x34" "ORTHO" "ON" "_.VPORTS" "P" "2,2" "@30<0" "@18<90" "@30<180" "@18<270" "") (COMMAND "MSPACE" "_.ZOOM" "C" "6120,3960" "8640" "_.ZOOM" "1/360XP" "PSPACE" "_.ZOOM" "A") (COMMAND "_.LAYER" "S" "0" "LO" "DEFPOINTS" "") ) ((= SCALE "7") (COMMAND "RECTANG" "0,0" "16320,10560" "_.ZOOM" "C" "8160,5280" "11520") (COMMAND "DIMSCALE" "480" "LTSCALE" "240") (COMMAND "_.LAYOUT" "S" "22x34" "ORTHO" "ON" "_.VPORTS" "P" "2,2" "@30<0" "@18<90" "@30<180" "@18<270" "") (COMMAND "MSPACE" "_.ZOOM" "C" "8160,5280" "11520" "_.ZOOM" "1/480XP" "PSPACE" "_.ZOOM" "A") (COMMAND "_.LAYER" "S" "0" "LO" "DEFPOINTS" "") ) ((= SCALE "8") (COMMAND "RECTANG" "0,0" "20400,13200" "_.ZOOM" "C" "10200,6600" "14400") (COMMAND "DIMSCALE" "600" "LTSCALE" "300") (COMMAND "_.LAYOUT" "S" "22x34" "ORTHO" "ON" "_.VPORTS" "P" "2,2" "@30<0" "@18<90" "@30<180" "@18<270" "") (COMMAND "MSPACE" "_.ZOOM" "C" "10200,6600" "14400" "_.ZOOM" "1/600XP" "PSPACE" "_.ZOOM" "A") (COMMAND "_.LAYER" "S" "0" "LO" "DEFPOINTS" "") ) ) ;_ cond ) ;_ cond ((= SHEET "2") ;; 24X36 (cond ((= SCALE "1") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "2") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "3") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "4") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "5") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "6") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "7") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "8") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ) ;_ cond ) ;_ cond ((= SHEET "3") ;; 30X42 (cond ((= SCALE "1") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "2") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "3") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "4") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "5") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "6") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "7") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "8") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ) ;_ cond ) ;_ cond ((= SHEET "4") ;; 36X48 (cond ((= SCALE "1") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "2") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "3") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "4") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "5") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "6") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "7") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "8") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ) ;_ cond ) ;_ cond ) ;_ cond (princ) ) ;_ defun c:setup Thanks for everything!!!!!!!! Quote
Footpeg Posted August 26, 2008 Posted August 26, 2008 I just want to use this and just add one more option under each sheet for a custom option. Is that possible. Once I get that to work I will updated the other sheets code like I did for the 22x34 sheet. Do you mean like this? (defun c:setup ( / SHEET SCALE CSCALE SheetX SheetY) (initget "1 2 3 4 Exit") (setq SHEET (getkword "\nEnter Sheet [1]22X34,[2]24X36,[3]30X42,[4]36X48/<Exit>: ")) (if (or (not SHEET) (= SHEET "Exit")) (exit)) (initget "1 2 3 4 5 6 7 8 9 Exit") (setq SCALE (getkword "\nEnter Scale [1]FULL,[2]1/2,[3]1/4,[4]1/8,[5]1/20,[6]1/30,[7]1/40,[8]1/50,[9]custom/<Exit>: ")) (if (or (not SCALE) (= SCALE "Exit")) (exit)) (if (= SCALE "9") (progn ;; Get a custom scale factor. (initget "Exit") (setq CSCALE (getreal "\nEnter the desired scale factor (e.g. 16.0 for 3/4\"=1')/<Exit>: ")) (if (or (not CSCALE) (= CSCALE "Exit")) (exit)) ) ;_ progn ) ;_ if (cond ((= SHEET "1") ;; 22X34 (SETQ SheetX 34.0 SheetY 22.0 ) ;_ setq (COMMAND "_.LAYOUT" "D" "24X36" "_.LAYOUT" "D" "30X42" "_.LAYOUT" "D" "36X48") (COMMAND "_.LAYOUT" "N" (strcat (rtos SheetY 2 0) "X" (rtos SheetX 2 0))) (COMMAND "_.LAYER" "S" "DEFPOINTS" "" "MODEL") (cond ((= SCALE "1") (COMMAND "RECTANG" "0,0" "34,22" "_.ZOOM" "C" "17,11" "24") (COMMAND "DIMSCALE" "1" "LTSCALE" ".5") (COMMAND "_.LAYOUT" "S" "22x34" "ORTHO" "ON" "_.VPORTS" "P" "2,2" "@30<0" "@18<90" "@30<180" "@18<270" "") (COMMAND "MSPACE" "_.ZOOM" "C" "17,11" "24" "_.ZOOM" "1/1XP" "PSPACE" "_.ZOOM" "A") (COMMAND "_.LAYER" "S" "0" "LO" "DEFPOINTS" "") ) ((= SCALE "2") (COMMAND "RECTANG" "0,0" "816,528" "_.ZOOM" "C" "408,264" "576") (COMMAND "DIMSCALE" "24" "LTSCALE" "12") (COMMAND "_.LAYOUT" "S" "22x34" "ORTHO" "ON" "_.VPORTS" "P" "2,2" "@30<0" "@18<90" "@30<180" "@18<270" "") (COMMAND "MSPACE" "_.ZOOM" "C" "408,264" "576" "_.ZOOM" "1/24XP" "PSPACE" "_.ZOOM" "A") (COMMAND "_.LAYER" "S" "0" "LO" "DEFPOINTS" "") ) ((= SCALE "3") (COMMAND "RECTANG" "0,0" "1632,1056" "_.ZOOM" "C" "816,528" "1152") (COMMAND "DIMSCALE" "48" "LTSCALE" "24") (COMMAND "_.LAYOUT" "S" "22x34" "ORTHO" "ON" "_.VPORTS" "P" "2,2" "@30<0" "@18<90" "@30<180" "@18<270" "") (COMMAND "MSPACE" "_.ZOOM" "C" "816,528" "1152" "_.ZOOM" "1/48XP" "PSPACE" "_.ZOOM" "A") (COMMAND "_.LAYER" "S" "0" "LO" "DEFPOINTS" "") ) ((= SCALE "4") (COMMAND "RECTANG" "0,0" "3264,2112" "_.ZOOM" "C" "1632,1056" "2304") (COMMAND "DIMSCALE" "96" "LTSCALE" "48") (COMMAND "_.LAYOUT" "S" "22x34" "ORTHO" "ON" "_.VPORTS" "P" "2,2" "@30<0" "@18<90" "@30<180" "@18<270" "") (COMMAND "MSPACE" "_.ZOOM" "C" "1632,1056" "2304" "_.ZOOM" "1/96XP" "PSPACE" "_.ZOOM" "A") (COMMAND "_.LAYER" "S" "0" "LO" "DEFPOINTS" "") ) ((= SCALE "5") (COMMAND "RECTANG" "0,0" "8160,5280" "_.ZOOM" "C" "4080,2640" "5760") (COMMAND "DIMSCALE" "240" "LTSCALE" "120") (COMMAND "_.LAYOUT" "S" "22x34" "ORTHO" "ON" "_.VPORTS" "P" "2,2" "@30<0" "@18<90" "@30<180" "@18<270" "") (COMMAND "MSPACE" "_.ZOOM" "C" "4080,2640" "5760" "_.ZOOM" "1/240XP" "PSPACE" "_.ZOOM" "A") (COMMAND "_.LAYER" "S" "0" "LO" "DEFPOINTS" "") ) ((= SCALE "6") (COMMAND "RECTANG" "0,0" "12240,7920" "_.ZOOM" "C" "6120,3960" "8640") (COMMAND "DIMSCALE" "360" "LTSCALE" "180") (COMMAND "_.LAYOUT" "S" "22x34" "ORTHO" "ON" "_.VPORTS" "P" "2,2" "@30<0" "@18<90" "@30<180" "@18<270" "") (COMMAND "MSPACE" "_.ZOOM" "C" "6120,3960" "8640" "_.ZOOM" "1/360XP" "PSPACE" "_.ZOOM" "A") (COMMAND "_.LAYER" "S" "0" "LO" "DEFPOINTS" "") ) ((= SCALE "7") (COMMAND "RECTANG" "0,0" "16320,10560" "_.ZOOM" "C" "8160,5280" "11520") (COMMAND "DIMSCALE" "480" "LTSCALE" "240") (COMMAND "_.LAYOUT" "S" "22x34" "ORTHO" "ON" "_.VPORTS" "P" "2,2" "@30<0" "@18<90" "@30<180" "@18<270" "") (COMMAND "MSPACE" "_.ZOOM" "C" "8160,5280" "11520" "_.ZOOM" "1/480XP" "PSPACE" "_.ZOOM" "A") (COMMAND "_.LAYER" "S" "0" "LO" "DEFPOINTS" "") ) ((= SCALE "8") (COMMAND "RECTANG" "0,0" "20400,13200" "_.ZOOM" "C" "10200,6600" "14400") (COMMAND "DIMSCALE" "600" "LTSCALE" "300") (COMMAND "_.LAYOUT" "S" "22x34" "ORTHO" "ON" "_.VPORTS" "P" "2,2" "@30<0" "@18<90" "@30<180" "@18<270" "") (COMMAND "MSPACE" "_.ZOOM" "C" "10200,6600" "14400" "_.ZOOM" "1/600XP" "PSPACE" "_.ZOOM" "A") (COMMAND "_.LAYER" "S" "0" "LO" "DEFPOINTS" "") ) ((= SCALE "9") (COMMAND "_.RECTANG" "0,0" (list (* SheetX CSCALE) (* SheetY CSCALE))) (COMMAND "_.ZOOM" "C" (list (* SheetX 0.5 CSCALE) (* SheetY 0.5 CSCALE)) (* (+ 2.0 SheetY) CSCALE)) (COMMAND "_.DIMSCALE" CSCALE "_.LTSCALE" (/ CSCALE 2.0)) (COMMAND "_.LAYOUT" "S" (strcat (rtos SheetY 2 0) "x" (rtos SheetX 2 0)) "_.ORTHO" "ON") ;; I added the erase last command. Is that what you intend? (COMMAND "_.ERASE" "L" "") (COMMAND "_.VPORTS" "P" "2,2" (list (- SheetX 2.0) 2.0) (list (- SheetX 2.0) (- SheetY 2.0)) (list 2.0 (- SheetY 2.0)) "C") (COMMAND "_.MSPACE" "_.ZOOM" "C" (list (* SheetX 0.5 CSCALE) (* SheetY 0.5 CSCALE)) (* (+ 2.0 SheetY) CSCALE)) (COMMAND "_.ZOOM" (strcat (rtos (/ 1.0 CSCALE)) "XP")) (COMMAND "_.PSPACE" "_.ZOOM" "A") (COMMAND "_.LAYER" "S" "0" "LO" "DEFPOINTS" "") ) ) ;_ cond ) ;_ cond ((= SHEET "2") ;; 24X36 (cond ((= SCALE "1") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "2") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "3") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "4") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "5") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "6") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "7") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "8") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ) ;_ cond ) ;_ cond ((= SHEET "3") ;; 30X42 (cond ((= SCALE "1") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "2") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "3") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "4") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "5") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "6") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "7") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "8") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ) ;_ cond ) ;_ cond ((= SHEET "4") ;; 36X48 (cond ((= SCALE "1") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "2") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "3") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "4") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "5") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "6") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "7") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ((= SCALE "8") (command "DIMSCALE" "1" "LTSCALE" ".5") ) ) ;_ cond ) ;_ cond ) ;_ cond (princ "\nDimscale = ") (princ (getvar "dimscale")) (princ "\nLTscale = ") (princ (getvar "ltscale")) (princ) ) ;_ defun c:setup I added the "erase" "last" command after first entering the layout to eliminate the default viewport. If that's not what you want, just remove it? You should also consider combining all of the "standard" scales into a single set of commands (instead of a duplicate set for every scale for every sheet), using the same technique as I used for the custom scale. In fact, that code can be used for all of the others. You would just have to convert the users selections to scale factors and assign that value to the variable CSCALE. Footpeg Quote
neekcotrack Posted August 26, 2008 Author Posted August 26, 2008 Can you show me what you mean? Do you want me to finish the others and then submit it from there you can modify up to you? Quote
Footpeg Posted August 26, 2008 Posted August 26, 2008 Can you show me what you mean? Do you want me to finish the others and then submit it from there you can modify up to you? No, it's better not to code the other sheet sizes until you work out everything for one sheet size, just as you have been doing. What I mean is your current coding has a "cond" for each of your standard scale factors (1 through 9), and each of them does the same thing, except with values based upon the scale factor. But, as you can see by the code for the "custom" scale factor, one set of commands will work for any scale factors, be it Imperial, Metric, etc. As such, there is no need to repeat the commands for conditions 1 through 8, provided you add coding that converts what the user enters at the scale factor prompt to the appropriate scale factor. For example, if the user enters "1", the code needs to change that to 1.0, and if the user enters "2", the code needs to change that to 24.0. Here's one way, using the "cond" statement which you seem to be comfortable with: (setq CSCALE (cond ((= SCALE "1") 1.0) ((= SCALE "2") 24.0) ((= SCALE "3") 48.0) ((= SCALE "4") 96.0) ((= SCALE "5") 240.0) ((= SCALE "6") 360.0) ((= SCALE "7") 480.0) ((= SCALE "8") 600.0) ((= SCALE "9") ;; Get a custom scale factor. (initget "Exit") (setq CSCALE (getreal "\nEnter the desired scale factor (e.g. 16.0 for 3/4\"=1')/<Exit>: ")) (if (or (not CSCALE) (= CSCALE "Exit")) (exit)) CSCALE ) ;_ c9 ) ;_ cond ) ;_ setq Another way is to use the method that CAB provided earlier, which is cleaner but more advanced. (setq SCALE (nth (1- (atoi SCALE)) '(1 24 48 96 240 360 480 600))) If you look carefully at the entire code that CAB posted earlier, it does what I'm talking about, although it can be modified further to eliminate all of the hard coded sizes (for example, the layout name, the viewport dimensions, and zoom sizes, like I did in what I submitted). All that said, if you are just learning AutoLisp, and I assume you are, there is nothing wrong with continuing with what you are comfortable with. You can always improve your coding as your skills develop. Whichever way you decide to go, always try to do it yourself before asking for help. Did you test what I submitted? Did it do what you intended? Footpeg Quote
neekcotrack Posted August 26, 2008 Author Posted August 26, 2008 It is just what I was looking for. Just a few things are acting up. The viewport scale is not coming in right but, I think it has something to do with the box in model space not being center to the center point. I think the box is being zoomed to all in the viewport so that throws the scale off. Thanks for all your help! Quote
Footpeg Posted August 26, 2008 Posted August 26, 2008 It is just what I was looking for. Just a few things are acting up. The viewport scale is not coming in right but, I think it has something to do with the box in model space not being center to the center point. I think the box is being zoomed to all in the viewport so that throws the scale off. The rectangle drawin in model space is centered in the viewport and the XP scale factor is correct, you just can't see the rectangle because of its size. That's because the rectangle drawn in model space represents the edges of the paper, but the viewport size in paper space is 4 units smaller in both directions. With the XP scale factor set to suit the scale, it is impossible for that size rectangle to appear in the viewport. Perhaps you did not intend to reduce the size of the viewport? I added code to draw a few objects in model space just to demonstrate the problem. Just delete those lines when you're done with testing. To verify the XP scale factor, LIST the viewport object. To activate the viewport, you have to return to MSPACE (see the line of code I added). Of course, since the defpoints layer is locked, you won't see it as a heavy line weight, but it will be highlighted and the crosshairs will be in that viewport. ((= SCALE "9") (COMMAND "_.RECTANG" "0,0" (list (* SheetX CSCALE) (* SheetY CSCALE))) ;;; Remove the next 7 lines when done testing (command ".color" "red") (COMMAND "_.RECTANG" (list (* 2.0 CSCALE) (* 2.0 CSCALE)) (list (* (- SheetX 2.0) CSCALE) (* (- SheetY 2.0) CSCALE))) (command "_.Line" (list (* 2.0 CSCALE) (* 2.0 CSCALE)) (list (* (- SheetX 2.0) CSCALE) (* (- SheetY 2.0) CSCALE)) "") (command "_.Line" (list (* 2.0 CSCALE) (* (- SheetY 2.0) CSCALE)) (list (* (- SheetX 2.0) CSCALE) (* 2.0 CSCALE)) "") (command "_.Circle" (list (* (/ SheetX 2.0) CSCALE) (* (/ SheetY 2.0) CSCALE)) (* (/ (- SheetY 4.0) 2.0) CSCALE)) (command "_.Circle" (list (* (/ SheetX 2.0) CSCALE) (* (/ SheetY 2.0) CSCALE)) (* (/ (- SheetX 4.0) 2.0) CSCALE)) (command ".color" "bylayer") ;;; Remove the previous 7 lines when done testing (COMMAND "_.ZOOM" "C" (list (* SheetX 0.5 CSCALE) (* SheetY 0.5 CSCALE)) (* (+ 2.0 SheetY) CSCALE)) (COMMAND "_.DIMSCALE" CSCALE "_.LTSCALE" (/ CSCALE 2.0)) (COMMAND "_.LAYOUT" "S" (strcat (rtos SheetY 2 0) "x" (rtos SheetX 2 0)) "_.ORTHO" "ON") (COMMAND "_.ERASE" "L" "") (COMMAND "_.VPORTS" "P" "2,2" (list (- SheetX 2.0) 2.0) (list (- SheetX 2.0) (- SheetY 2.0)) (list 2.0 (- SheetY 2.0)) "C") (COMMAND "_.MSPACE" "_.ZOOM" "C" (list (* SheetX 0.5 CSCALE) (* SheetY 0.5 CSCALE)) (* (+ 2.0 SheetY) CSCALE)) (COMMAND "_.ZOOM" (strcat (rtos (/ 1.0 CSCALE)) "XP")) (COMMAND "_.PSPACE" "_.ZOOM" "A") (COMMAND "_.LAYER" "S" "0" "LO" "DEFPOINTS" "") (COMMAND "_.MSPACE") ) ;_ c9 Footpeg Quote
neekcotrack Posted August 26, 2008 Author Posted August 26, 2008 The viewport is still scaling wrong hmmm. I tried doing 24 but it scales it to 3/8"=1'. Quote
Footpeg Posted August 26, 2008 Posted August 26, 2008 The viewport is still scaling wrong hmmm. I tried doing 24 but it scales it to 3/8"=1'. When you list the viewport, what does it say for "Scale relative to Paper space:"? Footpeg Quote
Footpeg Posted August 26, 2008 Posted August 26, 2008 Immediately after the setup completes, switch to paper space and use the LIST command to select the viewport rectangle. One of the things it will display in the text window is a value for "Scale relative to Paper space:". That's the XP scale factor. What does it say? Footpeg Quote
neekcotrack Posted August 26, 2008 Author Posted August 26, 2008 It says 5/128"XP that right. Ok I figured out no matter what scale you want your scale to be it will turn out to be 75% of that. Quote
Footpeg Posted August 26, 2008 Posted August 26, 2008 It says 5/128"XP that right. Ok I figured out no matter what scale you want your scale to be it will turn out to be 75% of that. Hmmm... No, it should be exactly 1 divided by the scale factor, or your plots will not be to scale. I'm also confused how you are getting a fraction for the value, I can only get a decimal value regardless of the Units setting. Can you enlighten me? Here's the entire sequence I get when I run Setup for sheet 22x24, and custom scale 24. It shows the XP scale as 0.0417 which is 1/2"=1'-0". Also, 75% of 0.0417 would be 0.031275, not 5/128, so I don't understand the 75% you state. Command: setup Enter Sheet [1]22X34,[2]24X36,[3]30X42,[4]36X48/: 1 Enter Scale [1]FULL,[2]1/2,[3]1/4,[4]1/8,[5]1/20,[6]1/30,[7]1/40,[8]1/50,[9]custom/: 9 Enter the desired scale factor (e.g. 16.0 for 3/4"=1')/: 24 Dimscale = 24.0 LTscale = 12.0 Command: PS PSPACE Command: LIST Select objects: L 1 found Select objects: VIEWPORT Layer: "defpoints" Space: Paper space Layout: 22X34 Visual Style: 2D Wireframe Handle = 44e Status: On and Active Scale relative to Paper space: 0.0417xp Annotation Scale: 1:1 View lock is on Clipping is on, clip entity handle = 44c center point, X=17.0000000 Y=11.0000000 Z=0.0000000 width 30.0000000 height 18.0000000 Command: Footpeg Quote
neekcotrack Posted August 26, 2008 Author Posted August 26, 2008 Mine keeps on finding two object pline and viewport Quote
Footpeg Posted August 26, 2008 Posted August 26, 2008 Mine keeps on finding two object polg and viewport If you do a LIST LAST in paper space, you will see only one object, that being the viewport. If you do LIST ALL, or select the viewport with the cursor, you will see the viewport and the lwpolyline that made the viewport. You can ignore the lwpolyline. Footpeg Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.