Jump to content

Leaderboard

Popular Content

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

  1. This works for me, selects text with user input as BigAl suggested and MHupps first bit of code (slight modification to both, using "(getstring T....)" to allow for spaces in the text string and (cons 1 str) which mhupp uses n his second code) (defun C:seltxt (/ SS str) (setq str "") (while (/= "" (setq txt (getstring T "\nType text Enter to stop "))) (setq str (strcat str "," txt)) ) (setq SS (ssget "_X" (list '(0 . "*TEXT") (cons 1 str) (cons 410 (getvar 'ctab))))) (sssetfirst nil ss) (princ) ) Noting that this is case sensitive, not sure how to do it otherwise, and it also accepts wold cards, search term Hello won't select 'Hello World' text in the drawing. but search Hello* should pick it up (and so should *llo wo*)
    3 points
  2. You can use a simple (while and just add the txt to a string. (setq str "") (while (/= "" (setq txt (getstring "\nType text Enter to stop "))) (setq str (strcat str "," txt)) )
    3 points
  3. Not me, I just copied and pasted BigAl and Mhupp.....
    1 point
  4. Without seeing the drawing I can only guess while holding down the Alt key they entered 154 before releasing the Alt key which added the Ü. https://theasciicode.com.ar/extended-ascii-code/non-breaking-space-no-break-space-ascii-code-255.html Alt+154 Ü Alt+153 Ö Alt+144 É The Extended Characters aren't standardized so while Alt+211 returns ╙ on this website I'm sure it worked as expected with the font used in that drawing's text. You can also use the Windows Character Map which displays the Alt+ number on the lower-right of a selected character. This macro will open it: ^C^C^P(progn(startapp "Charmap.exe")(princ)) I use the Command Name: Character Map with the attached image for a quick reference in my Annotation tab.
    1 point
  5. ad s ;| Infix notation Converter and Calculator Supports: + - * / ^ ( ) _Examples_ (str2prefix "B*8-5/2^(2 PI)") -> (- (* B 8) (/ 5 (EXPT 2 (* 2 PI)))) (setq B 4.6) (calculate "B*8-5/2^(2 PI)") -> 36.7358 (eval (infix-prefix '(10 - 3 - 2 - 1))) -> 4 (infix-prefix '(10 - 3 - 2 - 1)) -> (- (- (- 10 3) 2) 1) It also handles unary - and +, and implicit multiplication: (infix-prefix '(- 2 a + b)) -> (+ (* (- 2) A) B) |; ;Original code from: http://www.lispology.com/show?JIH by: johnsondavies (defun str2prefix (str / i cache) (setq i 1 cache "(") (repeat (strlen str) (setq char (substr str i 1)) (if (member char '("+" "-" "*" "/" "(" ")" "^" "%")) (setq cache (strcat cache " " char " ")) (setq cache (strcat cache char)) ) (setq i (1+ i)) ) (setq cache (strcat cache ")")) (infix-prefix (read cache)) ) (defun calculate (str) (eval (str2prefix str))) (setq *binary-operators* '((+ 1 +) (- 1 -) (* 2 *) (/ 2 /) (^ 3 expt))) ;removed (x 2 *) to avoid accidents (setq *unary-operators* '((+ 4 +) (- 4 -))) (defun weight (c) (cadr (assoc c *binary-operators*))) (defun binary-opcode (c) (caddr (assoc c *binary-operators*))) (defun unary-opcode (c) (caddr (assoc c *unary-operators*))) (defun infix-prefix (ae) (cond ((atom ae) ae) (t (inf-aux ae nil nil)) ) ) (defun inf-aux (ae operators operands) (cond ;; Unary operator ((and (atom (car ae)) (assoc (car ae) *unary-operators*)) (inf-iter (cddr ae) operators (cons (list (unary-opcode (car ae)) (infix-prefix (cadr ae))) operands))) (t (inf-iter (cdr ae) operators (cons (infix-prefix (car ae)) operands))))) (defun inf-iter (ae operators operands) (cond ((and (null ae) (null operators)) (car operands)) ;; Implicit multiplication ((and ae (or (listp (car ae)) (null (weight (car ae))))) (inf-iter (cons '* ae) operators operands)) ((and ae (or (null operators) (> (weight (car ae)) (weight (car operators))))) (inf-aux (cdr ae) (cons (car ae) operators) operands)) (t (inf-iter ae (cdr operators) (cons (list (binary-opcode (car operators)) (cadr operands) (car operands)) (cddr operands))))))
    1 point
  6. @hosneyalaa Please don't use my codes in such a missy way of coding via copying and pasting then removing my name from my routine. CHECK Always try to write yours to get experience via practicing.
    1 point
  7. Thinking more about this maybe it would be better to let the user decide what to search for. or use both top for common terms and this for not so common terms. You also have to input the * for wild cards and use , if you going to search for more then one term. its also important to note when typing the search terms you can't use spaces. (defun C:selTxt (/ SS txt) (setq txt (getstring "\nSearch Text for Terms: ")) ;hit enter for defult options. (if (eq txt "") (setq txt "Area*,*m2") ;set defult search options here ) (if (setq SS (ssget "_X" (list '(0 . "*TEXT") (cons 1 txt) (cons 410 (getvar 'ctab))))) (sssetfirst nil ss) (prompt (strcat "\nText doesn't contain " txt)) ) (princ) ) Example Search Text for: area*,*m2 This would work like above lisp. Search Text for: *area* This would select text that has the word "area" in it. Search Text for: *door This would select text that ends with "door" Search Text for: area*,*m2,*area*,*door This would select all 3 examples text in one go.
    1 point
  8. You're welcome! - For an alphabetically sorted output, try the following: (defun c:layernames ( / f l s x ) (if (and (setq s (ssget)) (setq f (getfiled "Create File" "" "txt" 1)) ) (if (setq f (open f "w")) (progn (repeat (setq i (sslength s)) (or (member (setq x (cdr (assoc 8 (entget (ssname s (setq i (1- i))))))) l) (setq l (cons x l)) ) ) (foreach x (acad_strlsort l) (write-line x f)) (close f) ) (princ "\nUnable to open file for writing.") ) ) (princ) )
    1 point
×
×
  • Create New...