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

📄 mvsetup.lsp

📁 Autocad-2005-简体中文-解密版.zip
💻 LSP
📖 第 1 页 / 共 5 页
字号:
;;;
;;;    mvsetup.lsp
;;;
;;;    Copyright 1990-2003 by Autodesk, Inc.
;;;    
;;;    Permission to use, copy, modify, and distribute this software 
;;;    for any purpose and without fee is hereby granted, provided
;;;    that the above copyright notice appears in all copies and 
;;;    that both that copyright notice and the limited warranty and 
;;;    restricted rights notice below appear in all supporting 
;;;    documentation.
;;;    
;;;    AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.  
;;;    AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF 
;;;    MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC. 
;;;    DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE 
;;;    UNINTERRUPTED OR ERROR FREE.
;;;    
;;;    Use, duplication, or disclosure by the U.S. Government is subject to 
;;;    restrictions set forth in FAR 52.227-19 (Commercial Computer 
;;;    Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) 
;;;    (Rights in Technical Data and Computer Software), as applicable. 
;;;
;;;
;;; DESCRIPTION
;;;
;;;   This is a setup routine for Mview.
;;;   
;;;   It is based around a set of functionality that was determined to be a
;;;   necessary part of preparing a drawing for plotting.  This routine allows
;;;   the user to insert several pre-defined title blocks (ANSI A - E) and in
;;;   addition it allows the user to create a set of viewports within the 
;;;   title block just inserted.  A global scale may be specified as a ratio
;;;   between the scale of the title block in paperspace and the model geometry
;;;   in modelspace.  For example, if you were doing an engineering drawing at
;;;   a scale of 1:4 or quarter scale, then you would specify that you wanted
;;;   a ratio of 1 paperspace unit to 4 modelspace units.  The routine will 
;;;   convert this to 0.25xp for the Zoom command.  You may also elect to 
;;;   align the viewports.
;;;   
;;;   (The first time you invoke MVSETUP, you may notice a slight delay.
;;;   This occurs because the routine is creating a default file of various
;;;   title blocks and viewport layouts.  If you should accidentally erase
;;;   your default file, another will be created the next time you invoke
;;;   MVSETUP.  The file will be created in the directory specified by the
;;;   AutoCAD system variable "ACADPREFIX".  If you run AutoCAD from a
;;;   directory other than that one, and the system variables ACAD or ACADCFG
;;;   do not point to that directory, then MVSETUP will not be able to find 
;;;   it, and will create a new one in the directory pointed to by the first
;;;   path found in the current setting of the AutoCAD system variable 
;;;   "ACADPREFIX".)
;;;   
;;;   When you invoke MVSETUP from the command line or one of the menus, you
;;;   are given four options;  three dealing with the creation and manipulation
;;;   of viewports, and one which allows you to insert various "title blocks".
;;;   The initial prompt is shown below.
;;;   
;;;         Align/Create/Scale viewports/Options/Title block/Undo:  
;;;         
;;;   The Align viewports option presents you with several more options; you
;;;   are asked to determine the type of alignment you wish to perform.
;;;   
;;;         Angled/Horizontal/Vertical alignment/Rotate view/Undo? 
;;;           
;;;   The Horizontal and Vertical options ask you to pick a basepoint in one
;;;   viewport, and the point to move in another viewport.  The view in the
;;;   second viewport is panned by the offset distance in X or Y between
;;;   the two points relative to the zoom scale factor of the second viewport.
;;;   
;;;   The Angled option asks you for these two points and for a distance and
;;;   angle from the basepoint.  The point in the first viewport at the 
;;;   specified distance and angle from the basepoint is where the "other"
;;;   point will be panned.
;;;   
;;;   The Rotate view option asks you for a basepoint and a rotation angle
;;;   and uses the DVIEW command to change the view twist.  This generally 
;;;   will be useful only when the UCS of the view you are rotating is 
;;;   parallel to the screen and would be used to align a view with an
;;;   angled edge with the Align Angled option.
;;;   
;;;   Selecting Create viewports prompts you with the following:
;;;   
;;;         Delete objects/<Create viewports>:
;;;   
;;;   Selecting Delete objects provides you with a general selection prompt
;;;   at which time you may delete any paperspace objects that you wish.
;;;   This is intended to allow you to clear an area for your new viewports.
;;;   Modelspace entities will NOT be removed.
;;;   
;;;   
;;;   Selecting Create viewports prompts you to select one of the viewport 
;;;   options listed.
;;;   
;;;         Available Mview viewport layout options: 
;;; 
;;;         0:       None
;;;         1:       Single
;;;         2:       Std. Engineering
;;;         3:       Array of Viewports
;;; 
;;;         Redisplay/<Number of entry to load>: 
;;;         
;;;   Pressing RETURN or selecting "None" returns you to the main prompt
;;;   without creating any viewports.  
;;;   
;;;   "Single" is a single viewport which can fill the default area open in 
;;;   the sheet or it can be located by picking two points on the screen.  
;;;   
;;;   Std. Engineering is a set of four viewports with the upper left viewport 
;;;   in plan view, the lower left in a front view, the lower right in a right 
;;;   side view, and the upper right in an oblique view at -45 degrees from 0 
;;;   and up 30 degrees.
;;;   
;;;   The "Array of Viewports" allows you to specify any array of viewports
;;;   that you want to place on your sheet, from a 1 by 2 or 2 by 1 to any
;;;   level allowed by AutoCAD.
;;;   
;;;   
;;;   After selecting option 1, 2 or 3, you are prompted to specify the bounding
;;;   area for the viewports that are to be created.  Each of the title blocks
;;;   provided has a bounding region defined for it in the default file.  You
;;;   can elect to create all of the viewports within this region by selecting 
;;;   "Default" at the following prompt:
;;;   
;;;         Bounding area for viewports.  Default/<First point >: 
;;;   
;;;   You can also select two points on the screen and the number of viewports 
;;;   you subsequently define will be mapped into this area.
;;;   
;;;   Picking options 2 or 3 prompts you to specify the distance between the
;;;   viewports; the interstitial distance.  This value must be a positive 
;;;   number but may be zero.  The value you enter for X is automatically
;;;   assigned to Y, though you may specify Y to have a different value.
;;;   If you selected option 2 above, then the four viewports are created and
;;;   the four views are mapped into them as defined in the default file.
;;;   The other options create the viewports but do not change the views in 
;;;   any of them; the view will be a plan view in the current UCS.
;;;   
;;;   
;;;   Selecting Scale viewports at the main menu prompts you to select the 
;;;   viewports you wish to scale.  If you select one or more viewports
;;;   you asked whether you wnat to set the zoom scales all at once or for
;;;   each viewport separately:
;;;   
;;;         Set zoom scale factors for viewports.  Interactively/<Uniform>:
;;;   
;;;   After selecting one of these you are asked the following;
;;;   
;;;         Enter the ratio of paper space units to model space units... 
;;;         Number of paper space units.  <1.0>: 
;;;         Number of model space units.  <1.0>: 
;;;   
;;;   The number of viewports specified will have their zoom scales changed
;;;   by the ratio of the paper space units divided by the model space units.
;;;   This is cumulative over time, so performing this operation twice with
;;;   paper space units set to 1.0 and model space units set to 2.0 will give
;;;   the same results as doing it once with 1.0 an 4.0 as the values.
;;;   
;;;   
;;;   Selecting Options at the main menu allows you to specify several
;;;   preferences for operation of Mvsetup.  They are:
;;;
;;;         Set Layer/LImits/Units/Xref: 
;;;   
;;;   The Layer option allows you to specify a layer, existing or new, on
;;;   which to insert the title block, the LImits option allows you to
;;;   specify whether or not to reset the limits to the drawing extents after
;;;   a title block has been inserted, Units specifies whether the sizes and 
;;;   point locations are to be translated to inch or millimeter paper units,
;;;   and the Xref option let's you determine whether the title block is to 
;;;   be inserted or Xref'ed.
;;;
;;;
;;;   Selecting Title block from the main menu gives you another sub-menu.
;;;   
;;;         Delete objects/Origin/<Insert title block>:
;;;   
;;;   Delete objects works as described above under Create viewports.
;;;   Origin allows you to specify a new UCS origin for the subsequent
;;;   insertion of a title block.  Pressing RETURN will cause you to be 
;;;   presented with a list of available title blocks or sheets.
;;;   
;;;         Available title block options:  
;;; 
;;;         0:       NONE
;;;         1:       ISO A4 Size(mm)
;;;         2:       ISO A3 Size(mm)
;;;         3:       ISO A2 Size(mm)
;;;         4:       ISO A1 Size(mm)
;;;         5:       ISO A0 Size(mm)
;;;         6:       ANSI-V Size(in)
;;;         7:       ANSI-A Size(in)
;;;         8:       ANSI-B Size(in)
;;;         9:       ANSI-C Size(in)
;;;         10:      ANSI-D Size(in)
;;;         
;;;         11:      ANSI-E Size(in)
;;;         12:      Arch/Engineering (24 x 36 in)
;;; 
;;;         Add/Redisplay/<Number of entry to load>:      
;;;         
;;;   This list includes ISO standard sheets used outside the US, specified
;;;   in millimeters, the ANSI standard sheet layouts from A to E and size 
;;;   A Vertical specified in inches.  Selecting the number preceding one of the
;;;   selections causes one of two things to occur.  One, if the AutoCAD
;;;   drawing associated with the selections cannot be found, then the 
;;;   default file is read, a definition is extracted, and the drawing is
;;;   created in your current drawing.  You are then asked whether you want
;;;   to save this drawing to disk.  If you want to use this drawing more
;;;   than once, you should answer Yes to this prompt.  Two, if the AutoCAD
;;;   drawing can be found then it is INSERTed into your drawing at 0,0.
;;;   
;;;   The other options are Add, Delete and Redisplay.
;;;   
;;;   Pressing RETURN or selecting 0 for "None" at this prompt returns you 
;;;   to the main menu.  Selecting the number of a viable entry causes one
;;;   of two things to occur:  if you selected one of the built-in entries,
;;;   and you have not created a drawing by the name associated with this 
;;;   entry, the default file is scanned for a definition, and if found, 
;;;   the title block is created in your current drawing.  You are asked
;;;   whether you want to create a drawing of the entities just created.
;;;   For example, picking 1 (ANSI-V Size) gives you the following prompt:
;;;   
;;;         Create a drawing named ansi-v.dwg? <Y>:
;;;   
;;;   Answering Yes causes a drawing to be created and reinserted into your
;;;   drawing where it was created.
;;;   
;;;   If the drawing already exists it is inserted at the current UCS origin.
;;;   This is the mechanism for using your own title blocks and parts of
;;;   title blocks.  
;;;   
;;;   Selecting Add after the available title blocks are listed gives you
;;;   the following prompts; example text follows the colon:
;;;   
;;;         Title block description: A/E (24 x 18in)
;;;   
;;;         Drawing to insert (without extension): arch-b
;;;         Specify default usable area? <Y>:  Y
;;;         
;;;         Lower left corner: (1.12 0.99 0.00)
;;;         Upper right corner: (18.63 17.02 0.00)
;;;   
;;;   A line looking like this
;;;   
;;;         A/E (24 x 18in),arch-b.dwg,(1.12 0.99 0.00),(18.63 17.02 0.00),in
;;;   
;;;   is added after the last entry in the default file.
;;;   
;;;   The last field of the line specifies whether the title block has been 
;;;   created in inch or millimeter units.  This filed is used to allow title 
;;;   blocks created in either unit system to be interchanged simply by setting 
;;;   the unit type in the Options menu.
;;;   
;;;   Selecting Delete at the same prompt allows you to delete any of the 
;;;   lines listed except line 0.  Redisplay causes the list to be displayed 
;;;   again.
;;;   
;;;   If neither a valid drawing or a definition can be found you are so
;;;   informed and returned to the main menu.
;;;   
;;;   
;;;   GLOBALS:
;;;     mv_nln -- New layer name for title block insertions.
;;;     mv_slr -- Set Limits Request from drawing extents.
;;;     mv_utr -- Unit Translation Request.
;;;     mv_uxr -- Use Xref Request for title block insertions.
;;;   
;;;----------------------------------------------------------------------------;
;;;
;;; Avoid (gc)s on load to improve load time.
;;;
(defun do_alloc (/ old_allod new_alloc)
  (setq old_alloc (alloc 2000) new_alloc (alloc 2000))
  (expand (1+ (/ 11500 new_alloc)))
  (alloc old_alloc)
)
(do_alloc)
(setq do_alloc nil)
;;;
;;; ===========================================================================
;;; ===================== load-time error checking ============================
;;;

  (defun ai_abort (app msg)
     (defun *error* (s)
        (if old_error (setq *error* old_error))
        (princ)
     )
     (if msg
       (alert (strcat " Application error: "
                      app
                      " \n\n  "
                      msg
                      "  \n"
              )
       )
     )
     (exit)
  )

;;; Check to see if AI_UTILS is loaded, If not, try to find it,
;;; and then try to load it.
;;;
;;; If it can't be found or it can't be loaded, then abort the
;;; loading of this file immediately, preserving the (autoload)
;;; stub function.

  (cond
     (  (and ai_dcl (listp ai_dcl)))          ; it's already loaded.

     (  (not (findfile "ai_utils.lsp"))                     ; find it
        (ai_abort "MVSETUP"
                  (strcat "Can't locate file AI_UTILS.LSP."
                          "\n Check support directory.")))

     (  (eq "failed" (load "ai_utils" "failed"))            ; load it
        (ai_abort "MVSETUP" "Can't load file AI_UTILS.LSP"))
  )

  (if (not (ai_acadapp))               ; defined in AI_UTILS.LSP
      (ai_abort "MVSETUP" nil)         ; a Nil <msg> supresses
  )                                    ; ai_abort's alert box dialog.

;;; ==================== end load-time operations ===========================

;;;   
;;;   Start routine from menu pick or by typing MVS at the
;;;   command prompt.
;;;   
(defun mv_sup ( / mv_err s mv_oer mv_oce mv_olu ll_crn need_z mv_orm mv_oln
                  deffi deffo mv_utr mv_oas undo_setting)

  ;;
  ;; Internal error handler defined locally
  ;;

  (defun mv_err (s)                   ; If an error (such as CTRL-C) occurs
                                      ; while this command is active...
    (if (/= s "Function cancelled")
      (if (= s "quit / exit abort")
        (princ)
        (princ (strcat "\nError: " s))
      )
    )
    (if deffi (close deffi))
    (if deffo (close deffo))
    (if mv_olu (setvar "lunits" mv_olu)) ; Restore prev. linear units value
    (if (/= 1 mv_orm)
      (setvar "regenmode" mv_orm))    ; Restore prev. Regenmode value
    (if (/= 0 mv_osm)
      (setvar "osmode" mv_osm))       ; Restore prev. Object snap mode value
    (if (/= 0 mv_oas)
      (setvar "pickfirst" mv_oas))    ; Restore prev. Pickfirst value   
    (command "_.UNDO" "_EN")
    (ai_undo_off)
    ; Restore CMDECHO without undo recording
    (ai_setCmdEcho mv_oce)            ; Reset command echoing on error   
    (if mv_oer                        ; If an old error routine exists
      (setq *error* mv_oer)           ; then, reset it 
    )
    (princ)
  )
  
  (if (not *DEBUG*)
    (if *error*                       ; If there is an error routine defined
      (setq mv_oer   *error*          ; Store AutoLisp error routine
            *error*  mv_err)          ; Temporarily replace it
    )
  )
  (setq mv_oce (getvar "cmdecho"))  
  (ai_setCmdEcho 0)                   ; Turn off command echoing without undo recording
  (ai_undo_on)                        ; Turn UNDO on

  (setq mv_orm (getvar "regenmode"))
  (setq mv_osm (getvar "osmode"))
  (setq mv_oas (getvar "pickfirst"))
  (if (/= 0 mv_oas) (setvar "pickfirst" 0)) ; Turn off pickfirst 
  (if (/= 0 mv_osm) (setvar "osmode" 0))    ; Turn off object snap mode
  (if (/= 1 mv_orm) (setvar "regenmode" 1))
  (if (/= 4 (logand 4 (cdr (assoc 70 (tblsearch "LAYER" (getvar "CLAYER"))))))
    (if (mv_ctm)                        ; Is Tile-mode on? T or nil
      (mv_dos)                          ; Do old setup
      ;; else    
      (mv_dns)                          ; Do new setup
    )
    (princ "\nCannot run MVSETUP from a locked layer.")
  )
  (if deffi (setq deffi (close deffi)))
  (if deffo (setq deffo (close deffo)))
  (if (/= 1 mv_orm)
    (setvar "regenmode" mv_orm))      ; Restore prev. Regenmode value       
  (if (/= 0 mv_osm)
    (setvar "osmode" mv_osm))         ; Restore prev. Object snap mode value
  (if (/= 0 mv_oas)
    (setvar "pickfirst" mv_oas))      ; Restore prev. Pickfirst value

  (ai_undo_off)                       ; Return UNDO to initial state
  (ai_setCmdEcho mv_oce)              ; Reset command echoing
  (if mv_oer                          ; If an old error routine exists
    (setq *error* mv_oer)             ; then, reset it 
  )
  (princ)
)
;;;
;;; Check Tile-mode.  Returns T if ON and nil if not on.

⌨️ 快捷键说明

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