Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/09/2020 in all areas

  1. (defun c:Foo (/ s ) (and (setq s (ssget "_X" '((0 . "XLINE")))) (command "_.erase" s "") ) (princ) )
    2 points
  2. Use an alphanumerical sorting function to interpret & sort numerical data within the string, rather than sorting character-wise, e.g. to sort layouts alphanumerically, you might use: (defun c:sortlayouts ( / ls1 ls2 ord ) (vlax-for lyt (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (if (= :vlax-false (vla-get-modeltype lyt)) (setq ls1 (cons (strcase (vla-get-name lyt)) ls1) ls2 (cons lyt ls2) ) ) ) (setq ord 0) (foreach idx (LM:alphanumsort-i ls1) (vla-put-taborder (nth idx ls2) (setq ord (1+ ord))) ) (princ) ) ;; Alphanumerical Sort-i - Lee Mac ;; Sorts a list of strings containing a combination of alphabetical & numerical characters and returns the indices. (defun LM:alphanumsort-i ( lst ) (vl-sort-i (mapcar 'LM:splitstring lst) (function (lambda ( a b / x y ) (while (and (setq x (car a)) (setq y (car b)) (= x y) ) (setq a (cdr a) b (cdr b) ) ) (cond ( (null x) b) ( (null y) nil) ( (and (numberp x) (numberp y)) (< x y)) ( (numberp x)) ( (numberp y) nil) ( (< x y)) ) ) ) ) ) ;; Split String - Lee Mac ;; Splits a string into a list of text and numbers (defun LM:splitstring ( str ) ( (lambda ( l ) (read (strcat "(" (vl-list->string (apply 'append (mapcar (function (lambda ( a b c ) (cond ( (or (= 34 b) (= 92 b)) (list 32 34 92 b 34 32) ) ( (or (< 47 b 58) ;(and (= 45 b) (< 47 c 58) (not (< 47 a 58))) (and (= 46 b) (< 47 a 58) (< 47 c 58)) ) (list b) ) ( (list 32 34 b 34 32)) ) ) ) (cons nil l) l (append (cdr l) '(( ))) ) ) ) ")" ) ) ) (vl-string->list str) ) ) (vl-load-com) (princ)
    1 point
  3. This one will sort all the desired tabs and places it at the end of the list of all the layouts. (defun c:test ( / acd ind len lst nm sortl) (while (progn (initget 6) (setq nm (getint "\nSpecify number <exit>: ")) (cond ((not nm) nil) ((progn (setq nm (itoa nm)) (vl-some '(lambda (x) (if (wcmatch x (strcat nm "`-[12]")) (princ (strcat "\nLayout name " x " already exists.")) ) ) (layoutlist) ) ) ) ) ) ) (if nm (progn (setq acd (vla-get-Layouts (vla-get-ActiveDocument (vlax-get-acad-object)))) (foreach x (list (strcat nm "-1") (strcat nm "-2")) (vla-Add acd x) ) (setq lst (layoutlist) sortl (vl-remove-if-not '(lambda (x) (wcmatch x "#*`-[12]")) lst) ind (vl-sort sortl '(lambda (a b) (if (= (atoi a) (atoi b)) (< (atoi (substr a (+ (vl-string-search "-" a) 2))) (atoi (substr b (+ (vl-string-search "-" b) 2))) ) (< (atoi a) (atoi b)) ) ) ) len (length lst) ) (mapcar '(lambda (x) (vla-put-TabOrder (vla-item acd x) len)) ind) ) ) (princ) )
    1 point
  4. Or go for a Donut, which is a polyline circle with width
    1 point
×
×
  • Create New...