
;建议用户修改此文件，使配置符合各自的习惯。

;下面代码判断ACAD版本
 ;     (= (atof (getvar "ACADVER")) 14.0) R14
 ;     (= (atof (getvar "ACADVER")) 15.0) 2000
 ;     (= (atof (getvar "ACADVER")) 15.1) 2000i
 ;     (= (atof (getvar "ACADVER")) 15.2) 2002
 ;     (= (atof (getvar "ACADVER")) 16.0) 2004
 ;     (= (atof (getvar "ACADVER")) 16.1) 2005
 ;     (= (atof (getvar "ACADVER")) 16.2) 2006
 ;     (= (atof (getvar "ACADVER")) 17.0) 2007
 ;     (= (atof (getvar "ACADVER")) 17.1) 2008
 ;     (= (atof (getvar "ACADVER")) 17.2) 2009
 ;     (= (atof (getvar "ACADVER")) 18.0) 2010
 ;     (= (atof (getvar "ACADVER")) 18.1) 2011
 ;     (= (atof (getvar "ACADVER")) 18.2) 2012
 ;     (= (atof (getvar "ACADVER")) 19.0) 2013
 ;     (= (atof (getvar "ACADVER")) 19.1) 2014
 ;     (= (atof (getvar "ACADVER")) 20.0) 2015
 ;     (= (atof (getvar "ACADVER")) 20.1) 2016
 ;     (= (atof (getvar "ACADVER")) 21.0) 2017
 ;     (= (atof (getvar "ACADVER")) 23.0) 2019
 ;     (= (atof (getvar "ACADVER")) 23.1) 2020


(if (getvar "secureload") (setvar "secureload" 0));关闭加载警告

;;AutoCAD初始化 AutoLISP 程序
(setvar "cmdecho" 1)           ;打开命令过程中的提示
(setvar "blipmode" 0)          ;消除影点变量
(setvar "mirrtext" 0)          ;镜像文字变量
(setvar "filedia" 1)           ;使open文件对话框打开
(setvar "cmddia" 1)            ;使plot文件对话框打开
; (setvar "cursorsize" 100)     ;十字交叉光标最大0-100
; (setvar "lispinit" 1)
(setvar "menuctl" 1)           ;使命令与屏幕菜单自动关联
; (setvar "aperture" 6)          ;捕捉靶标的大小
; (setvar "PICKBOX" 6)           ;拾取靶标的大小
; (setvar "APBOX" 0)             ;1打开捕捉靶标。
(setvar "ucsicon" 1)           ;使UCS光标不动
(setvar "snapmode" 0)          ;Snap off
(setvar "gridmode" 0)          ;关闭网格
; (setvar "pickadd" 1)           ;1传统选择方式，0用shift键增加选择。
;(if (getvar "ZOOMFACTOR") (setvar "ZOOMFACTOR" 60))
(if (getvar "acadlspasdoc") (setvar "acadlspasdoc" 1))    ;reload autolisp between drawings
;(if (getvar "autosnap") (setvar "autosnap" 63))    ;打开轨迹跟踪
(if (getvar "vtenable") (setvar "vtenable" 0))    ;reload autolisp between drawings
(if (< (getvar "filletrad") 11) (setvar "filletrad" 0)) ;倒园角半径过小时自动设为0
(if (< (getvar "chamfera") 11) (setvar "chamfera" 0)) ;倒角距离a过小时自动设为0
(if (< (getvar "chamferb") 11) (setvar "chamferb" 0)) ;倒角距离b过小时自动设为0
(if (> (getvar "savetime") 30) (setvar "savetime" 10)) ;自动存盘时间如果大于30分钟则自动修改为10分钟
;;;;(setvar "ltscale" 1)                ;线型比例为一
;(if (< (getvar "dimscale") 4) (setvar "dimscale" (* (getvar "dimscale") 100)))  ;标注比例过小时自动x100


; (if (member (getvar "osmode") (list 0 4133)) (setvar "osmode" 175))   ;打开捕捉


; (if (getvar "shortcutmenu") (setvar "shortcutmenu" 0))
   ;系统变量"shortcutmenu"为0时鼠标右键回车

; (if (getvar "vtenable") (setvar "vtenable" 0)) ;2006以上版本，0~7 ，默认的是3 ，改为0, ZOOM时就没有平滑缩放
; (if (getvar "selectionarea") (setvar "selectionarea" 0)) ;2006以上版本，0~1,默认的是1，改为0，选择的时候选区内就没有透明色
; (if (getvar "selectionareaopacity") (setvar "selectionareaopacity" 25)) ;2006以上版本，0~100 默认25 控制选择区域透明色的透明度
; (if (getvar "selectionpreview") (setvar "selectionpreview" 2)) ;2006以上版本，0~3 ，默认的是3 改为0 选择物体时就不会显高亮，建议用2，在命令状态下，选择物体时显高亮，这样能看清选择的物体
; (if (getvar "vtfps") (setvar "vtfps" 1)) ;2006以上版本，1~30 默认7 控制平滑缩放的速度
; (if (getvar "insunits") (setvar "insunits" 4))
; (if (getvar "insunitsdefsource") (setvar "insunitsdefsource" 4))
; (if (getvar "insunitsdeftarget") (setvar "insunitsdeftarget" 4))
; (if (getvar "pickfirst") (setvar "pickfirst" 1))
; (if (getvar "dynprompt") (setvar "dynprompt" 0)) ;关闭动态输入
; (if (getvar "dynmode") (setvar "dynmode" 0)) ;关闭动态输入

  (and (> 18 (atoi (getvar "acadver")) 15) ;2000i-2009以上版本
       (findfile "whohas.arx")
       (progn (arxunload "whohas.arx")
              (vl-load-com)
              (vl-file-delete (findfile "whohas.arx"))
       )
  ) ;删除"whohas.arx"文件


;以下部分可能出错或与其他插件冲突,用户可自己删除。 ;2000以上版本
(if (> (atof (getvar "acadver")) 15.0)
   (vl-catch-all-apply
    '(lambda ( / x )
        (setq x (vlax-get-property (vlax-get-property (vlax-get-acad-object) 'Preferences) 'Display))
        (vlax-put-property x 'displaylayouttabs :vlax-true)   ;打开布局控制图签
        (vlax-put-property x 'DisplayScrollBars :vlax-false)    ;关闭滚动条
        ; (vlax-put-property x 'TextFont "微软雅黑")                 ;设置命令行字体
        (vlax-put-property x 'LayoutDisplayMargins :vlax-false) ;在布局不显示可打印区域
        (vlax-put-property x 'LayoutDisplayPaper :vlax-false)    ;在布局不显示图纸背景
        (vlax-put-property x 'LayoutDisplayPaperShadow :vlax-false)    ;在布局不显示图纸阴影
        ; (c:mini_fix_menu)  ;恢复屏幕菜单至合适宽度,
     )
   )
)
; (if (> (atof (getvar "acadver")) 19.0) ;2014以上版本
    ; (progn (setvar "filetabstate" 1) ;1打开显示文件选项卡 0关闭文件选项卡
           ; (setvar "filetabpreview" 1) ;1鼠标在选项卡时显示缩略图视图，0不显示。
           ; (setvar "filetabthumbhover" 0) ;1当您将光标悬停在文件选项卡缩略图上时，在图形窗口中加载模型或布局，0不显示
    ; )
; )

  ; (if (getvar "NAVVCUBEDISPLAY") (setvar "NAVVCUBEDISPLAY" 0));关闭ViewCube 工具在当前视觉样式的显示
  ;(if (getvar "osnaphatch") (setvar "osnaphatch" 0));1打开填充捕捉填充 0关闭

;以下三行设置迷你缺省绘图比例
  ; (setq mai_scale 100)
  ; (mai_get_scale)
  ; (mai_load_dim_style (>= mai_scale maidimsite))
  (if (getvar "menubar") (setvar "menubar" 1)) ;显示下拉菜单
  ; (if (= (getvar "tpstate") 1) (command "_.toolpalettesclose")) ;关闭工具选项板
  ;(setvar "modemacro" (strcat "[绘图比例： ""$(getvar,dimscale)"" ] [层： ""$(substr,$(getvar,CLAYER),1,8)" " ] [字型： " "$(getvar,TEXTSTYLE)" " ]"))
  (setvar "modemacro" "[迷你比例：$(getvar,dimscale) ]") ;左下角状态栏显示


(defun mai_file_gbk->utf ( f / a )
    (and (setq f (findfile f))
	     (setq a (mai_ReadTextStream f "GB2312"))
		 (mai_WriteTextStream a f "utf-8")
    )
)
(defun mai_file_utf->gbk ( f / a )
    (and (setq f (findfile f))
	     (setq a (mai_ReadTextStream f "utf-8"))
		 (mai_WriteTextStream a f "GB2312")
    )
)

; (defun c:mini_gbk->utf-8 ( / old_cmd fs file)
(defun c:2utf ( / old_cmd fs file)
  (mai_start nil)
  (setq fs (mai_GetFiles "选择将GB2312编码转换为UTF-8编码的文件" mai_mini_path "txt,lsp,mnu,mnl,lin,pat,pgp,set,text"))
  (or fs (exit))
  (or (= 1 (mai_dos_Popup "警告" 49 "会覆盖源文件，是否继续")) (exit))
  (foreach file fs (mai_file_gbk->utf file))
  (mai_end)
)
(defun c:2gbk ( / old_cmd fs file)
  (mai_start nil)
  (setq fs (mai_GetFiles "选择将UTF-8编码转换为GB2312编码的文件" mai_mini_path "txt,lsp,mnu,mnl,lin,pat,pgp,set,text"))
  (or fs (exit))
  (or (= 1 (mai_dos_Popup "警告" 49 "会覆盖源文件，是否继续")) (exit))
  (foreach file fs (mai_file_utf->gbk file))
  (mai_end)
)


  (princ)

