⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mvsetup.lsp

📁 Autocad-2005-简体中文-解密版.zip
💻 LSP
📖 第 1 页 / 共 5 页
字号:
                  (if (> ll 3)
                    (setq ur_crn (nth 3 d_item_list)
                          li     (nth 4 d_item_list)
                    )
                    (setq ll_crn nil ur_crn nil)
                  )
                )
              )
              (if (= (type ur_crn) 'STR)
                (setq ll_crn (read ll_crn)
                      ur_crn (read ur_crn)
                )
              )
              ;;; Force the right units to be used for the scaling
              (cond
                ((= li "mm")
                  (if (= (strcase mv_utr T) "in")
                    (setq mv_utr "mm")
                  )
                )
                ((= li "in")
                  (if (= (strcase mv_utr T) "mm")
                    (setq mv_utr "in")
                  )
                )
              )
              (cond
                ((= (strcase mv_utr T) "mm")
                  (setq isc   25.4
                        mmsc  1.0
                        msc   1000.0
                        fsc   (* 12 25.4)
                  )
                )
                ((= (strcase mv_utr T) "m")
                  (setq isc   (/ 25.4 1000)
                        mmsc  (/ 1.0 1000)
                        msc   1.0
                        fsc   (/ (* 12 25.4) 1000)
                  )
                )
                ((= (strcase mv_utr T) "ft")
                  (setq isc   (/ 1.0 12)
                        mmsc  (/ 1.0 (* 12 25.4))
                        msc   (/ 1000.0 (* 12 25.4))
                        fsc   1.0
                  )
                )
                ((= (strcase mv_utr T) "in")
                  (setq isc   1.0
                        mmsc  (/ 1.0 25.4)
                        msc   (/ 1000.0 25.4)
                        fsc   12.0
                  )
                )
                (T
                  (princ "\nError: unit type not specified in default file.")
                  (exit)
                )
              )
            )
          )          
		  (cond             
            ((= li "in")                 ; And are defined in inches
              (command "_.SCALE" (entlast) "" "0,0" isc)
              (setq ll_crn (mapcar '(lambda (x) (* x isc)) ll_crn))
              (setq ur_crn (mapcar '(lambda (x) (* x isc)) ur_crn))
            )
            ((= li "ft")                 ; And are defined in feet
              (command "_.SCALE" (entlast) "" "0,0" fsc)
              (setq ll_crn (mapcar '(lambda (x) (* x fsc)) ll_crn))
              (setq ur_crn (mapcar '(lambda (x) (* x fsc)) ur_crn))
            )
            ((= li "mm")                 ; And are defined in millimeters
              (command "_.SCALE" (entlast) "" "0,0" mmsc)
              (setq ll_crn (mapcar '(lambda (x) (* x mmsc)) ll_crn))
              (setq ur_crn (mapcar '(lambda (x) (* x mmsc)) ur_crn))
            )
            ((= li "M")                 ; And are defined in meters
              (command "_.SCALE" (entlast) "" "0,0" msc)
              (setq ll_crn (mapcar '(lambda (x) (* x msc)) ll_crn))
              (setq ur_crn (mapcar '(lambda (x) (* x msc)) ur_crn))
            )
          )
          (command "_.ZOOM" "_E")
          (if mv_slr                      ; Set Limits requested
            (progn
              (setq temp (getvar "EXTMIN"))
              (setvar "LIMMIN" (list (car temp) (cadr temp)))
              (setq temp (getvar "EXTMAX"))
              (setvar "LIMMAX" (list (car temp) (cadr temp)))
            )
          )
        )
      )
      (setq ITEM_LIST nil)

      (setq deffi (close deffi))
      
    )
    (princ (strcat "\nCouldn't open the file " mv_xdf " for reading. "))
  )
)
;;;
;;; Pick options
;;;
;;; mv_pao == MView_Pick_An_Option
;;;
(defun mv_pao (str str1 / cont max_lines d_item_list)
  (setq cont T)
  (while cont
    (princ str1)
    (setq cur_ln (mv_rux str 1 (strlen str)))
    (setq ITEM_LIST nil)
    (setq max_lines (mv_lns (strcat "END_" str) 
                                          1 (+ 4 (strlen str))))
    (if (= str "MVIEWS")
      (setq d_item_list (mv_pfl max_lines 4 "Redisplay"  
        "\nEnter layout number to load or [Redisplay]: "))
      (setq d_item_list (mv_pfl max_lines 4 "Add Redisplay Delete"  
        "\nEnter number of title block to load or [Add/Delete/Redisplay]: "))
    )
    ;; 
    ;; Skip the title block insertion if "None" is selected.
    ;;
    (if (and (= (type d_item_list) 'LIST) (= (car d_item_list) "None"))
      (setq skip T)
      (setq skip nil)
    )
    ;;
    ;; If the Redisplay option is chosen, rewind the file by
    ;; Closing it, opening it again, and seeking to the start
    ;; of the NAMES section again.
    ;;
    (if cont
      (progn
        (if deffi (setq deffi (close deffi)))
        (if (null (setq deffi (mv_lfx mv_xdf "r")))
          (progn
            (princ (strcat "\nCouldn't open  " mv_xdf " for reading."))
            (setq cont nil)
          )
        )
      )
    )
  )
  d_item_list
)
;;;
;;; Title block insertion
;;; Check that the drawing exists and if not, try to create it
;;; from the definition, if it can be found.  If not,
;;; reject the selection.  If there is a definition, then
;;; execute it and perform the WBLOCK command, then
;;; insert the resulting block.
;;;
;;; mv_tbi == MView_Title_Block_Insertion
;;;
(defun mv_tbi ()
  ;; If an alternate layer has been specified, then set that layer for the
  ;; subsequent title block insertion or Xref.
  (if mv_nln
    (command "_.LAYER" "_SET" mv_nln "")
  )
  ;; 
  ;; a definition in the default file.  If that fails, then    
  (if (> (length d_item_list) 1) 
    (if (setq block_name (findfile (nth 1 d_item_list)))
      (if mv_uxr
        (mv_xtb block_name)
        (mv_itb block_name)
      )
      ;; Block named not found;  try to create it...
      (progn
        (setq block_name (nth 1 d_item_list))
        (setq e_last (cdr(assoc -1 (entget(entlast)))))
        (setq item_name (strcat "NAME - " (nth 0 d_item_list)))
        (if (mv_rux item_name 1 (strlen item_name))
          (mv_cfd)
        )
        (if (not (eq (cdr(assoc -1 (entget(entlast)))) e_last))
          (progn
            (setq sset (ssadd))   ; Create a null selection set.
            (while (setq e_last (if e_last (entnext e_last) (entnext)))
              (ssadd e_last sset) ; Add new entities to end of database.
            )
            (initget "Yes No")
            (setq ans (getkword (strcat
              "\nCreate a drawing named " block_name "? <Y>: ")))
            (if (/= ans "No")
              (progn
                (command "_.WBLOCK" block_name "" "0,0" sset "")
                (if mv_uxr
                  (mv_xtb block_name)
                  (mv_itb block_name)
                )
              )
              ;; Else do nothing...
            )
          )
          (progn
            (princ (strcat
              "\nCouldn't find a definition for block " block_name ". "))
            ;;(exit)
          )
        )
      )
    )
    (progn
      (setq d_item_list (strcat "NAME - " (nth 0 d_item_list)))
      (if (mv_rux d_item_list 1 (strlen d_item_list))
        (mv_cfd)
      )
    )
  )  
  (if mv_nln
    (command "_.LAYER" "_SET" mv_oln "") ; Reset old layer
  )
)
;;;
;;; Insert title blocks, no prompting for attributes.
;;;
;;; mv_itb == MView_Insert_Title_Block
;;;
(defun mv_itb (block_name / attreq_old)
  ;; Insert the block
  (setq attreq_old (getvar "attreq"))
  (setvar "attreq" 0)
  (command "_.INSERT" block_name "0,0" "" "" "")
  (setvar "attreq" attreq_old)
)
;;;
;;; Xref title blocks; variable attributes are ignored.
;;;
;;; mv_xtb == MView_Xref_Title_Block
;;;
(defun mv_xtb (block_name / b_def b_nam hasatt temp cont count)
  ;; Insert the block
  (command "_.XREF" "_ATTACH" block_name "0,0" "" "" "0")
)
;;;
;;; Create the mview viewports.
;;;
;;; mv_mvi == MView_MView_Insertion
;;;
(defun mv_mvi (/ n_vp_x n_vp_y i_l_len view_n p1 p2 ok_size)
  (if (> (length vp_item_list) 0) 
    (progn
      (if (> (length vp_item_list) 2) 
        (setq n_vp_x (nth 1 vp_item_list)
              n_vp_y (nth 2 vp_item_list)
        )
      )
      (if (> (setq i_l_len (length vp_item_list)) 3) 
        (setq view_n (- i_l_len 3))  ; Number of views defined.
        (setq view_n 0)
      )
      (setq d_item_name (strcat "VPSETNAME  - " (nth 0 vp_item_list)))
      (if (mv_rux d_item_name 1 (strlen d_item_name))
        (progn
          (mv_gba)                    ; Get bounding area
          (mv_s2p 'mvs_p1 'mvs_p2)
          (mv_gnv)                    ; Get number of viewport
          (mv_gid)                    ; Get interstitial distances
          (mv_cfp)                    ; Calculate first points
          (mv_cba)                    ; Check area is on-screen
          (setvar "osmode" 0)
          (command "_.MVIEW" p1 p2)
          (if (> (cdr (assoc 68 (entget (entlast)))) 0)
            (progn
              (setq ok_size T)
              (mv_cna)                ; Check number of active viewports
            )
          )
          (setq f_vp_n (mv_gvn))      ; Get viewport number
          (mv_avp)                    ; Array other Mview viewports
          (setq l_vp_n (mv_gvn))      ; Get viewport number
          (if (and (not ok_size) (> i_l_len 3))
              (princ "\n Viewport size is too small to change views.")
              (mv_cav)                ; Change the view of all viewports
          )
        )
      )
    )
  )
)
;;;
;;; Set the zoom scale factors for a set of viewports.
;;;
;;; mv_szs == MView_Set_Zoom_Scales
;;;
(defun mv_szs ( / temp)
  (command "_.UNDO" "_GROUP")
  (setq uctr (1+ uctr))
  (if (/= (getvar "cvport") 1)
    (command "_.PSPACE")
  )
  (princ "\nSelect the viewports to scale... ")
  (setq sset (ssget '((0 . "VIEWPORT") (-4 . "<NOT") (69 . 1) (-4 . "NOT>"))))
  (if sset
    (progn
      (if (> (sslength sset) 1)
        (progn
          (initget "Interactively Uniform")
          (setq ans (getkword (strcat
            "\nSet zoom scale factors for viewports.  "
            "Interactively/<Uniform>: "))
          )
          (if (= ans "Interactively")
            (setq vp_s_i T)
            (setq vp_s_i nil)
          )
        )
        (setq vp_s_i nil)
      )
      (setq temp (sslength sset)
            j    0
      )
      (if (= (getvar "cvport") 1)
        (command "_.MSPACE")
      )
      (while (< j temp)
        (progn
          (setq vp_n (cdr(assoc 69 (entget(ssname sset j)))))
          (setvar "cvport" vp_n)
          (setq j (1+ j))
          (if (or vp_s_i (< j 2))
            (mv_ssi)
          )
          (command "_.ZOOM" (strcat (mv_sts vp_scale) "xp"))
        )
      )
      (command "_.PSPACE")
    )
    (princ "\nNo viewports selected. ")
  )
  (command "_.UNDO" "_EN")
)
;;;
;;; Interactively set the scale of each viewport.
;;;
;;; mv_ssi == MView_Setup_Scale_Interactively
;;;
(defun mv_ssi (/ ans)
  (princ "\nSet the ratio of paper space units to model space units... ")
  (initget 6)
  (setq ans (getreal 
    "\nEnter the number of paper space units <1.0>: ")
  )
  (if (= (type ans) 'REAL)
    (setq vp_scale ans)
    (setq vp_scale 1.0)
  )
  (initget 6)
  (setq ans (getreal 
    "\nEnter the number of model space units <1.0>: ")
  )
  (if (= (type ans) 'REAL)
    (setq vp_scale (/ vp_scale ans))
    (setq vp_scale (/ vp_scale 1.0))
  )
  vp_scale
)
;;;
;;; Set up the scale either interactively or uniformly.
;;;
;;; mv_sus == MView_Set_Up_Scale
;;;
(defun mv_sus ()
  (if vp_s_i
    (mv_ssi)
  )
    (setq vp (mv_gvp (+ n vp_n) sset))
  (command "_.ZOOM" (strcat (mv_sts vp_scale) "xp"))
)
;;;
;;; Convert a real number to its shortest value; no trailing zeros.
;;;
;;; mv_sts == MView_Scale_To_String
;;;
(defun mv_sts (num / scale j return)
  (setq scale (rtos num 2 15)
        j     0
  )
  (while (< j (strlen scale))
    (if (= (setq return (substr scale (- (strlen scale) j) 1)) "0")
      (setq j (1+ j))
      (if (= return ".")
        (progn
          (setq return (substr scale 1 (- (strlen scale) (1- j)))) 
          (setq j (strlen scale))
        )
        (progn
          (setq return (substr scale 1 (- (strlen scale) j))) 
          (setq j (strlen scale))
        )
      )
    )
  )
  return
)
;;;
;;; Change to a new plan view and restore.
;;;
;;; mv_npv == MView_set_New_Plan_View
;;;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -