Text total Area

Text total Area

k005
Advisor Advisor
713 Views
8 Replies
Message 1 of 9

Text total Area

k005
Advisor
Advisor

 

Hello there

 

How can I print the product of text files as square meters like in the example?

0 Likes
Accepted solutions (1)
714 Views
8 Replies
Replies (8)
Message 2 of 9

Kent1Cooper
Consultant
Consultant

I assume you mean text objects, not files.  In any case, what is the meaning of text content like  150/130  in relation to area?

Kent Cooper, AIA
0 Likes
Message 3 of 9

k005
Advisor
Advisor

150/30: window size, 90/210: door size. Unit : cm

 

* Area of (TEXT) fields of these values and automatic summing.

 

 

result : minha : xxxx m²

0 Likes
Message 4 of 9

ВeekeeCZ
Consultant
Consultant

Perhaps this could help you.

 

(vl-load-com)

(defun c:WindowArea ( / LM:str->lst s del)

  (defun LM:str->lst ( str / pos )
    (if (setq del "/"
	      pos (vl-string-search del str))
        (cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del)))))
        (list str)))

  (if (setq s (ssget '((0 . "TEXT") (1 . "*/*"))))
    (princ (rtos (apply '+ (mapcar '(lambda (y) (apply '* (mapcar 'atof y))) (mapcar 'LM:str->lst (mapcar '(lambda (x) (getpropertyvalue x "TextString")) (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))))))))
  (princ)
  )

 

Message 5 of 9

Kent1Cooper
Consultant
Consultant
Accepted solution

Here's my approach to it:

(defun C:OAT ; = Opening Area Total
  (/ ss oat n str)
  (if (setq ss (ssget '((0 . "TEXT") (1 . "*#/#*"))))
    (progn ; then
      (setq oat 0)
      (repeat (setq n (sslength ss))
        (setq
          str (cdr (assoc 1 (entget (ssname ss (setq n (1- n))))))
          oat
            (+
              oat
              (/
                (*
                  (atoi (substr str 1 (vl-string-search "/" str)))
                  (atoi (substr str (+ (vl-string-search "/" str) 2)))
                ); *
                10000.0 ; cm² to m²
              ); /
            ); + & oat
        ); setq
      ); repeat
      (command "_.text" "_mc" pause "" 0 (strcat "Minha : " (rtos oat 2 2) " m²"))
    ); progn
  ); if
  (princ)
); defun

It uses the current Text Style [assumed to not have a fixed height, as in the sample drawing] and height, on the current Layer; specifics for those could all be built into it if needed.

Kent Cooper, AIA
Message 6 of 9

pbejse
Mentor
Mentor

 

(Defun c:porridge (/ sss i sum pt str)
  (if (and
	(setq sum 0
	      sss (ssget '((0 . "TEXT") (1 . "*/*")))
	)
	(setq pt (getpoint "\nPick Text insertion point"))
      )

    (progn
      (repeat (setq i (sslength sss))
	(setq str (cdr (assoc 1 (entget (ssname sss (setq i (1- i)))))))
	(setq sum
	       (+
		 sum
		 (eval
		   (read (strcat "( * " (vl-string-subst " " "/" str) ")")
		   )
		 )
	       )
	)
      )
      (entmakex
	(list (cons 0 "TEXT")
	      (cons 10 (trans pt 1 0))
	      (cons 7 (getvar 'Textstyle))
	      (cons 40 (getvar 'Textsize))
	      (cons 1
		    (strcat "Minha : " (rtos (* 0.0001 sum) 2 2) " m²")
	      )
	)
      )
    )
  )
  (princ)
)

 

 

Message 7 of 9

ronjonp
Mentor
Mentor

Another for fun:

(defun c:foo (/ a p r s v)
  ;; RJP » 2021-07-29
  (cond	((setq s (ssget '((0 . "TEXT") (1 . "*#/#*"))))
	 (setq a (ssname s 0))
	 (setq r 0)
	 (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	   (setq v (read (strcat "(" (vl-string-translate "/" " " (cdr (assoc 1 (entget e)))) ")")))
	   (setq r (+ r (/ (apply '* v) 10000.)))
	 )
	 (if (setq p (getpoint "\nPick a point to place results: "))
	   (entmake (append (entget a)
			    (list (cons 10 p)
				  '(8 . "CERCEVE")
				  (cons 1 (strcat "Minha : " (rtos r 2 2) " m²"))
				  '(50 . 0.)
				  '(40 . 30.)
			    )
		    )
	   )
	 )
	)
  )
  (princ)
)
Message 8 of 9

k005
Advisor
Advisor

@Kent1Cooper 

 

Yup. That's what was wanted. Thank you very much, it's ok. 🤗

 

0 Likes
Message 9 of 9

k005
Advisor
Advisor

@ronjonp 

@pbejse 

@ВeekeeCZ 

 

I tested all of them. Successful in all.

Thank you very much guys. 🤗🤗🤗

 

I save as an alternative...

0 Likes