Jump to content

Lisp lệnh M2V trong chủ đề “Nhờ các bạn giúp đỡ sửa lisp”

(defun c:m2v (/ #app #doc *error* c cmd lay lst o sc vp)

  (defun *error* (msg)
    (and cmd (setvar 'cmdecho cmd))
    (and #doc (vla-endundomark #doc))
    (if	(and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
      (princ (strcat "\nError: " msg))
    )
  )
  
  (setq #app (vlax-get-acad-object)
	#doc (vla-get-activedocument #app)
	cmd (getvar 'cmdecho))
  
  (if (= 0 (vla-get-activespace #doc)) (vla-put-activespace #doc 1))
  
  (if (and (princ    "\nSelect a Closed LwPolyline:  ")
	   (setq o   (ssget "_+.:E:S" '((0 . "LWPOLYLINE") (70 . 1))))
	   (setq o   (ssname o 0))
	   (setq c   (pline-centroid o))
	   (setq o   (vlax-ename->vla-object o))
	   (setq sc  (distof (getstring "\nEnter Scale for new Viewport: ")))
	   (setq sc  (/ 1.0 sc))
      )
    (progn
      (vlax-for	lay (vla-get-layouts #doc)
	(if (/= "MODEL" (strcase (vla-get-name lay)))
	  (setq lst (cons (cons (vla-get-name lay) lay) lst))
	)
      )
      (if (setq	lst
		 (mapcar
		   '(lambda (x) (cdr (assoc x lst)))
		   (LM:Listbox
		     "Choose Layout to create ViewPort"
		     (mapcar 'car
			     (vl-sort lst
				      '(lambda (a b)
					 (< (vla-get-taborder (cdr a))
					    (vla-get-taborder (cdr b))
					 )
				       )
			     )
		     )
		     t
		   )
		 )
	  )
	(progn
	  (vla-startundomark #doc)
	  (LM:loadlinetypes '("hidden") nil)
	  (setvar 'cmdecho 0)
	  (foreach lay lst
	    (vla-put-activelayout #doc lay)
	    (setq vp (vlax-vla-object->ename
		       (car (vlax-invoke
			      #doc
			      'copyobjects
			      (list o)
			      (vla-get-block lay)
			    )
		       )
		     )
	    )
	    (vla-put-linetype (vlax-ename->vla-object vp) "hidden")
	    (vl-cmdf "_.mview" "_object" vp)
	    (setq vp (vlax-ename->vla-object (entlast)))
	    (vla-put-linetype vp "hidden")
	    (vla-display vp :vlax-true)
	    (vla-put-mspace #doc :vlax-true)
	    (vla-put-ActivePViewport #doc vp)
	    (vla-zoomCenter #app (vlax-3d-point c) 1.0)
	    (vla-put-mspace #doc :vlax-false)
	    (vla-put-customscale vp sc)
	    (VLA-ZoomObject vp)
	  )
	)
      )
    )
  )
  (*error* nil)
  (princ)
)

;;==================================================================;;
;;======================== SUB FUNCTION ============================;;
;;==================================================================;;


;;=================== POLYLINE CENTROID BY GILE=====================;;
;; ALGEB-AREA
;; Returns tha algebraic area of the triangle defined by 3  2d points
;; the area is negative if points are clockwise

(defun algeb-area (p1 p2 p3)
  (/ (-	(* (- (car p2) (car p1))
	   (- (cadr p3) (cadr p1))
	)
	(* (- (car p3) (car p1))
	   (- (cadr p2) (cadr p1))
	)
     )
     2.0
  )
)

;; TRIANGLE-CENTROID
;; Returns the centroid of a triangle defined by 3 points

(defun triangle-centroid (p1 p2 p3)
  (mapcar '(lambda (x1 x2 x3)
	     (/ (+ x1 x2 x3) 3.0)
	   )
	  p1
	  p2
	  p3
  )
)

;; POLYARC-CENTROID
;; Returns a list which first item is the centroid of a 'polyarc'
;; and the second its algeraic area
;;
;; Arguments
;; bu : polyarc bulge
;; p1 : start point
;; p2 : end point

(defun polyarc-centroid	(bu p1 p2 / ang rad cen area dist cg)
  (setq	ang  (* 2 (atan bu))
	rad  (/	(distance p1 p2)
		(* 2 (sin ang))
	     )
	cen  (polar p1
		    (+ (angle p1 p2) (- (/ pi 2) ang))
		    rad
	     )
	area (/ (* rad rad (- (* 2 ang) (sin (* 2 ang)))) 2.0)
	dist (/ (expt (distance p1 p2) 3) (* 12 area))
	cg   (polar cen
		    (- (angle p1 p2) (/ pi 2))
		    dist
	     )
  )
  (list cg area)
)

;; PLINE-CENTROID
;; Returns the WCS coordinates of a lwpolyline centroid
;;
;; Argument
;; pl : the lwpolyline ename

(defun pline-centroid (pl / elst lst tot cen p0 area cen)
  (setq elst (entget pl))
  (while (setq elst (member (assoc 10 elst) elst))
    (setq lst  (cons (cons (cdar elst) (cdr (assoc 42 elst))) lst)
	  elst (cdr elst)
    )
  )
  (setq	lst (reverse lst)
	tot 0.0
	cen '(0.0 0.0)
	p0  (caar lst)
  )
  (if (/= 0 (cdar lst))
    (setq p-c (polyarc-centroid (cdar lst) p0 (caadr lst))
	  cen (mapcar '(lambda (x) (* x (cadr p-c))) (car p-c))
	  tot (cadr p-c)
    )
  )
  (setq lst (cdr lst))
  (if (equal (car (last lst)) p0 1e-9)
    (setq lst (reverse (cdr (reverse lst))))
  )
  (while (cadr lst)
    (setq area (algeb-area p0 (caar lst) (caadr lst))
	  cen  (mapcar '(lambda (x1 x2) (+ x1 (* x2 area)))
		       cen
		       (triangle-centroid p0 (caar lst) (caadr lst))
	       )
	  tot  (+ area tot)
    )
    (if	(/= 0 (cdar lst))
      (setq p-c	(polyarc-centroid (cdar lst) (caar lst) (caadr lst))
	    cen	(mapcar	'(lambda (x1 x2) (+ x1 (* x2 (cadr p-c))))
			cen
			(car p-c)
		)
	    tot	(+ tot (cadr p-c))
      )
    )
    (setq lst (cdr lst))
  )
  (if (/= 0 (cdar lst))
    (setq p-c (polyarc-centroid (cdar lst) (caar lst) p0)
	  cen (mapcar '(lambda (x1 x2) (+ x1 (* x2 (cadr p-c))))
		      cen
		      (car p-c)
	      )
	  tot (+ tot (cadr p-c))
    )
  )
  (trans (list (/ (car cen) tot)
	       (/ (cadr cen) tot)
	       (cdr (assoc 38 (entget pl)))
	 )
	 pl
	 0
  )
)

;;-----------------------=={ List Box }==---------------------;;
;;                                                            ;;
;;  Displays a List Box allowing the user to make a selection ;;
;;  from the supplied data.                                   ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2012 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  title    - List Box Dialog title                          ;;
;;  lst      - List of Strings to display in the List Box     ;;
;;  multiple - Boolean flag to determine whether the user     ;;
;;             may select multiple items (T=Allow Multiple)   ;;
;;------------------------------------------------------------;;
;;  Returns:  List of selected items, else nil.               ;;
;;------------------------------------------------------------;;
 
(defun LM:ListBox ( title lst multiple / dch des tmp res )
    (cond
        (   (not
                (and
                    (setq tmp (vl-filename-mktemp nil nil ".dcl"))
                    (setq des (open tmp "w"))
                    (write-line
                        (strcat
                            "listbox : dialog { label = \""
                            title
                            "\"; spacer; : list_box { key = \"list\"; multiple_select = "
                            (if multiple "true" "false")
                            "; } spacer; ok_cancel; }"
                        )
                        des
                    )
                    (not (close des))
                    (< 0 (setq dch (load_dialog tmp)))
                    (new_dialog "listbox" dch)
                )
            )
            (prompt "\nError Loading List Box Dialog.")
        )
        (   t     
            (start_list "list")
            (foreach item lst (add_list item))
            (end_list)
            (setq res (set_tile "list" "0"))
            (action_tile "list" "(setq res $value)")
            (setq res
                (if (= 1 (start_dialog))
                    (mapcar '(lambda ( x ) (nth x lst)) (read (strcat "(" res ")")))
                )
            )
        )
    )
    (if (< 0 dch)
        (unload_dialog dch)
    )
    (if (and tmp (setq tmp (findfile tmp)))
        (vl-file-delete tmp)
    )
    res
)

;; Load Linetypes  -  Lee Mac
;; Attempts to load a list of linetypes from any .lin files found in the support path.
;; Excludes known metric & imperial definition files based on the value of MEASUREMENT
;; lts -  List of linetypes to load
;; rdf -  If T, linetypes will be redefined from file if already loaded
;; Returns:  T if all linetypes are loaded successfully, else nil
 
(defun LM:loadlinetypes ( lts rdf / lst ltc rtn val var )
    (if (zerop (getvar 'measurement))
        (setq lst (mapcar 'strcase '("acadiso.lin" "iso.lin")))  ;; Known metric .lin files
        (setq lst (mapcar 'strcase '("acad.lin" "default.lin"))) ;; Known imperial .lin files
    )
    (setq ltc  (vla-get-linetypes (vla-get-activedocument (vlax-get-acad-object)))
          var '(cmdecho expert)
          val  (mapcar 'getvar var)
          lst  (vl-remove-if '(lambda ( x ) (member (strcase x) lst))
                   (apply 'append
                       (mapcar '(lambda ( dir ) (vl-directory-files dir "*.lin" 1))
                           (vl-remove "" (LM:str->lst (getenv "ACAD") ";"))
                       )
                   )
               )
    )
    (mapcar 'setvar var '(0 5))
    (setq rtn
        (apply 'and
            (mapcar
               '(lambda ( typ )
                    (cond
                        (   (not (tblsearch "ltype" typ))
                            (vl-some
                               '(lambda ( lin )
                                    (vl-catch-all-apply 'vla-load (list ltc typ lin))
                                    (tblsearch "ltype" typ)
                                )
                                lst
                            )
                        )
                        (   rdf
                            (vl-some
                               '(lambda ( lin )
                                    (and (LM:ltdefined-p typ lin)
                                         (vl-cmdf "_.-linetype" "_L" typ lin "")
                                         (tblsearch "ltype" typ)
                                    )
                                )
                                lst
                            )
                        )
                        (   t   )
                    )
                )
                lts
            )
        )
    )
    (mapcar 'setvar var val)
    rtn
)
 
;; Linetype Defined-p  -  Lee Mac
;; Returns T if the linetype is defined in the specified .lin file
;; ltp -  Linetype name
;; lin -  Filename of linetype definition file (.lin)
 
(defun LM:ltdefined-p ( ltp lin / str rtn )
    (if
        (and
            (setq lin (findfile lin))
            (setq lin (open lin "r"))
        )
        (progn
            (setq ltp (strcat "`*" (strcase ltp) "`,*"))
            (while
                (and (setq str (read-line lin))
                     (not (setq rtn (wcmatch (strcase str) ltp)))
                )
            )
            (close lin)
            rtn
        )
    )
)
 
;; String to List  -  Lee Mac
;; Separates a string using a given delimiter
;; str -  String to process
;; del -  Delimiter by which to separate the string
;; Returns:  List of strings
 
(defun LM:str->lst ( str del / pos )
    (if (setq pos (vl-string-search del str))
        (cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del))
        (list str)
    )
)

(defun VLA-ZoomObject (obj / minPt maxPt)
  (vla-GetBoundingBox obj 'minPt 'maxpt)
  (vla-ZoomWindow (vlax-get-acad-object) minPt maxpt)
)

(vl-load-com)
;|«Visual LISP© Format Options»
(70 2 1 2 nil "_eof " 100 9 0 0 1 T T T T)
;*** DO NOT add text below the comment! ***|;

bạn ơi cái lsp của bạn mình dùng toàn báo lỗi. khi pick xong polyline, nhập tỷ lệ ( vd 1/100 ) , chọn layout, xong nó tự động chuyển sang layout đã đc chọn, rồi chẳng có gì hiện ra và nó báo lỗi thế này Clip entity not currently regen'ed. ActiveX Server returned the error: unknown name: DisplaySelect object to clip viewport:

Tệp .lsp gốc không còn trên máy chủ. Hãy chép mã nguồn bên dưới (lấy từ bài viết gốc) vào một tệp văn bản, lưu với đuôi .lsp.

Cách dùng

  1. Chép mã nguồn, lưu thành tệp 362510_m2v.lsp.
  2. Trong AutoCAD gõ lệnh APPLOAD, chọn tệp vừa tải rồi bấm Load. Cũng có thể kéo thả tệp .lsp vào cửa sổ bản vẽ.
  3. Gõ lệnh M2V để chạy lisp.

Mã nguồn 362510_m2v.lsp (trích từ bài viết gốc)

(defun c:m2v (/ #app #doc *error* c cmd lay lst o sc vp)

  (defun *error* (msg)
    (and cmd (setvar 'cmdecho cmd))
    (and #doc (vla-endundomark #doc))
    (if	(and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
      (princ (strcat "\nError: " msg))
    )
  )
  
  (setq #app (vlax-get-acad-object)
	#doc (vla-get-activedocument #app)
	cmd (getvar 'cmdecho))
  
  (if (= 0 (vla-get-activespace #doc)) (vla-put-activespace #doc 1))
  
  (if (and (princ    "\nSelect a Closed LwPolyline:  ")
	   (setq o   (ssget "_+.:E:S" '((0 . "LWPOLYLINE") (70 . 1))))
	   (setq o   (ssname o 0))
	   (setq c   (pline-centroid o))
	   (setq o   (vlax-ename->vla-object o))
	   (setq sc  (distof (getstring "\nEnter Scale for new Viewport: ")))
	   (setq sc  (/ 1.0 sc))
      )
    (progn
      (vlax-for	lay (vla-get-layouts #doc)
	(if (/= "MODEL" (strcase (vla-get-name lay)))
	  (setq lst (cons (cons (vla-get-name lay) lay) lst))
	)
      )
      (if (setq	lst
		 (mapcar
		   '(lambda (x) (cdr (assoc x lst)))
		   (LM:Listbox
		     "Choose Layout[s] to create ViewPort"
		     (mapcar 'car
			     (vl-sort lst
				      '(lambda (a b)
					 (< (vla-get-taborder (cdr a))
					    (vla-get-taborder (cdr b))
					 )
				       )
			     )
		     )
		     t
		   )
		 )
	  )
	(progn
	  (vla-startundomark #doc)
	  (LM:loadlinetypes '("hidden") nil)
	  (setvar 'cmdecho 0)
	  (foreach lay lst
	    (vla-put-activelayout #doc lay)
	    (setq vp (vlax-vla-object->ename
		       (car (vlax-invoke
			      #doc
			      'copyobjects
			      (list o)
			      (vla-get-block lay)
			    )
		       )
		     )
	    )
	    (vla-put-linetype (vlax-ename->vla-object vp) "hidden")
	    (vl-cmdf "_.mview" "_object" vp)
	    (setq vp (vlax-ename->vla-object (entlast)))
	    (vla-put-linetype vp "hidden")
	    (vla-display vp :vlax-true)
	    (vla-put-mspace #doc :vlax-true)
	    (vla-put-ActivePViewport #doc vp)
	    (vla-zoomCenter #app (vlax-3d-point c) 1.0)
	    (vla-put-mspace #doc :vlax-false)
	    (vla-put-customscale vp sc)
	    (VLA-ZoomObject vp)
	  )
	)
      )
    )
  )
  (*error* nil)
  (princ)
)

;;==================================================================;;
;;======================== SUB FUNCTION ============================;;
;;==================================================================;;


;;=================== POLYLINE CENTROID BY GILE=====================;;
;; ALGEB-AREA
;; Returns tha algebraic area of the triangle defined by 3  2d points
;; the area is negative if points are clockwise

(defun algeb-area (p1 p2 p3)
  (/ (-	(* (- (car p2) (car p1))
	   (- (cadr p3) (cadr p1))
	)
	(* (- (car p3) (car p1))
	   (- (cadr p2) (cadr p1))
	)
     )
     2.0
  )
)

;; TRIANGLE-CENTROID
;; Returns the centroid of a triangle defined by 3 points

(defun triangle-centroid (p1 p2 p3)
  (mapcar '(lambda (x1 x2 x3)
	     (/ (+ x1 x2 x3) 3.0)
	   )
	  p1
	  p2
	  p3
  )
)

;; POLYARC-CENTROID
;; Returns a list which first item is the centroid of a 'polyarc'
;; and the second its algeraic area
;;
;; Arguments
;; bu : polyarc bulge
;; p1 : start point
;; p2 : end point

(defun polyarc-centroid	(bu p1 p2 / ang rad cen area dist cg)
  (setq	ang  (* 2 (atan bu))
	rad  (/	(distance p1 p2)
		(* 2 (sin ang))
	     )
	cen  (polar p1
		    (+ (angle p1 p2) (- (/ pi 2) ang))
		    rad
	     )
	area (/ (* rad rad (- (* 2 ang) (sin (* 2 ang)))) 2.0)
	dist (/ (expt (distance p1 p2) 3) (* 12 area))
	cg   (polar cen
		    (- (angle p1 p2) (/ pi 2))
		    dist
	     )
  )
  (list cg area)
)

;; PLINE-CENTROID
;; Returns the WCS coordinates of a lwpolyline centroid
;;
;; Argument
;; pl : the lwpolyline ename

(defun pline-centroid (pl / elst lst tot cen p0 area cen)
  (setq elst (entget pl))
  (while (setq elst (member (assoc 10 elst) elst))
    (setq lst  (cons (cons (cdar elst) (cdr (assoc 42 elst))) lst)
	  elst (cdr elst)
    )
  )
  (setq	lst (reverse lst)
	tot 0.0
	cen '(0.0 0.0)
	p0  (caar lst)
  )
  (if (/= 0 (cdar lst))
    (setq p-c (polyarc-centroid (cdar lst) p0 (caadr lst))
	  cen (mapcar '(lambda (x) (* x (cadr p-c))) (car p-c))
	  tot (cadr p-c)
    )
  )
  (setq lst (cdr lst))
  (if (equal (car (last lst)) p0 1e-9)
    (setq lst (reverse (cdr (reverse lst))))
  )
  (while (cadr lst)
    (setq area (algeb-area p0 (caar lst) (caadr lst))
	  cen  (mapcar '(lambda (x1 x2) (+ x1 (* x2 area)))
		       cen
		       (triangle-centroid p0 (caar lst) (caadr lst))
	       )
	  tot  (+ area tot)
    )
    (if	(/= 0 (cdar lst))
      (setq p-c	(polyarc-centroid (cdar lst) (caar lst) (caadr lst))
	    cen	(mapcar	'(lambda (x1 x2) (+ x1 (* x2 (cadr p-c))))
			cen
			(car p-c)
		)
	    tot	(+ tot (cadr p-c))
      )
    )
    (setq lst (cdr lst))
  )
  (if (/= 0 (cdar lst))
    (setq p-c (polyarc-centroid (cdar lst) (caar lst) p0)
	  cen (mapcar '(lambda (x1 x2) (+ x1 (* x2 (cadr p-c))))
		      cen
		      (car p-c)
	      )
	  tot (+ tot (cadr p-c))
    )
  )
  (trans (list (/ (car cen) tot)
	       (/ (cadr cen) tot)
	       (cdr (assoc 38 (entget pl)))
	 )
	 pl
	 0
  )
)

;;-----------------------=={ List Box }==---------------------;;
;;                                                            ;;
;;  Displays a List Box allowing the user to make a selection ;;
;;  from the supplied data.                                   ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2012 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  title    - List Box Dialog title                          ;;
;;  lst      - List of Strings to display in the List Box     ;;
;;  multiple - Boolean flag to determine whether the user     ;;
;;             may select multiple items (T=Allow Multiple)   ;;
;;------------------------------------------------------------;;
;;  Returns:  List of selected items, else nil.               ;;
;;------------------------------------------------------------;;
 
(defun LM:ListBox ( title lst multiple / dch des tmp res )
    (cond
        (   (not
                (and
                    (setq tmp (vl-filename-mktemp nil nil ".dcl"))
                    (setq des (open tmp "w"))
                    (write-line
                        (strcat
                            "listbox : dialog { label = \""
                            title
                            "\"; spacer; : list_box { key = \"list\"; multiple_select = "
                            (if multiple "true" "false")
                            "; } spacer; ok_cancel; }"
                        )
                        des
                    )
                    (not (close des))
                    (< 0 (setq dch (load_dialog tmp)))
                    (new_dialog "listbox" dch)
                )
            )
            (prompt "\nError Loading List Box Dialog.")
        )
        (   t     
            (start_list "list")
            (foreach item lst (add_list item))
            (end_list)
            (setq res (set_tile "list" "0"))
            (action_tile "list" "(setq res $value)")
            (setq res
                (if (= 1 (start_dialog))
                    (mapcar '(lambda ( x ) (nth x lst)) (read (strcat "(" res ")")))
                )
            )
        )
    )
    (if (< 0 dch)
        (unload_dialog dch)
    )
    (if (and tmp (setq tmp (findfile tmp)))
        (vl-file-delete tmp)
    )
    res
)

;; Load Linetypes  -  Lee Mac
;; Attempts to load a list of linetypes from any .lin files found in the support path.
;; Excludes known metric & imperial definition files based on the value of MEASUREMENT
;; lts - [lst] List of linetypes to load
;; rdf - [bol] If T, linetypes will be redefined from file if already loaded
;; Returns: [bol] T if all linetypes are loaded successfully, else nil
 
(defun LM:loadlinetypes ( lts rdf / lst ltc rtn val var )
    (if (zerop (getvar 'measurement))
        (setq lst (mapcar 'strcase '("acadiso.lin" "iso.lin")))  ;; Known metric .lin files
        (setq lst (mapcar 'strcase '("acad.lin" "default.lin"))) ;; Known imperial .lin files
    )
    (setq ltc  (vla-get-linetypes (vla-get-activedocument (vlax-get-acad-object)))
          var '(cmdecho expert)
          val  (mapcar 'getvar var)
          lst  (vl-remove-if '(lambda ( x ) (member (strcase x) lst))
                   (apply 'append
                       (mapcar '(lambda ( dir ) (vl-directory-files dir "*.lin" 1))
                           (vl-remove "" (LM:str->lst (getenv "ACAD") ";"))
                       )
                   )
               )
    )
    (mapcar 'setvar var '(0 5))
    (setq rtn
        (apply 'and
            (mapcar
               '(lambda ( typ )
                    (cond
                        (   (not (tblsearch "ltype" typ))
                            (vl-some
                               '(lambda ( lin )
                                    (vl-catch-all-apply 'vla-load (list ltc typ lin))
                                    (tblsearch "ltype" typ)
                                )
                                lst
                            )
                        )
                        (   rdf
                            (vl-some
                               '(lambda ( lin )
                                    (and (LM:ltdefined-p typ lin)
                                         (vl-cmdf "_.-linetype" "_L" typ lin "")
                                         (tblsearch "ltype" typ)
                                    )
                                )
                                lst
                            )
                        )
                        (   t   )
                    )
                )
                lts
            )
        )
    )
    (mapcar 'setvar var val)
    rtn
)
 
;; Linetype Defined-p  -  Lee Mac
;; Returns T if the linetype is defined in the specified .lin file
;; ltp - [str] Linetype name
;; lin - [str] Filename of linetype definition file (.lin)
 
(defun LM:ltdefined-p ( ltp lin / str rtn )
    (if
        (and
            (setq lin (findfile lin))
            (setq lin (open lin "r"))
        )
        (progn
            (setq ltp (strcat "`*" (strcase ltp) "`,*"))
            (while
                (and (setq str (read-line lin))
                     (not (setq rtn (wcmatch (strcase str) ltp)))
                )
            )
            (close lin)
            rtn
        )
    )
)
 
;; String to List  -  Lee Mac
;; Separates a string using a given delimiter
;; str - [str] String to process
;; del - [str] Delimiter by which to separate the string
;; Returns: [lst] List of strings
 
(defun LM:str->lst ( str del / pos )
    (if (setq pos (vl-string-search del str))
        (cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del))
        (list str)
    )
)

(defun VLA-ZoomObject (obj / minPt maxPt)
  (vla-GetBoundingBox obj 'minPt 'maxpt)
  (vla-ZoomWindow (vlax-get-acad-object) minPt maxpt)
)

(vl-load-com)
;|«Visual LISP© Format Options»
(70 2 1 2 nil "_eof " 100 9 0 0 1 T T T T)
;*** DO NOT add text below the comment! ***|;

Thảo luận gốc

Lisp được chia sẻ trong chủ đề Nhờ các bạn giúp đỡ sửa lisp. Xem đúng bài viết #362510 để đọc hướng dẫn và trao đổi thêm.

Về Thư viện AutoLisp (trang 320)