Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Double selection issue..

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
danglar
1059 Views, 2 Replies

Double selection issue..

Hi All.

This program add sq. m suffix to selected text (see code):

;;; Add Sq.m simbol to the end of text and change text style to apropriative one.
;;; Combined from existing routines and deeply modified by Igal Averbuh 2016

(defun C:Sst (/ entities len count ent ent_data ent_name new_style_name)
 
(princ "\nSelect text :")
(setq entities (ssget '((0 . "TEXT")))
      len      (sslength entities)
      count 0
);setq 
 (command "STYLE" "igal" "arial.ttf" "" "" "" "" "")
(while (< count len)
       (setq ent      (ssname entities count) 
             ent_data (entget ent)
             ent_name (cdr (assoc 7 ent_data))
       );setq
 
(setq new_style_name (cons 7 "igal"))
(setq ent_data (subst new_style_name (assoc 7 ent_data) ent_data))
(entmod ent_data)
 
(setq count (+ count 1))
);while
 
(princ)
 
);defun

(defun c:smt1 (/ entdata btxt ntxt bltxt)


 (while  (setq bltxt (nentsel "\nSelect text to add m²: "))
           
     
           
       

  (setq entdata (entget (car bltxt))
          btxt (cdr (assoc 1 entdata))
          ntxt (strcat btxt " m²")
          );_setq
  (entmod (subst (cons 1 ntxt)(assoc 1 entdata) entdata))
  (entupd (cdr (assoc -1 entdata)))

      );_while
);_defun

(defun c:smt() ;Main function
(c:sst)
(c:smt1)

)

(c:smt)


 

 

but first of all it change style of selected text in order to use Unicode extensions

This routine was combined and deeply modified in order to combine changing style of selected text with add sq. m suffix 

All works properly, but "dirty" I mean user need to select text twice: once to change style and other one - to add suffix

Is it possible to do it in one selection?

Note: Select previous not works because text has been already changed

Any help will be very appreciated

2 REPLIES 2
Message 2 of 3
ВeekeeCZ
in reply to: danglar

Try...

 

(defun c:Addm2 (/ ss ots i ed tx)

  (if (and (setq ss (ssget '((0 . "TEXT"))))
	   (setq ots (getvar 'TEXTSTYLE))
	   (or (tblsearch "STYLE" "igal")
	       (command "STYLE" "igal" "arial.ttf" "" "" "" "" "")
	       (setvar 'TEXTSTYLE ots))
	   )
    (repeat (setq i (sslength ss))
      (setq ed (entget (ssname ss (setq i (1- i)))))
      (entmod (append ed
		      (list (cons 1 (strcat (setq tx (cdr (assoc 1 ed)))
					    (if (wcmatch tx "* m\\U+00B2")
					      ""
					      " m\\U+00B2")))
			    (cons 7 "igal"))))))
  (princ)
)

(c:addm2)

 

 

Message 3 of 3
danglar
in reply to: ВeekeeCZ

Wow! It's works like a charm!

More simple.. more efficient.. in short MORE...

Thank you.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost