Wall Calculate

Wall Calculate

k005
Advisor Advisor
3,783 Views
23 Replies
Message 1 of 24

Wall Calculate

k005
Advisor
Advisor

Hello there

How can I calculate the X distance from the P1 and P2 points as I have specified in the appendix, and multiply the result with the Height, and print the result in the middle of the wall in m² when measuring the walls of 10?

We can't drop the gaps.
---------------------------------------------

0- Wall width : ? ( 10 )

1- first point, second point
2- wall height : ?
----------------------------------------
X (cm) * Wall height (cm)

 

and the command will continue without ending after typing the text...

Result :   10 luk Duvar : xxx m²

0 Likes
Accepted solutions (2)
3,784 Views
23 Replies
Replies (23)
Message 2 of 24

pendean
Community Legend
Community Legend
While you wait...

Are you on a current AutoCAD subscription? If yes, may I ask why you are not using the free-to-you AutoCAD-ARCHITECTURE variant that not only creates WALL objects (not lines touching each other) and has all the automated tools you see for wall areas and so much more built in https://knowledge.autodesk.com/support/autocad-architecture/learn-explore/caas/CloudHelp/cloudhelp/2...
0 Likes
Message 3 of 24

Kent1Cooper
Consultant
Consultant

Something could be worked out to do that, but questions arise:

 

Would you want [I assume] the Y distance instead of X if the difference between the two points is greater in the Y direction, automatically?

 

Would the walls always be in orthogonal directions, or might there be any at angles?  If so, is it acceptable to require selection of the two points on the same side of the wall?  Or to require selection of one of the wall Lines to establish what the angle is?

Kent Cooper, AIA
Message 4 of 24

k005
Advisor
Advisor

@Kent1Cooper 

 

 

Yes, the example I gave was for horizontal walls.

yes, we will get the Y value for vertical walls as well. That's always great value.

the angle is usually either 0° or 90°. is

 

0° : horizontal walls ( X )

 

90° : Vertical walls ( Y )

0 Likes
Message 5 of 24

k005
Advisor
Advisor

@pendean 

 

What exactly is this ?

I am not using Autocad architecture. This is not always necessary...

 

0 Likes
Message 6 of 24

hak_vz
Advisor
Advisor

@k005

Can we formulate this request as:

Select two point along a wall at opposite ends (dx > 0 and dy > 0).
- a) width >= height --> horizontal wall, otherwise vertical wall

- b) min (dx xy) is wall width - no need ask for input if scale is 1 : 1 and drafting is precise.

- c) max (dx dy) is total wall length

- d) Points p1 and p2 will always be selected inside full space

- e) Process only segments along horizontal (vertical) center line (bisector) between points p1 and p2. Ignore  

       segments heading in opposite direction to wall direction. If wall is horizontal ignore all vertical segments

 

Divide center line in segments at intersection points with wall lines, add up only odd ones

Depending on type of the wall change text orientation angle and create text at user picked point and loop.

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 24

k005
Advisor
Advisor

@hak_vz 

 

 

I think it can be formulated that way.

* It can always write horizontally only when typing text. this is not a problem.

* My purpose: to calculate the other long side from the hypotenuse. It really is that simple..

 

0- ask for wall width. (for separation in this conclusion. : 10 xxx m²)

1- first point, second point ( for hypotenuse . From there we will calculate X or Y. that's what we need  )

 

2- wall height ( to reach this m².)

 

0 Likes
Message 8 of 24

Kent1Cooper
Consultant
Consultant

@hak_vz wrote:

....

- e) Process only segments along horizontal (vertical) center line (bisector) between points p1 and p2. Ignore  

       segments heading in opposite direction to wall direction. If wall is horizontal ignore all vertical segments

Divide center line in segments at intersection points with wall lines, add up only odd ones

....


I didn't get aspects like those out of the description in Message 1.  Ask for wall height, and multiply that by overall wall length, ignoring openings, to calculate the area to put into Text content.

Kent Cooper, AIA
Message 9 of 24

Kent1Cooper
Consultant
Consultant

@k005 wrote:

.... when measuring the walls of 10....
---------------------------------------------

0- Wall width : ? ( 10 )

1- first point, second point
2- wall height : ?
....


In light of the answers to other questions, going back to this and the Point locations in the drawing:  If you would always pick points at opposite ends and on opposite sides of the wall, and if the walls are always orthogonal, then the routine can calculate the wall width -- it would not need to ask the User for that.  Is that desirable?

Kent Cooper, AIA
Message 10 of 24

k005
Advisor
Advisor

@Kent1Cooper 

 

Yes true. Of course, this width part is needed when printing the result text.

Yes, it can also be calculated in this way. Wall width.

0 Likes
Message 11 of 24

Sea-Haven
Mentor
Mentor

I am confused also why not just length x height, why do you need horizontal and vertical, the text can be orientated to match. Just a side issue if thickness is used then height is known. If its a line pick line, if a pline can do segments and label.  For image can do a full wall dump total area as its by layer.

 

 

0 Likes
Message 12 of 24

hak_vz
Advisor
Advisor

@k005 

Here is my conceptual solution for horizontal wall case (vertical is similar).

All walls are created as line entities (as in example)

After your review I can make changes. Keep in mind that code is not thoroughly tested.

To use Unicode text use TTF font.

That's all from me for now.

(defun c:warea (/ wh p1 p2 x1 x2 y1 y2 dx dy ss eo p3 p4 int_pts seg_lst i t_lst  seg l)
	(defun LM:Unique ( l )(if l (cons (car l) (LM:Unique (vl-remove (car l) (cdr l))))))
     (setq wh (getreal "\nWall height >"))
	 (setq to_del (ssadd))
	 (setvar 'cmdecho 0)
     (cond
         ((and(setq p1 (getpoint "\nSelect first point >") p2 (getpoint "\nSelect second point >")))

             (setq a (vl-sort (list (car p1)(car p2)) '<) b (vl-sort (list (cadr p1)(cadr p2)) '<))
			 (setq dx (- (cadr a)(car a)) dy (- (cadr b)(car b)))
             (cond
                 ((>= dx dy)
                     (setq p1 (list (car a) (+ (car b) (* 0.5 dy))))
                     (setq p2 (list (cadr a) (+ (car b) (* 0.5 dy))))
                     (setq ss (ssget "F" (list p1 p2) '((0 . "Line") )))
                     ;(command "_.line" p1 p2 "")
                     (setq i -1)
                     (cond
                         ((and ss)
                             (while (< (setq i (1+ i))(sslength ss))
                                 (setq eo (vlax-ename->vla-object(ssname ss i)))
                                 (setq p3 (vlax-get eo 'StartPoint))
                                 (setq p4 (vlax-get eo 'EndPoint))
                                 (setq m (inters p1 p2 p3 p4 nil))
                                 (if (and m) (setq int_pts (cons m int_pts)))
                             )
                             (setq int_pts (cons p1 int_pts))
                             (setq int_pts (cons p2 int_pts))
                             (setq int_pts (LM:Unique (vl-sort int_pts '(lambda (x y)(< (car x)(car y))))))
                             (while int_pts
                                 (setq t_lst (cons (list (car int_pts)(cadr int_pts)) t_lst))
                                 (setq int_pts (cdr int_pts))
                             )
                             (setq t_lst (reverse t_lst))
                             (while t_lst
                                 (setq seg_lst (cons (car t_lst) seg_lst))
                                 (setq t_lst (cddr t_lst))
                             )
                             (setq seg_lst (reverse seg_lst))
                             (setq L 0)
                             (while seg_lst
                                 (setq seg (car seg_lst) seg_lst (cdr seg_lst))
                                 (setq L (+ L (distance (car seg)(cadr seg))))
                                 (command "_.line" (car seg)(cadr seg) "")
								 (ssadd (entlast) to_del)
                             )
							 (setq p1 (getpoint "\nText insertion point >"))
							 (setq text (strcat (rtos dy 2 0) " luk Duvar : " (rtos (* L wh) 2 2)  " m\U+00B2"))
							 (entmake
								(list
									(cons 0 "TEXT")
									(cons 100 "AcDbText")
									(cons 10 p1)
									(cons 40 5)
									(cons 1 text)
									(cons 50 0)
									(cons 100 "AcDbText")
								)
							)
                            (princ (strcat (rtos dy 2 0) " luk Duvar : " (rtos (* L wh) 2 2)  " m2"))
							(command "_.erase" to_del "")
							(setvar 'cmdecho 0)
							(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 13 of 24

k005
Advisor
Advisor

@hak_vz 

 

beautiful. I have tested.

 

results:

1. It does not operate on vertical walls.
2. The operation result is correct
3. After writing the article should continue again. without asking the wall height...
4. If I exit the command, and re-enter it, it should ask for the wall height.

5. We must also take into account the gaps. In your solution the gaps are falling.

 

Thank you.

0 Likes
Message 14 of 24

hak_vz
Advisor
Advisor

@k005 

Ok. I'll make changes later trough the week. As I told, vertical case needs to be coded.

Please create some sample images, and attach to this post, about what you want to be added or not to add. It's pick up all the details from single sample. 

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 15 of 24

k005
Advisor
Advisor

the file is attached.

 

 

0 Likes
Message 16 of 24

hak_vz
Advisor
Advisor
Accepted solution

@k005  Test this. To exit loop hit <enter> on input p1 p2. 

To change text height look at

(cons 40 5)  ; 5 is text height

 

 

(defun c:warea (/ wh p1 p2 a b dx dy new_text *error* )
	(defun *error* ( msg )
		(if (not (member msg '("Function cancelled" "quit / exit abort")))
			(princ)
		)
	)
	(setq wh (getreal "\nWall height >"))
	(while
        (and(setq p1 (getpoint "\nSelect first point >") p2 (getpoint "\nSelect second point >")))
            (setq a (vl-sort (list (car p1)(car p2)) '<) b (vl-sort (list (cadr p1)(cadr p2)) '<))
			(setq dx (- (cadr a)(car a)) dy (- (cadr b)(car b)))
            (cond
                ((>= dx dy)
					(setq p1 (getpoint "\nText insertion point >"))
					(setq new_text (rtos (*  0.0001 dx wh) 2 2))
					(cond 
						((not (vl-string-position (ascii ".") new_text))
							(setq new_text (strcat new_text ".00"))
						)
						((= (-(strlen new_text)(vl-string-position (ascii ".") new_text)) 2)
							(setq new_text (strcat new_text "0"))
						)
					)
					(setq new_text (strcat (rtos dy 2 0) " luk Duvar : " new_text  " m\U+00B2"))
					(entmake
					(list
					(cons 0 "TEXT")
					(cons 100 "AcDbText")
					(cons 10 p1)
					(cons 40 5)
					(cons 1 new_text)
					(cons 50 0)
					(cons 100 "AcDbText")
					)
					)

					(princ (strcat (rtos dy 2 0) " luk Duvar : " new_text " m2"))
					(princ)
				)
                ((< dx dy)
					(setq p1 (getpoint "\nText insertion point >"))
					(setq new_text (rtos (*  0.0001 dy wh) 2 2))
					(cond 
						((not (vl-string-position (ascii ".") new_text))
							(setq new_text (strcat new_text ".00"))
						)
						((= (-(strlen new_text)(vl-string-position (ascii ".") new_text)) 2)
							(setq new_text (strcat new_text "0"))
						)
					)
					(setq new_text (strcat (rtos dx 2 0) " luk Duvar : " new_text  " m\U+00B2"))
					(entmake
					(list
					(cons 0 "TEXT")
					(cons 100 "AcDbText")
					(cons 10 p1)
					(cons 40 5)
					(cons 1 new_text)
					(cons 50 (* 0.5 pi))
					(cons 100 "AcDbText")
					)
					)
					(princ (strcat (rtos dx 2 0) " luk Duvar : " new_text " m2"))
					(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 17 of 24

k005
Advisor
Advisor

@hak_vz 

 

In one word, super!

 

Thank you very much, it's ok. 🤗

Message 18 of 24

Kent1Cooper
Consultant
Consultant
Accepted solution

@k005 wrote:

....

3. After writing the article should continue again. without asking the wall height...
4. If I exit the command, and re-enter it, it should ask for the wall height.

....


It seems to me this can be somewhat simpler.  Try this, which when you exit and re-enter, asks for wall height but also offers your previous wall height as the default, so you can press Enter and not type it in again:

 

(defun C:WAL ; = Wall Area Label [horizontal/vertical walls only]
  (/ pt1 pt2 delta)
  (initget (if _WALht_ 6 7)); no zero, no negative, no Enter if no prior value
  (setq _WALht_ ; global variable for default
    (cond
      ( (getdist
          (strcat
            "\nWall Height"
            (if _WALht_ (strcat " <" (rtos _WALht_) ">") ""); prior default if present
            ": "
          ); strcat
        ); getdist
      ); User-input condition
      (_WALht_); on Enter with prior value default
    ); cond
  ); setq
  (while
    (and
      (setq pt1 (getpoint "\nWall end point: "))
      (setq pt2 (getpoint "\nOther end on opposite side: "))
    ); and
    (setq delta (reverse (cdr (reverse (mapcar 'abs (mapcar '- pt2 pt1)))))); XY only
    (command "_.text"
      "_mc" "_non" (mapcar '/ (mapcar '+ pt1 pt2) '(2 2 2)); justification/ins. pt
      "" ;; <-- current Text height
      (if (> (car delta) (cadr delta)) "0" "90")
      (strcat
        (rtos (apply 'min delta) 2 0); wall thickness
        " luk duvar : "
        (rtos (/ (* _WALht_ (apply 'max delta)) 10000) 2 2); area
        " m²"
      ); strcat
    ); command
  ); while
  (princ)
); defun

 

It uses the current Text height and Style, but those can have fixed values built in, or something could be calculated based on the wall thickness.  And it puts the Text on the current Layer, but that could also be specified.

Kent Cooper, AIA
Message 19 of 24

k005
Advisor
Advisor

@Kent1Cooper 

 

@hak_vz  My friend had a solution. This was the alternative.

Endless thanks to both of you. thanks.

 

🤗🤗

0 Likes
Message 20 of 24

Sea-Haven
Mentor
Mentor

Hak_vz did you have a look at the image I posted, takes into account stacked walls ie window opening. The windows have a bottom line and a top line both with "Thickness".

 

SeaHaven_0-1627539076483.png

 

0 Likes