📄 mvsetup.lsp
字号:
(defun mv_npv (ord_1 amnt_1 ord_2 amnt_2)
(command "_.UCS" ord_1 amnt_1)
(command "_.UCS" ord_2 amnt_2)
(command "_.PLAN" "" )
(command "_.UCS" "_P")
(command "_.UCS" "_P")
(princ)
)
;;;
;;;Get the Mview viewport whose number we have in vp_n.
;;;
;;; mv_gvp == MView_Get_ViewPort
;;;
(defun mv_gvp (num sset / j vp ss_len cont)
(setq ss_len (sslength sset)
j 0
cont T
)
(while (and cont (< j ss_len))
(if (= (cdr(assoc 69 (setq vp (entget (ssname sset j))))) num)
(setq cont nil)
)
(setq j (1+ j))
)
vp
)
;;;
;;; Change the view into all Mview viewports.
;;;
;;; mv_cav == MView_Change_All_Views
;;;
(defun mv_cav (/ n sset vp_n vp m_4_iso)
(if need_z
(command "_.ZOOM" "_E")
)
(setq n 0
sset (ssget "_x" '((0 . "VIEWPORT")))
vp_n f_vp_n
)
(command "_.MSPACE")
;;(setvar "cvport" vp_n)
;; While we still have both viewports and view definitions for them...
(while (and (< n view_n) (<= (+ n vp_n) l_vp_n))
(setq vp (mv_gvp (+ n vp_n) sset))
(if m_4_iso
(command "_.MVIEW" "_on" (cdr (assoc -1 vp)) "")
)
(setvar "cvport" (+ n vp_n))
(cond
((= (nth (+ 3 n) vp_item_list) "PLAN")
(command "_.PLAN" "")
;;(mv_sus)
)
((= (nth (+ 3 n) vp_item_list) "FRONT")
(mv_npv "_x" "90" "_x" "0")
;;(mv_sus)
)
((= (nth (+ 3 n) vp_item_list) "RIGHT")
(mv_npv "_z" "90" "_x" "90")
;;Test for case when all 4 viewports can't be on. We
;;turn this one off so we can continue to the iso view.
(if (= maxact 4)
(progn
(command "_.MVIEW" "_OFF" (cdr (assoc -1 vp)) "")
(setq m_4_iso T)
)
)
;;(mv_sus)
)
((= (nth (+ 3 n) vp_item_list) "LEFT")
(mv_npv "_z" "-90" "_x" "90")
;;(mv_sus)
)
((= (nth (+ 3 n) vp_item_list) "ISO")
(command "_.VPOINT" "_R" "-45" "30")
;;(mv_sus)
)
(T
(princ "\nUndefined view definition in default file. ")
(exit)
)
)
(setq n (1+ n))
)
(command "_.PSPACE")
)
;;;
;;; Array other Mview viewports.
;;;
;;; mv_avp == MView_Array_ViewPorts
;;;
(defun mv_avp ( / dx dy)
(if (and (> (car mvs_p4) 1) (> (cadr mvs_p4) 1))
(progn
(setq dx (+ (car mvs_p5) (car mvs_p3)))
(setq dy (+ (cadr mvs_p5) (cadr mvs_p3)))
(command "_.ARRAY"
(entlast) ""
"_r"
(cadr mvs_p4)
(car mvs_p4)
(+ (cadr mvs_p5) (cadr mvs_p3))
(+ (car mvs_p5) (car mvs_p3))
)
)
(if (> (car mvs_p4) 1)
(progn
(setq dx (+ (car mvs_p5) (car mvs_p3)))
(command "_.ARRAY"
(entlast) ""
"_r"
(cadr mvs_p4)
(car mvs_p4)
(+ (car mvs_p5) (car mvs_p3))
)
)
(if (> (cadr mvs_p4) 1)
(progn
(setq dy (+ (cadr mvs_p5) (cadr mvs_p3)))
(command "_.ARRAY"
(entlast) ""
"_R"
(cadr mvs_p4)
(car mvs_p4)
(+ (cadr mvs_p5) (cadr mvs_p3))
)
)
)
)
)
)
;;;
;;; Check the number of active viewports plus the number of new
;;; viewports to be created to determine whether the allowable
;;; number of active viewports will be exceeded. If so, noff
;;; holds the number of viewports to turn off before creating
;;; the rest of the new ones.
;;;
;;; mv_cna == MView_Check_Number_of_Active_viewports
;;;
(defun mv_cna (/ sset ssl nsset nssl n temp total noff)
(setq sset (ssget "_x" '((0 . "viewport")))
ssl (sslength sset)
nsset (ssadd)
n 0
)
(while (< n ssl)
(setq temp (ssname sset n))
(if (> (cdr (assoc 68 (entget temp))) 0)
(ssadd temp nsset)
)
(setq n (1+ n))
)
(if (> (setq total (+ (setq nssl (sslength nsset))
(1- (* (car mvs_p4) (cadr mvs_p4)))
)
)
(setq maxact (getvar "maxactvp"))
)
(progn
(setq noff (- total maxact)
n 1
)
(if (> maxact 4)
(while (and (<= n noff) (< n (1- nssl)))
(setq temp (ssname nsset n))
(command "_.MVIEW" "_OFF" temp "")
(setq n (1+ n))
)
(while (< n (1- ssl))
(setq temp (ssname sset n))
(command "_.MVIEW" "_OFF" temp "")
(setq n (1+ n))
)
)
)
)
)
;;;
;;; Get the name of a Mview viewport.
;;;
;;; mv_gvn == MView_Get_Viewport_Name
;;;
(defun mv_gvn ()
(cdr(assoc 69 (entget(entlast))))
)
;;;
;;; Calculate the size of the individual viewports from the two
;;; corner points, mvs_p1 and mvs_p2, the interstitial distances
;;; held in mvs_p3, and the number of viewports held in mvs_p4.
;;;
;;; mv_cfp == MView_Calculate_First_Points
;;;
(defun mv_cfp (/ x y dx dy )
(mv_s2p 'mvs_p1 'mvs_p2)
;; Points are now sorted so that mvs_p1 IS lower left....
(setq x (- (car mvs_p2) (car mvs_p1))
y (- (cadr mvs_p2) (cadr mvs_p1))
dx (/ (- x (* (1- (car mvs_p4)) (car mvs_p3))) (car mvs_p4))
dy (/ (- y (* (1- (cadr mvs_p4)) (cadr mvs_p3))) (cadr mvs_p4))
p1 mvs_p1
p2 (mapcar '+ p1 (setq mvs_p5 (list dx dy 0)))
)
)
;;;
;;; Sort two points into lower-left to upper-right order.
;;;
;;; mv_s2p == MView_Sort_2_Points
;;;
(defun mv_s2p (_p1 _p2 / x y pt1 pt2 )
(setq pt1 (eval _p1)
pt2 (eval _p2)
)
(if (> (car pt1) (car pt2))
(setq x (car pt1)
pt1 (list (car pt2) (cadr pt1) 0.0)
pt2 (list x (cadr pt2) 0.0)
)
)
(if (> (cadr pt1) (cadr pt2))
(setq x (cadr pt1)
pt1 (list (car pt1) (cadr pt2) 0.0)
pt2 (list (car pt2) x 0.0)
)
)
(set _p1 pt1)
(set _p2 pt2)
)
;;;
;;; Get the number of viewports in X and Y.
;;; Sets the global mvs_p4 which is a point containing the X and Y
;;; amounts as the (car) and (cadr) of mvs_p4.
;;;
;;; mv_gnv == MView_Get_Number_of_Viewports_in_x_and_y
;;;
(defun mv_gnv (/ )
(if n_vp_x
(progn
(setq mvs_p4 (list (read n_vp_x) (read n_vp_y) 0))
)
(progn
(setq ans (getint "\nEnter number of viewports in X direction <1>: "))
(if (= (type ans) 'INT)
(setq mvs_p4 (list ans))
(setq mvs_p4 (list 1))
)
(setq ans (getint "\nEnter number of viewports in Y direction <1>: "))
(if (= (type ans) 'INT)
(setq mvs_p4 (append mvs_p4 (list ans 0)))
(setq mvs_p4 (append mvs_p4 (list 1 0)))
)
)
)
)
;;;
;;; Get the horizontal and vertical distances between the viewports.
;;; Sets the global mvs_p3 which is a point containing the X and Y
;;; interstitial distances as the (car) and (cadr) of mvs_p3.
;;;
;;; mv_gid == MView_Get_Interstitial_Distances
;;;
(defun mv_gid (/ )
(setq mvs_p3 (list 0.0 0.0 0.0))
(if (> (car mvs_p4) 1)
(progn
(setq ans (getdist (strcat
"\nSpecify distance between viewports in X direction <"
(mv_sts (car mvs_p3))
">: ")))
(if (= (type ans) 'REAL)
(setq mvs_p3 (list ans ans ans))
)
)
)
(if (> (cadr mvs_p4) 1)
(progn
(setq ans (getdist (strcat
"\nSpecify distance between viewports in Y direction <"
(mv_sts (cadr mvs_p3))
">: ")))
(if (= (type ans) 'REAL)
(setq mvs_p3 (list (car mvs_p3) ans (caddr mvs_p3)))
)
)
)
mvs_p3
)
;;;
;;; Get set up for creating viewports.
;;; Sets the globals mvs_p1 and mvs_p2 which are the corners of the
;;; allowable area for viewports in paperspace coordinates.
;;;
;;; mv_gba == MView_Get_Bounding_Area
;;;
(defun mv_gba (/ )
(if ll_crn
(initget 1 "Default")
(initget 1)
)
(graphscr)
(setq ans (getpoint
(if ll_crn
"\nBounding area for viewport(s). Default/<First point >: "
"\nSpecify first corner of bounding area for viewport(s): "
)
))
(if (= ans "Default")
(progn
(if ll_crn
(setq mvs_p1 ll_crn
mvs_p2 ur_crn
)
(progn
(princ "\nNo default points defined. ")
(exit)
)
)
)
(progn
(initget 1)
(setq mvs_p1 ans
mvs_p2 (getcorner mvs_p1 "\nSpecify opposite corner: ")
)
)
)
)
;;;
;;; Check that the corners given are on-screen. If not, zoom so they are.
;;;
;;; mv_cba == MView_Check_Bounding_Area
;;;
(defun mv_cba (/ vs vc ss dx dy)
(setq vs (getvar "viewsize")
vc (getvar "viewctr")
ss (getvar "screensize")
dx (* vs (/ (car ss) (cadr ss)))
)
(if (or (< (car mvs_p1) (- (car vc) (/ dx 2.0)))
(< (cadr mvs_p1) (- (cadr vc) (/ vs 2.0)))
(> (car mvs_p2) (+ (car vc) (/ dx 2.0)))
(> (cadr mvs_p2) (+ (cadr vc) (/ vs 2.0)))
)
(setq need_z T)
)
)
;;;
;;; Create a title block or Mview viewport layout from the code in the
;;; default file. This may be anything from inserting a block to actually
;;; drawing every component of the title block from scratch. Any
;;; single-line valid Lisp expression may be written in the default file
;;; after the DATA name.
;;;
;;; mv_cfd == MView_Create_From_Defaults
;;;
(defun mv_cfd (/ cont theCmd)
(setq cont T)
(while cont
(setq theCmd (mv_rpl))
(if (= (substr theCmd 1 8) "END_ITEM")
(progn
(setq cont nil)
)
(mv_etl theCmd)
)
)
)
;;;
;;; Evaluate the line or string passed in.
;;;
;;; mv_etl == MView_Evaluate_The_Line
;;;
(defun mv_etl (str / )
;(princ str)(terpri)
(if (eval(read str)) T nil)
)
;;;
;;; Read and parse out a line of the Lisp code found in the defaults
;;; file. This must be done so that literal strings may be written
;;; directly in the defaults file, without having to escape all of them.
;;; We will do the escaping here, if necessary.
;;;
;;; Return the escaped string
;;;
;;; mv_rpl == MView_Read_and_Parse_a_Line
;;;
(defun mv_rpl ( / line j k sl str)
(if (setq line (read-line deffi))
(progn
(setq j 1 k 1 sl (strlen line) str "")
(while (<= j sl)
(if (= (setq sb_str (substr line j k)) "\"")
(setq str (strcat str "\""))
(setq str (strcat str sb_str))
)
(setq j (1+ j))
)
)
(progn
(princ "\nNo lines left to read. ")
(exit)
)
)
str
)
;;;
;;; Create a default definitions file in the current
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -