100cm and bigger

100cm and bigger

k005
Advisor Advisor
8,140 Views
42 Replies
Message 1 of 43

100cm and bigger

k005
Advisor
Advisor

Hello guys;

 

How can I calculate the area of column sizes of 100 cm and above?

 

* The number 260 will be entered manually. example is attached.

 

* We will make the color of the relevant parts green.

 

Thanks.

0 Likes
Accepted solutions (4)
8,141 Views
42 Replies
Replies (42)
Message 2 of 43

hak_vz
Advisor
Advisor

@k005You are not new to this forum, so please, to help us create your script attach sample dwg.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 3 of 43

k005
Advisor
Advisor

 

Sorry.

 

 

0 Likes
Message 4 of 43

hak_vz
Advisor
Advisor

Try this

 

(defun c:area_100+ ( / ss i con sumlist mult);
(princ "\nSelect all columns text >")
(setq ss (ssget '((0 . "TEXT") (8 . "Kolon"))) i -1)
(while (< (setq i (1+ i)) (sslength ss))
	(setq con (cdr (assoc 1 (entget(ssname ss i)))))
	(setq con (substr con (+(vl-string-position (ascii "(")con)2)))
	(setq con (substr con 1 (vl-string-position (ascii "/")con)))
	(setq con (atof con))
	(cond ((>= con 100.0)(setq sumlist (cons con sumlist))))
)
(cond
	((and sumlist)
		(setq mult (getreal "\nEnter multiplicator >"))
		(princ (strcat "\nLengths: "(vl-princ-to-string sumlist) "\n"))
		(princ (strcat "Total area = " (rtos (* mult (apply '+ sumlist)) 2 2)))
	)
	(T (princ "\nNo column > 100 "))
)
(princ)
)

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 5 of 43

k005
Advisor
Advisor

* a fix: for attached file

Not 6.45 m², correct calculation: It should be 10.53 m². I made a mistake...

------------------------------------------------------------------------------------

 

 

@hak_vz 

 

 

 

Good luck my friend. yes, that's exactly it. if it can change the selected columns to green color. It'll be super. It's not much of a problem...

0 Likes
Message 6 of 43

hak_vz
Advisor
Advisor
Accepted solution

This will change column text to green. Multiplier is entered in centimeters, result is expressed in m2. For your test sample it gives 10.53. Code was edited so take last version.

 

 

(defun c:area_100+ ( / ss i con sumlist mult); 
(princ "\nSelect all columns text >")

(setq ss (ssget '((0 . "TEXT") (8 . "Kolon"))) i -1)
(while (< (setq i (1+ i)) (sslength ss))
	(setq con (cdr (assoc 1 (entget(ssname ss i)))))
	(setq con (substr con (+(vl-string-position (ascii "(")con)2)))
	(setq con (substr con 1 (vl-string-position (ascii "/")con)))
	(setq con (atof con))
	(cond 
		((>= con 100.0)
			(setq sumlist (cons (* 0.01 con) sumlist))
			(vlax-put (vlax-ename->vla-object (ssname ss i)) 'Color 3)
		)
	)
)
(cond
	((and sumlist)
		(setq mult (getreal "\nEnter multiplier >"))
		(princ (strcat "\nLengths: "(vl-princ-to-string sumlist) "\n"))
		(princ (strcat "Total area = " (rtos (* 0.01 mult (apply '+ sumlist)) 2 2) " m2"))
	)
	(T (princ "\nNo column > 100 "))
)
(princ)
)

 

 

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 7 of 43

k005
Advisor
Advisor

@hak_vz 

 

Thank you very much. It's ok. 🤗

Message 8 of 43

pbejse
Mentor
Mentor
Accepted solution

@k005 wrote:

* The number 260 will be entered manually. example is attached.

* We will make the color of the relevant parts green.

 


(defun c:Demo ( / tData Total Strng ss ml pt i str)
(if   (and
     (setq Total 0 strng ""
	  ss (ssget '((0 . "TEXT") (8 . "KOLON")(1 . "*(###/#*)"))))
      (setq ml (getreal "\nEnter factor: "))
      (setq pt (getpoint "\nPick point for Total: "))
     )
  
   (progn
     (repeat (setq i (sslength ss))
       (setq str (cdr (assoc 1 (setq ent (entget  (ssname ss (setq i (1- i))))))))
       	  (setq str (atoi (substr str (+ 2 (vl-string-position 40 str  nil t))))
		Total (+ Total str)
		strng (strcat "+" (itoa str) strng)
		)
       (entmod (append ent '((62 . 3)))) 
       (or tData (setq tData (mapcar '(lambda (d)
			(assoc d ent))'(0 7 8 62 40 50))))		
       )					 		 
        (entmakex (append  tData
			  (list '(62 . 3)(cons 10 pt)
				(cons 1 (strcat "ALAN: (" (substr strng 2) ")x"
							 (rtos ml) " = "
							 (rtos (* 0.0001 Total ml) 2 2) " m²")))))
	     )
	  )(princ)
  )

HTH

 

 

Message 9 of 43

k005
Advisor
Advisor

@pbejse 

 

I'm adding this solution to my Archive. Thank you very much. 🤗

0 Likes
Message 10 of 43

k005
Advisor
Advisor

@pbejse

@hak_vz 

 

Friends; Can we do this in line or lwpolyline version instead of text?

 

(1 . "*(###/#*)"))))

0 Likes
Message 11 of 43

hak_vz
Advisor
Advisor

@k005  Please explain in details

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 12 of 43

k005
Advisor
Advisor

@hak_vz 

 

......

.....

How can I calculate the area of column sizes of 100 cm and above?

 

* The number 260 will be entered manually. example is attached.

 

* We will make the color of the relevant parts green.

......

 

 

 

 

0 Likes
Message 13 of 43

hak_vz
Advisor
Advisor

In other words, select all rectangles that have a edge longer than 100, and set its color to green?

 

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 14 of 43

k005
Advisor
Advisor

Yes. including 100

0 Likes
Message 15 of 43

hak_vz
Advisor
Advisor
(defun c:rect_side_greather_than ( / adoc edge_length ss i j  pointlist2d take eo pointset lenghts *error*)
	(defun *error* ( msg )
		(if (not (member msg '("Function cancelled" "quit / exit abort")))
			(princ)
		)
		(if (and adoc) (vla-endundomark adoc))
		(princ)
	)
	(defun pointlist2d (lst / ret) (while lst (setq	ret (cons (take 2 lst) ret) lst (cddr lst))) (reverse ret))
	(defun take (amount lst / ret)(repeat amount (setq ret (cons (car lst) (take (1- amount) (cdr lst))))))
	(setq edge_length (getreal "\Enter minimal rectangle edge length >"))
	(setq ss (ssget '((0 . "LWPOLYLINE") (8 . "Kolon"))) i -1)
	(setq adoc (vla-get-activedocument (vlax-get-acad-object))) 
	(vla-endundomark adoc)
	(vla-startundomark adoc)
	(while (< (setq i (1+ i)) (sslength ss))
		(setq eo (vlax-ename->vla-object (ssname ss i)))
		(setq pointset (pointlist2d (vlax-get eo 'Coordinates)))
		(setq pointset (append pointset (list (car pointset))))
		(setq lenghts nil j -1)
		(while (< (setq j (1+ j)) (1- (length pointset)))(setq lenghts (cons (distance (nth j pointset)(nth (1+ j) pointset)) lenghts)))
		(cond ((>= (apply 'max lenghts) edge_length) (vlax-put eo 'Color 3)))
	)
	(vla-endundomark adoc)
	(princ "\nDone!")
	(princ)
)

 

In case rectangle in not closed ie, edges are polyline segments, it will put color to green only to polyline edges greater than minimal length.  If closed, rectangle will be changed to green. I would join all segmented rectangles to  one single polyline it that is not a problem for you.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 16 of 43

k005
Advisor
Advisor

Yes, that's exactly it. we will also make an area account,..

Let's say we entered 260 manually, we will add the lengths of the green wings and multiply by 260, my friend.

 

* (setq edge_length (getreal "\Enter minimal rectangle edge length >"))
We can fix this part to 100.

0 Likes
Message 17 of 43

hak_vz
Advisor
Advisor

In other words at start you have rectangles created with polyline segments. We collect all sides greater or equal to 100

, color it green, and sum its length to total length. At the end we multiply total length to wall height. and convert to square meters. When finished you can join segments to closed polylines.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 18 of 43

k005
Advisor
Advisor

Ok so far.
we have to manually enter 260, add the side lengths and calculate the AREA.

0 Likes
Message 19 of 43

hak_vz
Advisor
Advisor

Try this. Works on segmented rectangles which edge is either line or polyline.

(defun c:rect_side_greather_than_100 ( / adoc edge_length ss i eo  total total_length wall_height total_area *error*);
	(defun *error* ( msg )
		(if (not (member msg '("Function cancelled" "quit / exit abort")))
			(princ)
		)
		(if (and adoc) (vla-endundomark adoc))
		(princ)
	)

	(setq edge_length 100.0)
	(setq ss (ssget '((0 . "LWPOLYLINE,LINE") (8 . "Kolon"))) i -1)
	(setq adoc (vla-get-activedocument (vlax-get-acad-object))) 
	(initget 1)
	(setq wall_height (getreal "\nWall heigth >"))
	(vla-endundomark adoc)
	(vla-startundomark adoc)
	(while (< (setq i (1+ i)) (sslength ss))
		(setq eo (vlax-ename->vla-object (ssname ss i)))
		(setq len (vlax-get eo 'Length))
			(cond
				((>= len 100)
					(vlax-put eo 'Color 3)
					(setq total (cons (* 0.01 len) total))
				)
			)
		
	)
	(setq total_length (apply '+ total))
	(setq total_area (* 0.01 wall_height total_length))
	(princ (strcat "\nLengths greater than 100: "(vl-princ-to-string total) "\n"))
	(princ (strcat "\Total lenght > 100: " (rtos total_length 2 2) " m \n"))
	(princ (strcat "Total area = " (rtos total_area 2 2) " m2"))
	(vla-endundomark adoc)
	(princ "\nDone!")
	(princ)
)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 20 of 43

k005
Advisor
Advisor

@hak_vz 

 

 

Thank you very much my friend. It's okay with a little difference.

Let's go from the example file:

result: 21.06 m².

The result should be: 10.53 m².

ie : result / 2

If it's not too much trouble... Thank you.

 

 

0 Likes