自己的用的AutoCAD2024的lisp文件

;;-------------------------------------------------------------------------------
;;;C:\Program Files\Autodesk2024\AutoCAD 2024\Support\zh-CN
;-指令列表A~Z
;AAAAAAAAAA
;--------------------
;AAA来进行指令提示。
(defun c:AAA()
	(princ "\n 快捷指令:")
	(princ "\n AAA:啊啊啊,进行指令提示;")
	(princ "\n WFF:文找找:文字findfind,非常高级查找文字功能,只能找autocad文字,天正,浩辰等插件文字无法查找到。")
	(princ "\n GQT:关其他:关闭选中图层之外的图层。")
	(princ "\n TCV:图层visual:图层显示,打开全部图层。")
	(princ "\n LM:量Mline的长度,测量多段线长度。")
	(princ "\n LLk:连连看:把选中的对象用线段连接起来.")
	(princ "\n LLL: 练练线:把所有首尾相连的直线,拼接成多段线。")
	(princ "\n LCD:量长度:测量直线、曲线、圆弧等各种形状的长度。")
	(princ "\n LLTJ:量量统计:统计线段的长度。")
	(princ "\n THB:text合并:文字合并将选中的文字合并成多行文字,不要选太多。")
	(princ "\n 企鹅:973490770")
	(princ "\n *************显示所有命令快捷键:AAA***************")
	(princ "\n LM:标注选择线段的长度")
	(princ "\n BCC:备份图纸到当前文件夹,文件名后缀时间,精确到秒")
	(princ)
)

(defun c:Bcc (/ sj fn n)
;将cad备份为新的文件,后缀时间例如“新图纸-20240725235717.dwg”;精确到秒。
;这样我们每次画图都可以随时保存备份,而不必担心cad图纸损坏而无法恢复。
(command "qsave" )
(setq	sj (getvar "cdate")
sj (* 10000 sj)
sj (rtos sj 2 0)
fn (strcat (getvar "DWGPREFIX") (getvar "DWGNAME"))
n (strlen fn)
fn (substr fn 1 (- n 17))
fn (strcat fn "-" sj ".dwg")
)
(command "saveas" "2018" fn )
;;;保存为2018版本,如果你想保存为低版本可以改成2004
(prompt "文件已经保存;并且另存为:")
(princ fn)
(princ)
)
(defun c:GQT ()
  ;关闭cad选中对象之外的图层,GQT:关其他
  (setq ss (ssget))
  (if ss
    (progn
      (setq selLayer (vla-get-layer (vlax-ename->vla-object (ssname ss 0))))
      (setq layers (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))))
      (setq layersCount (vla-get-count layers))
      (setq layerIndex 0)
      (while (< layerIndex layersCount)
        (setq currentLayer (vla-item layers layerIndex))
        (if (not (equal (vla-get-name currentLayer) selLayer))
          (progn
            (vla-put-LayerOn currentLayer :vlax-false)
          )
        )
        (setq layerIndex (1+ layerIndex))
      )
    )
  )
  (princ)
)
(defun rg-Split (s p / L r)
;正则表达式,来对这样的字符串来分隔成数组"R1011,R1012">-"R1011" "R1012"
	(setq r (vlax-create-object "vbscript.regexp"))
	(vlax-put-property r 'Global 1)
	(vlax-put-property r 'Pattern p)
	(read (strcat "(\"" (vlax-invoke r 'Replace s "\" \"") "\")"))
)

(defun c:TFF ()
	;DrawLineToUserInputText 将需要查询的文字用","分割,会逐个查询并标记直线
  ;(setq inputString (getstring "\nEnter the text strings separated by commas: "))
  (setq a (getfiled "选择一个文本文件" "F:/F/20230803-山东金城项目/008-李志朋/" "txt" 8))
  (setq gaodu (getstring "\n输入文本高度:"))
  (if gaodu==''
	gaodu=500
	)
  (setq file (open a "r"))
  (setq inputString (read-line file))
  
  (setq textStrings (rg-Split inputString ","))
  (princ textStrings)
  (foreach str1 textStrings
	(setq str (substr str1 4 5))
	;获得XV-R1101001的R1101
    (setq textSet (ssget "X" (list (cons 0 "TEXT") (cons 1 str))))
    (if (and textSet (> (sslength textSet) 0))
		(if textSet
		  (progn
			(setq ent (ssname textSet 0))
			(setq charPoint (cdr (assoc 10 (entget ent))))
			(princ charPoint)
			(setq endPoint (list (+ (car charPoint) 5000) (+ (cadr charPoint) 40000)))
			(princ endpoint)
			(command "_line" charPoint  endPoint "")
			(command "circle" endPoint 10 "")
			
			(command "TEXT" endPoint gaodu 0 str1 )
			(setq newPoint (list (+ (car charPoint) 5000) (+ (cadr charPoint) 40000)))
		  )
		  (prompt (strcat "\nString not found: " str))
		)
	)
  )
  (princ)
)

;001.标注线段长度
(defun c:LM()
     (prompt "请选择要标注长度的线段:")
     (setq cm (getvar "cmdecho"))
     (setvar "cmdecho" 0)
     (while (setq ent (car (entsel "\n选取多段线<回车结束>:")))
		 (setq dxf (entget ent)
			nam (cdr (assoc 0 dxf))
		 )
		(if (wcmatch nam "LINE,*POLYLINE,SPLINE,ARC,CIRCLE,ELLIPSE")
			 (progn
				(command "_lengthen" ent "")
				(setq cd (getvar "PERIMETER"))
				(setq cd (rtos (/ cd 1000) 2 3))
				(princ (strcat "\n所选取图元的长度为" cd))
     				(setq pt (getpoint "\n请指定插入位置点: "))
    				(command "text" pt 100 0 cd )
			  )
		)
     )
     (setvar "cmdecho" cm)
     (princ)
)
;006.把选中的对象用多段线连接起来-连连看
;作者qq:1434177703
(defun c:LLk ( / e i msg odlst pts ss x)
(vl-load-com)
(setq *ACAD*  (vlax-get-acad-object)
    *DOC*   (vla-get-ActiveDocument *ACAD*)
)
(defun *error*(msg)
     (mapcar 'setvar '("cmdecho" "osmode") odlst)
     (vlax-invoke-method *DOC* 'EndUndoMark)
     (princ msg)
     )	
(vlax-invoke-method *DOC* 'StartUndoMark)
(setq odlst (mapcar 'getvar '("cmdecho" "osmode")))
(mapcar 'setvar '("cmdecho" "osmode") '(0 0))
	(setq ss (ssget '((0 . "TEXT"))))
	(setq pts nil)
	(repeat (setq i (sslength ss))
	(setq e (ssname ss (setq i (1- i))))
	(setq pts (cons (cdr (assoc 10 (entget e))) pts))
	)
	(entmake (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length pts)))
(mapcar '(lambda (x) (cons 10 x)) pts)))
(mapcar 'setvar '("cmdecho" "osmode") odlst)
(vlax-invoke-method *DOC* 'EndUndoMark)
)

;002、所有首尾相连的直曲线创建成一条多段线
(defun c:LLL()
(setvar "peditaccept" 1)
(setq ss (ssget))
(command "pedit" ss "j" "all" "" "")
(setvar "peditaccept" 0)
(princ)
)
;003、量取直线、多段线、样条曲线、圆弧、圆、椭圆的长度。
(defun c:LCD()
     (prompt "测量线段长度")
     (setq cm (getvar "cmdecho"))
     (setvar "cmdecho" 0)
     (while (setq ent (car (entsel "\n选取多段线<回车结束>:")))
		 (setq dxf (entget ent)
			nam (cdr (assoc 0 dxf))
		 )
		(if (wcmatch nam "LINE,*POLYLINE,SPLINE,ARC,CIRCLE,ELLIPSE")
			 (progn
				(command "_lengthen" ent "")
				(setq cd (getvar "PERIMETER"))
				(princ (strcat "\n所选取图元的长度为" (rtos cd 2 3)))
			  )
		)
     )
     (setvar "cmdecho" cm)
     (princ)
)
;004、统计选择线段的总长度。

(defun C:LLTJ (/ CURVE TLEN SS N SUMLEN)
(princ "程序:统计线段长度 命令:zz")  
(vl-load-com)
(setq SUMLEN 0)   
(setq SS (ssget '((0 . "CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE,ARC"))))  
(setq N 0)   
(repeat (sslength SS)    
(setq CURVE (vlax-ename->vla-object (ssname SS N)))    
(setq TLEN (vlax-curve-getdistatparam CURVE (vlax-curve-getendparam CURVE)))    
(setq SUMLEN (+ SUMLEN TLEN))  
(setq N (1+ N))   )    
(princ (strcat "\n共选择 " (itoa (sslength SS)) " 条线段. 线段总长: " (rtos SUMLEN 2 3) "  ."))) 
;--------------------
;-------关闭图层
(defun c:GQT ()

	(command "layiso" "S" "O" "O")

	(princ)

)


;;;*****文字合并 程序开始*****
(defun c:THB (/ lst)
  (setq oldaun (getvar "aunits"))
  (setvar "aunits" 3)
  (setvar "osmode" 15359)
  (setvar "cmdecho" 0)
  (command "undo" "be")
  (princ "\n★功能:文字合并。\n制作者:吴丁运\n")
  (setq ss (ssget '((0 . "MTEXT,TEXT"))))
  (setvar "osmode" 0)
  (initget "E S A")
  (if (not (setq kword
                  (getkword
                    "\n在合并文字之间加:[换行(E)/空格(S)/直接合并(A)]<E>"
                  )
           )
      )
    (setq kword "E")
  )
  (setvar "osmode" 0)
  (setq lst '())
  (while (> (sslength ss) 0)
    (setq entnam (ssname ss 0)
          entdat (entget entnam)
    )
   (setq pt  (cdr (assoc 10 entdat))        ;读取文字的插入点坐标
          txt (cdr (assoc 1 entdat))        ;读取文字内容
          zg  (cdr (assoc 40 entdat))        ;读取文字的字高
          lst (cons (list pt txt zg) lst) ;将点坐标、内容、字高组成表
          ss  (ssdel entnam ss)                ;选择集中删除当前的文字对象
    )
  )
  (setq
    lst
     (vl-sort lst
(function
                (lambda        (e1 e2)
                  (if (equal (cadr (car e1)) (cadr (car e2)) 1e-4)
                    (> (car (car e1)) (car (car e2)))
                    (< (cadr (car e1)) (cadr (car e2)))
                  )
                )
              )
     )
  )
  (setq str "")
  (cond        ((= kword "S")
         (foreach e lst
           (setq str (strcat (cadr e) " " str))
         )
        )
        ((= kword "E")
         (foreach e lst
           (setq str (strcat (cadr e) "\n" str))
         )
        )
        ((= kword "A")
         (foreach e lst
           (setq str (strcat (cadr e) str))
         )
        )
  )
  (setq pt (getpoint "\n请指定点位置:")) 
  (command "MTEXT" pt "H" zg "W" 0 str "")
  (princ "\n★提示:文字合并完成.\n")
  (princ)
  (setvar "aunits" oldaun)
  (command "undo" "e")
  (setvar "osmode" 15359)
  (princ)
)
;;;*****文字合并 程序结束*****
;;======大师级别程序代码开始,以下代码全部属于lisp祖师爷编写的文字查找功能的代码。

;======我是华丽分割线======================
; Next available MSG number is  104
; MODULE_ID ACAD2005doc_LSP_
;;;    ACAD2005DOC.LSP Version 1.0 for AutoCAD 2005
;;;
;;;    Copyright (C) 1994 - 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.
;;;
;;;.
;;;
;;;    Note:
;;;            This file is loaded automatically by AutoCAD every time 
;;;            a drawing is opened.  It establishes an autoloader and
;;;            other utility functions.
;;;
;;;    Globalization Note:   
;;;            We do not support autoloading applications by the native 
;;;            language command call (e.g. with the leading underscore
;;;            mechanism.)


;;;===== Raster Image Support for Clipboard Paste Special =====
;;
;; IMAGEFILE
;;
;; Allow the IMAGE command to accept an image file name without
;; presenting the file dialog, even if filedia is on.
;; Example: (imagefile "c:/images/house.bmp")
;;
(defun imagefile (filename / filedia-save cmdecho-save)
  (setq filedia-save (getvar "FILEDIA"))
  (setq cmdecho-save (getvar "CMDECHO"))
  (setvar "FILEDIA" 0)
  (setvar "CMDECHO" 0)
  (command "_.-image" "_attach" filename)
  (setvar "FILEDIA" filedia-save)
  (setvar "CMDECHO" cmdecho-save)
  (princ)
)

;;;=== General Utility Functions ===

;   R12 compatibility - In R12 (acad_helpdlg) was an externally-defined 
;   ADS function.  Now it's a simple AutoLISP function that calls the 
;   built-in function (help).  It's only purpose is R12 compatibility.  
;   If you are calling it for anything else, you should almost certainly 
;   be calling (help) instead. 
 
(defun acad_helpdlg (helpfile topic)
  (help helpfile topic)
)


(defun *merr* (msg)
  (setq *error* m:err m:err nil)
  (princ)
)

(defun *merrmsg* (msg)
  (princ msg)
  (setq *error* m:err m:err nil)
  (princ)
)

;; Loads the indicated ARX app if it isn't already loaded
;; returns nil if no load was necessary, else returns the
;; app name if a load occurred.
(defun verify_arxapp_loaded (app) 
  (if (not (loadedp app (arx)))
      (arxload app f)
  )
)

;; determines if a given application is loaded...
;; general purpose: can ostensibly be used for appsets (arx) or (ads) or....
;;
;; app is the filename of the application to check (extension is required)
;; appset is a list of applications, (such as (arx) or (ads)
;; 
;; returns T or nil, depending on whether app is present in the appset
;; indicated.  Case is ignored in comparison, so "foo.arx" matches "FOO.ARX"
;; Also, if appset contains members that contain paths, app will right-match
;; against these members, so "bar.arx" matches "c:\\path\\bar.arx"; note that
;; "bar.arx" will *not* match "c:\\path\\foobar.arx."
(defun loadedp (app appset)
  (cond (appset  (or 
                     ;; exactly equal? (ignoring case)
                     (= (strcase (car appset))
                        (strcase app))
                     ;; right-matching? (ignoring case, but assuming that
                     ;; it's a complete filename (with a backslash before it)
					 (and 
					     (> (strlen (car appset)) (strlen app))
	                     (= (strcase (substr (car appset) 
	                                         (- (strlen (car appset)) 
	                                            (strlen app) 
	                                         ) 
	                                 )
	                        ) 
	                        (strcase (strcat "\\" app))
	                     )
				     )
                     ;; no match for this entry in appset, try next one....
                     (loadedp app (cdr appset)) )))
)


;;; ===== Single-line MText editor =====
(defun LispEd (contents / fname dcl state)
  (if (not (setq fname (getvar "program")))
     (setq fname "acad")
  )
  (strcat fname ".dcl")
  (setq dcl (load_dialog fname))
  (if (not (new_dialog "LispEd" dcl)) (exit))
  (set_tile "contents" contents)
  (mode_tile "contents" 2)
  (action_tile "contents" "(setq contents $value)")
  (action_tile "accept" "(done_dialog 1)")
  (action_tile "mtexted" "(done_dialog 2)" )
  (setq state (start_dialog))
  (unload_dialog dcl)
  (cond
    ((= state 1) contents)
    ((= state 2) -1)
    (t 0)
  )
)

;;; ===== Discontinued commands =====
(defun c:ddselect(/ cmdecho-save)
  (setq cmdecho-save (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (command "._+options" 7)
  (setvar "CMDECHO" cmdecho-save)
  (princ)
)

(defun c:ddgrips(/ cmdecho-save)
  (setq cmdecho-save (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (command "._+options" 7)
  (setvar "CMDECHO" cmdecho-save)
  (princ)
)

(defun c:gifin ()
  (alert "\n不再支持 GIFIN 命令。\n请使用 IMAGE 命令来附着光栅图像文件。\n")
  (princ)
)

(defun c:pcxin ()
  (alert "\n不再支持 PCXIN 命令。\n请使用 IMAGE 命令来附着光栅图像文件。\n")
  (princ)
)

(defun c:tiffin ()
  (alert "\n不再支持 TIFFIN 命令。\n请使用 IMAGE 命令来附着光栅图像文件。\n")
  (princ)
)

(defun c:ddemodes()
  (alert "“对象特性”工具栏包含了 DDEMODES 的功能。\nDDEMODES 已废弃。\n\n欲知详细信息,请从 AutoCAD 帮助的“索引”选项卡中选择“DDEMODES”。")
  (princ)
)

(defun c:ddrmodes(/ cmdecho-save)
  (setq cmdecho-save (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (command "._+dsettings" 0)
  (setvar "CMDECHO" cmdecho-save)
  (princ)
)

;;; ===== AutoLoad =====

;;; Check list of loaded <apptype> applications ("ads" or "arx")
;;; for the name of a certain appplication <appname>.
;;; Returns T if <appname> is loaded.

(defun ai_AppLoaded (appname apptype)
   (apply 'or
      (mapcar 
        '(lambda (j)
	    (wcmatch
               (strcase j T)
               (strcase (strcat "*" appname "*") T)
            )   
         )
	 (eval (list (read apptype)))
      )
   )
)

;;  
;;  Native Rx commands cannot be called with the "C:" syntax.  They must 
;;  be called via (command).  Therefore they require their own autoload 
;;  command.

(defun autonativeload (app cmdliste / qapp)
  (setq qapp (strcat "\"" app "\""))
  (setq initstring "\n正在初始化...")
  (mapcar
   '(lambda (cmd / nom_cmd native_cmd)
      (progn
        (setq nom_cmd (strcat "C:" cmd))
        (setq native_cmd (strcat "\"_" cmd "\""))
        (if (not (eval (read nom_cmd)))
            (eval
             (read (strcat
                    "(defun " nom_cmd "()"
                    "(setq m:err *error* *error* *merrmsg*)"
                    "(if (ai_ffile " qapp ")"
                    "(progn (princ initstring)"
                    "(_autoarxload " qapp ") (command " native_cmd "))"
                    "(ai_nofile " qapp "))"
                    "(setq *error* m:err m:err nil))"
                    ))))))
   cmdliste)
  nil
)

(defun _autoqload (quoi app cmdliste / qapp symnam)
  (setq qapp (strcat "\"" app "\""))
  (setq initstring "\n正在初始化...")
  (mapcar
   '(lambda (cmd / nom_cmd)
      (progn
        (setq nom_cmd (strcat "C:" cmd))
        (if (not (eval (read nom_cmd)))
            (eval
             (read (strcat
                    "(defun " nom_cmd "( / rtn)"
                    "(setq m:err *error* *error* *merrmsg*)"
                    "(if (ai_ffile " qapp ")"
                    "(progn (princ initstring)"
                    "(_auto" quoi "load " qapp ") (setq rtn (" nom_cmd ")))"
                    "(ai_nofile " qapp "))"
                    "(setq *error* m:err m:err nil)"
                    "rtn)"
                    ))))))
   cmdliste)
  nil
)

(defun autoload (app cmdliste)
  (_autoqload "" app cmdliste)
)

(defun autoarxload (app cmdliste)
  (_autoqload "arx" app cmdliste)
)

(defun autoarxacedload (app cmdliste / qapp symnam)
  (setq qapp (strcat "\"" app "\""))
  (setq initstring "\n正在初始化...")
  (mapcar
   '(lambda (cmd / nom_cmd)
      (progn
        (setq nom_cmd (strcat "C:" cmd))
        (if (not (eval (read nom_cmd)))
            (eval
             (read (strcat
                    "(defun " nom_cmd "( / oldcmdecho)"
                    "(setq m:err *error* *error* *merrmsg*)"
                    "(if (ai_ffile " qapp ")"
                    "(progn (princ initstring)"
                    "(_autoarxload " qapp ")"
                    "(setq oldcmdecho (getvar \"CMDECHO\"))"
                    "(setvar \"CMDECHO\" 0)"
                    "(command " "\"_" cmd "\"" ")"
                    "(setvar \"CMDECHO\" oldcmdecho))"
                    "(ai_nofile " qapp "))"
                    "(setq *error* m:err m:err nil)"
                    "(princ))"
                    ))))))
   cmdliste)
  nil
)

(defun _autoload (app)
; (princ "Auto:(load ") (princ app) (princ ")") (terpri)
  (load app)
)

(defun _autoarxload (app)
; (princ "Auto:(arxload ") (princ app) (princ ")") (terpri)
  (arxload app)
)

(defun ai_ffile (app)
  (or (findfile (strcat app ".lsp"))
      (findfile (strcat app ".exp"))
      (findfile (strcat app ".exe"))
      (findfile (strcat app ".arx"))
      (findfile app)
  )
)

(defun ai_nofile (filename)
  (princ
    (strcat "\n文件 "
            filename
            "(.lsp/.exe/.arx) 在搜索路径文件夹中未找到。"
    )
  )
  (princ "\n请检查支持文件的安装,然后重试。")
  (princ)
)


;;;===== AutoLoad LISP Applications =====
;  Set help for those apps with a command line interface

(autoload "edge"  '("edge"))
(setfunhelp "C:edge" "" "edge")

(autoload "3d" '("3d" "3d" "ai_box" "ai_pyramid" "ai_wedge" "ai_dome"
                 "ai_mesh" "ai_sphere" "ai_cone" "ai_torus" "ai_dish")
)
(setfunhelp "C:3d" "" "3d")
(setfunhelp "C:ai_box" "" "3d_box")
(setfunhelp "C:ai_pyramid" "" "3d_pyramid")
(setfunhelp "C:ai__wedge" "" "3d_wedge")
(setfunhelp "C:ai_dome" "" "3d_dome")
(setfunhelp "C:ai_mesh" "" "3d_mesh")
(setfunhelp "C:ai_sphere" "" "3d_sphere")
(setfunhelp "C:ai_cone" "" "3d_cone")
(setfunhelp "C:ai_torus" "" "3d_torus")
(setfunhelp "C:ai_dish" "" "3d_dish")

(autoload "3darray" '("3darray"))
(setfunhelp "C:3darray" "" "3darray")

(autoload "mvsetup" '("mvsetup"))
(setfunhelp "C:mvsetup" "" "mvsetup")

(autoload "attredef" '("attredef"))
(setfunhelp "C:attredef" "" "attredef")

(autoload "tutorial" '("tutdemo" "tutclear"
				       "tutdemo" 
				       "tutclear"))

;;;===== AutoArxLoad Arx Applications =====


;;; ===== Double byte character handling functions =====

(defun is_lead_byte(code)
    (setq asia_cd (getvar "dwgcodepage"))
    (cond
        ( (or (= asia_cd "dos932")
              (= asia_cd "ANSI_932")
          )
          (or (and (<= 129 code) (<= code 159))
              (and (<= 224 code) (<= code 252))
          )
        )
        ( (or (= asia_cd "big5")
              (= asia_cd "ANSI_950")
          )
          (and (<= 129 code) (<= code 254))
        )
        ( (or (= asia_cd "gb2312")
              (= asia_cd "ANSI_936")
          )
          (and (<= 161 code) (<= code 254))
        )
        ( (or (= asia_cd "johab")
              (= asia_cd "ANSI_1361")
          )
          (and (<= 132 code) (<= code 211))
        )
        ( (or (= asia_cd "ksc5601")
              (= asia_cd "ANSI_949")
          )
          (and (<= 129 code) (<= code 254))
        )
    )
)

;;; ====================================================


;;;
;;;  FITSTR2LEN
;;;
;;;  Truncates the given string to the given length. 
;;;  This function should be used to fit symbol table names, that
;;;  may turn into \U+ sequences into a given size to be displayed
;;;  inside a dialog box.
;;;
;;;  Ex: the following string: 
;;;
;;;      "This is a long string that will not fit into a 32 character static text box."
;;;
;;;      would display as a 32 character long string as follows:
;;;
;;;      "This is a long...tatic text box."
;;;

(defun fitstr2len (str1 maxlen)

    ;;; initialize internals
    (setq tmpstr str1)
    (setq len (strlen tmpstr))

    (if (> len maxlen) 
         (progn
            (setq maxlen2 (/ maxlen 2))
            (if (> maxlen (* maxlen2 2))
                 (setq maxlen2 (- maxlen2 1))
            )
            (if (is_lead_byte (substr tmpstr (- maxlen2 2) 1))
                 (setq tmpstr1 (substr tmpstr 1 (- maxlen2 3)))
                 (setq tmpstr1 (substr tmpstr 1 (- maxlen2 2)))
            )
            (if (is_lead_byte (substr tmpstr (- len (- maxlen2 1)) 1))
                 (setq tmpstr2 (substr tmpstr (- len (- maxlen2 3))))
                 (setq tmpstr2 (substr tmpstr (- len (- maxlen2 2))))
            )
            (setq str2 (strcat tmpstr1 "..." tmpstr2))
         ) ;;; progn
         (setq str2 (strcat tmpstr))
    ) ;;; if
) ;;; defun


;;;
;;;  If the first object in a selection set has an attached URL
;;;  Then launch browser and point to the URL.
;;;  Called by the Grips Cursor Menu
;;;
(defun C:gotourl ( / ssurl url i)
   (setq m:err *error* *error* *merrmsg
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

菌王

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值