Листинг2.1 Основной файл проекта (*.LSP).
(defun torad (degree)
(* pi (/ degree 180.0))
)
(defun profile ()
(command "-osnap" "none");turning off object snap mode to avoid changes of input coordinates
(command "_arc" "0,0" "c" (setq p0 (list (- 0 rad) 0)) "a" (- 0 ang)); top arc creation
(command "_arc" "c" (setq p1 (polar p0 (- 0 (torad ang)) (* 2 rad)))
(setq p3 (polar p1 pi rad)) "a" (- 0 ang)); middle arc creation
(command "_arc" "c" (list 0 (cadr p1)) p3 "a" 90)
; bottom arc creation r1=2r(1-cos(ang))
(command "_mirror" "all" "" "0,0" "0,-1" ""); mirror part creation
(command "_region" "all" ""); conversion of contour to region
(command "_zoom" "e");zooming to extents
)
(defun write_script ()
(setq fscr (open "Z:\projection.scr" "w"))
(write-line "_PSPACE" fscr);switching to paper space
(write-line "_SOLVIEW" fscr);calling of SOLid VIEW command
;to start projection procedure
(write-line "_u" fscr);type of projection: main view
(write-line "" fscr);current UCS will be used for main view
(write-line "0.5" fscr);view scale
(write-line "120,240" fscr); view center in the paper space
(write-line "" fscr); view center OK
(write-line "90,280" fscr); the first corner of viewport
(write-line "150,200" fscr); the second corner of viewport
(write-line "main" fscr); name of the first view
(write-line "_o" fscr);type of projection: orthogonal view
(write-line "120,280" fscr); to select a side to project
; (on the frame of previous viewport)
(write-line "120,140" fscr); view center in the paper space
(write-line "" fscr); view center OK
(write-line "90,170" fscr); the first corner of viewport
(write-line "150,110" fscr); the second corner of viewport
(write-line "top" fscr); name of the second view
(write-line "" fscr); exit SOLVIEW
(write-line "_SOLDRAW" fscr); to finish the first projection
(write-line "90,280" fscr); select the first viewport
(write-line "" fscr); finishing the first projection
(write-line "_SOLDRAW" fscr); to finish the second projection
(write-line "90,170" fscr); select the second viewport
(write-line "" fscr); finishing the second projection
(write-line "mview" fscr); to creat new viewport for isometric projection
(write-line "90,90" fscr); the first corner of new veiwport
(write-line "150,30" fscr); the second corner of new veiwport
(write-line "_MSPACE" fscr); switching to model space in the new viewport
(write-line "_-view" fscr); Calling VIEW command for the new viewport
(write-line "_neiso" fscr); setting view direction for north-east isometric projection
(write-line "_SOLPROF" fscr); calling SOLid PROFile command to make isometric projection
(write-line "_l" fscr); selecting last object in the new viewport
(write-line "" fscr); finishing selection of objects to be projected
(write-line "Y" fscr); display hidden lines on separate layer?
(write-line "Y" fscr); project onto a plane?
(write-line "Y" fscr); delete tangential edges?
(write-line "_-layer" fscr); Calling LAYER command to freeze layers
;with model and hidden for the new viewport
(write-line "_set" fscr); change current layer
(write-line "main-VIS" fscr); to "main-VIS" (visible lines on main view)
(write-line "_freeze" fscr); freeze
(write-line "0" fscr); layer "0" - layer with the model
(write-line "_freeze" fscr); freeze
(write-line "main-HID" fscr); layer "0" - layer with hidden
;lines of the main view
(write-line "_freeze" fscr); freeze
(write-line "top-HID" fscr); layer "top-HID" - layer with hidden
;lines of the top view
(write-line "_freeze" fscr); freeze
(write-line "PH*" fscr); all layers with hidden lines of isometric views
(write-line "" fscr); return from LAYER command
(write-line "_PSPACE" fscr); return to paper space
(close fscr); closing script file
)
(defun projection ()
(vl-cmdf "_-layout" "_set" "layout1" (term_dialog))
; check for the first switching to "layout1"
(vl-cmdf "_-plot"; to adjust paper settingd for "layout1"
"y"; detailed configuration?
"layout1"; layout name
"Default Windows System Printer.pc3";output device name
"A4";paper size
"M";paper units (Millimeters)
"P";drawing orientation (Portrait)
"N";plot upside down?
"E";plot area (Extents)
"1:1";plot scale
"0,0";plot offset
"Y";plot with plotting styles?
"monochrome.ctb";plot style table
"Y";plot with lineweights?
"N";scale lineweights with plot scale?
"N";plot paper space first?
"N";hide paper space objects?
"N";write the plot to a file?
"Y";save changes to page setup?
"N";proceed with plot?
)
(vl-cmdf "_-layout" "_set" "layout1"); set current layout
(vl-cmdf "_erase" "_l" "");erase default viewport in "layout1"
(write_script)
(vl-cmdf "_script" "Z:\projection.scr")
)
(defun dome ()
(setq rad 50 ang 60 sides (/ 8 2))
(if (< (setq dlgDomeID (load_dialog "lisp03_Cb.dcl")) 0) (exit))
(print (strcat "dlgDomeID = " (itoa dlgDomeID) " "))
(if (not (new_dialog "dome_par" dlgDomeID)) (exit))
(action_tile "r1" "(setq rad (atof $value))")
(action_tile "a1" "(setq ang (atof $value))")
(action_tile "s1" "(setq sides (/ (atoi $value) 2))")
(setq dlgExitCode (start_dialog))
(unload_dialog dlgDomeID)
(print (strcat "dlgExitCode = " (itoa dlgExitcode) " "))
(print radius)
;(exit)
(vl-cmdf "_-layout" "_set" "Model"); set Model layout
(profile)
(command "_extrude" "0,0" "" 200 ""); extrusion of dome profile
(command "_ucs" "move" "0,0,100"); movement of user coordinate system
(command "_ucs" "new" "x" -90); rotation of user coordinate system
(command "_-array" "0,0" "" "p" "0,0" sides (* (/ 180 sides)
(1- sides))
""); creation of polar array of extruded profiles
(command "_intersect" "all" ""); creation the dome as an intersection of dome profiles
(command "_shademode" "_2d"); switching to 2D wireframe mode
(vl-cmdf "_ucs" "_p"); restore the previous UCS
(vl-cmdf "plan" ""); plan view for the first UCS
(projection)
)
Листинг 2.2 Файл описания диалогового окна lisp03_Cb.dcl, вызываемый основной программой.
dome_par: dialog{label="Dome parameters";
:edit_box{label="Radius:"; fixed_width="true"; key="r1";
edit_width=12; edit_limit=24; value="50";}
:edit_box{label="Angle:"; fixed_width="true"; key="a1";
edit_width=12; edit_limit=24; value="60";}
:edit_box{label="Number of sides:"; fixed_width="true"; key="s1";
edit_width=12; edit_limit=24; value="8";}
ok_button;
:errtile{label="No errors";}
}
Листинг 2.3 Файл сценария projection.scr, который создается в процессе выполнения основной программы и из нее же вызывается на исполнение.
_PSPACE
_SOLVIEW
_u
0.5
120,240
90,280
150,200
main
_o
120,280
120,140
90,170
150,110
top
_SOLDRAW
90,280
_SOLDRAW
90,170
mview
90,90
150,30
_MSPACE
_-view
_neiso
_SOLPROF
_l
Y
Y
Y
_-layer
_set
main-VIS
_freeze
_freeze
main-HID
_freeze
top-HID
_freeze
PH*
_PSPACE