Doors and Windows Text m²

Doors and Windows Text m²

k005
Advisor Advisor
1,144 Views
18 Replies
Message 1 of 19

Doors and Windows Text m²

k005
Advisor
Advisor

Hello guys

How can I print the areas of doors and windows like in the example?
when I print it should be in the KAPI-PENCERE-MNH layer. If the layer does not exist, it should be created. Color index=30

0 Likes
Accepted solutions (3)
1,145 Views
18 Replies
Replies (18)
Message 2 of 19

hosneyalaa
Advisor
Advisor

HI

USING  entmake

 

(entmake (list (cons 0 "TEXT") ;***
               (cons 1 "1.89 M2") ;***
               (cons 8 "KAPI-PENCERE-MNH");;LAYER
               (cons 10 (list 0.0 0.0 0.0)) ;POINT
               (cons 39 0.0)
               (cons 40 1.0) ;***
               (cons 41 1.0)
               (cons 50 0.0)
               (cons 51 0.0)
               (cons 62 30);;;COLOR
               (cons 71 0)
               (cons 72 0)
               (cons 73 0)
               (cons 210 (list 0.0 0.0 1.0))))

 

0 Likes
Message 3 of 19

k005
Advisor
Advisor

how ?
sample?

0 Likes
Message 4 of 19

hosneyalaa
Advisor
Advisor

my language is not good
I can't explain clearly

 

USING

 

(setq eName (ENTGET(car (nentsel "\nSelect TEXT " ))))

 

 

 

((-1 . <Entity name: 32df5860>) (0 . "TEXT") (330 . <Entity name: 32df6f00>) (5 . "7E") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "KAPI-PENCERE-MNH") (370 . 0) (100 . "AcDbText") (10 284.483 254.207 0.0) (40 . 12.9019) (1 . "1.89 m²") (50 . 0.0) (41 . 1.0) (51 . 0.0) (7 . "WMF-Arial0") (71 . 0) (72 . 0) (11 0.0 0.0 0.0) (210 0.0 0.0 1.0) (100 . "AcDbText") (73 . 0))

 

 

 

AND READING

 

https://help.autodesk.com/view/OARX/2022/ENU/?guid=GUID-62E5383D-8A14-47B4-BFC4-35824CAE8363

0 Likes
Message 5 of 19

k005
Advisor
Advisor

Thank You, It takes practice.

0 Likes
Message 6 of 19

CADaSchtroumpf
Advisor
Advisor
Accepted solution

With your drawing can be automaticly written, but we can also write the code for select manualy and write the result.

(defun c:test ( / js_l js_t nl dxf_ent pt10 pt11 sel_t l_val ind dlt ang)
  (if (null (tblsearch "STYLE" "WMF-Arial0"))
    (entmake
      '(
        (0 . "STYLE")
        (100 . "AcDbSymbolTableRecord")
        (100 . "AcDbTextStyleTableRecord")
        (2 . "WMF-Arial0")
        (70 . 0)
        (40 . 0.0)
        (41 . 1.0)
        (50 . 0.0)
        (71 . 0)
        (42 . 0.2)
        (3 . "arial.ttf")
        (4 . "")
      )
    )
  )
  (if (null (tblsearch "LAYER" "KAPI-PENCERE-MNH"))
    (entmake
      '(
        (0 . "LAYER")
        (100 . "AcDbSymbolTableRecord")
        (100 . "AcDbLayerTableRecord")
        (2 . "KAPI-PENCERE-MNH")
        (70 . 0)
        (62 . 30)
        (6 . "Continuous")
        (290 . 1)
        (370 . -3)
      )
    )
  )
  (command "_.zoom" "_all")
  (setq js_l (ssget "_X" '((0 . "LINE") (67 . 0) (8 . "0") (62 . 16) (370 . 0) (210 0.0 0.0 1.0))))
  (cond
    (js_l
      (setq js_t (ssadd))
      (repeat (setq nl (sslength js_l))
        (setq
          dxf_ent (entget (ssname js_l (setq nl (1- nl))))
          pt10 (cdr (assoc 10 dxf_ent))
          pt11 (cdr (assoc 11 dxf_ent))
        )
        (foreach pt (list pt10 pt11)
          (setq
            sel_t (ssget "_C" (mapcar '- pt '(20.0 20.0 0.0)) (mapcar '+ pt '(20.0 20.0 0.0)) '((0 . "TEXT") (67 . 0) (410 . "Model") (8 . "0") (62 . 16) (370 . 0) (210 0.0 0.0 1.0)))
          )
          (cond
            (sel_t
              (setq l_val nil)
              (repeat (setq n (sslength sel_t))
                (setq ind (cdr (assoc 1 (entget (ssname sel_t (setq n (1- n)))))))
                (if (eq (type (read ind)) 'INT)
                  (setq l_val (cons (atoi ind) l_val))
                )
              )
              (if l_val
                (progn
                  (if (zerop (rem (angle pt10 pt11) pi))
                    (setq dlt '(-37.2328 -4.8140 0.0) ang 0.0)
                    (setq dlt '(6.0670 -5.0771 0.0) ang (* 0.5 pi))
                  )
                  (entmake
                    (list
                      '(0 . "TEXT")
                      '(100 . "AcDbEntity")
                      '(67 . 0)
                      '(410 . "Model")
                      '(8 . "KAPI-PENCERE-MNH")
                      '(370 . 0)
                      '(100 . "AcDbText")
                      (cons 10 (mapcar '+ pt dlt))
                      '(40 . 12.9019)
                      (cons 1 (strcat (rtos (apply '* (cons 0.0001 l_val)) 2 2) " m²"))
                      (cons 50 ang)
                      '(41 . 1.0)
                      '(51 . 0.0)
                      '(7 . "WMF-Arial0")
                      '(71 . 0)
                      '(72 . 0)
                      '(11 0.0 0.0 0.0)
                      '(210 0.0 0.0 1.0)
                      '(100 . "AcDbText")
                      '(73 . 0)
                    )
                  )
                )
              )
            )
            (T (setq l_val nil))
          )
        )
      )
    )
  )
  (prin1)
)
Message 7 of 19

k005
Advisor
Advisor

Super. !

Can we specify the area with the window selection?

0 Likes
Message 8 of 19

CADaSchtroumpf
Advisor
Advisor

Try removing "_X" at the expression (setq js_l (ssget "_X" '(( 0 . "LINE") ..........

Message 9 of 19

k005
Advisor
Advisor

OK, I did it.

 

 

There is only one situation;

You print the result according to circle and line as far as I understand..,, We should change this. Because there is not always a line and a circle.

for this reason, for example, can we print the result near 90 or 210?

0 Likes
Message 10 of 19

CADaSchtroumpf
Advisor
Advisor
Accepted solution

New version

(defun c:test ( / js l_ent n ent dxf_ent pt ang l_ent sel_t e1 e2 l_val dlt)
  (if (null (tblsearch "STYLE" "WMF-Arial0"))
    (entmake
      '(
        (0 . "STYLE")
        (100 . "AcDbSymbolTableRecord")
        (100 . "AcDbTextStyleTableRecord")
        (2 . "WMF-Arial0")
        (70 . 0)
        (40 . 0.0)
        (41 . 1.0)
        (50 . 0.0)
        (71 . 0)
        (42 . 0.2)
        (3 . "arial.ttf")
        (4 . "")
      )
    )
  )
  (if (null (tblsearch "LAYER" "KAPI-PENCERE-MNH"))
    (entmake
      '(
        (0 . "LAYER")
        (100 . "AcDbSymbolTableRecord")
        (100 . "AcDbLayerTableRecord")
        (2 . "KAPI-PENCERE-MNH")
        (70 . 0)
        (62 . 30)
        (6 . "Continuous")
        (290 . 1)
        (370 . -3)
      )
    )
  )
  (princ "\nSelect all texts (by window or crossing).")
  (setq js (ssget '((0 . "TEXT") (67 . 0) (410 . "Model") (8 . "0") (62 . 16) (370 . 0) (210 0.0 0.0 1.0))))
  (cond
    (js
      (repeat (setq n (sslength js))
        (setq
          ent (ssname js (setq n (1- n)))
          dxf_ent (entget ent)
          pt (cdr (assoc 10 dxf_ent))
          ang (cdr (assoc 50 dxf_ent))
          l_ent (cons ent l_ent)
          sel_t (ssget "_C" (mapcar '- pt '(25.0 25.0 0.0)) (mapcar '+ pt '(25.0 25.0 0.0)) '((0 . "TEXT") (67 . 0) (410 . "Model") (8 . "0") (62 . 16) (370 . 0) (210 0.0 0.0 1.0)))
        )
        (cond
          ((and sel_t (= (sslength sel_t) 2))
            (setq e1 (ssname sel_t 0) e2 (ssname sel_t 1))
            (if (or (not (member e1 l_ent)) (not (member e2 l_ent)))
              (setq
                l_val (cons (atoi (cdr (assoc 1 (entget e1)))) (atoi (cdr (assoc 1 (entget e2)))))
                pt (mapcar '* (mapcar '+ (cdr (assoc 10 (entget e1))) (cdr (assoc 10 (entget e2)))) '(0.5 0.5 0.5))
              )
              (setq l_val nil)
            )
            (if l_val
              (progn
                (if (zerop ang)
                  (setq dlt '(-37.2328 -4.8140 0.0) ang 0.0)
                  (setq dlt '(6.0670 -5.0771 0.0) ang (* 0.5 pi))
                )
                (entmake
                  (list
                    '(0 . "TEXT")
                    '(100 . "AcDbEntity")
                    '(67 . 0)
                    '(410 . "Model")
                    '(8 . "KAPI-PENCERE-MNH")
                    '(370 . 0)
                    '(100 . "AcDbText")
                    (cons 10 pt)
                    '(40 . 12.9019)
                    (cons 1 (strcat (rtos (apply '* (list 0.0001 (car l_val) (cdr l_val))) 2 2) " m²"))
                    (cons 50 ang)
                    '(41 . 1.0)
                    '(51 . 0.0)
                    '(7 . "WMF-Arial0")
                    '(71 . 0)
                    '(72 . 0)
                    '(11 0.0 0.0 0.0)
                    '(210 0.0 0.0 1.0)
                    '(100 . "AcDbText")
                    '(73 . 0)
                  )
                )
              )
            )
          )
        )
      )
    )
  )
  (prin1)
)
Message 11 of 19

k005
Advisor
Advisor

Thank you very much. It's ok. 🤗

0 Likes
Message 12 of 19

k005
Advisor
Advisor

 

 

Hi

 

In some cases, even though I select my texts, the field does not perform the calculation. Where does this come from.. I've looked through the code a lot but couldn't find it.

0 Likes
Message 13 of 19

CADaSchtroumpf
Advisor
Advisor

@k005  a écrit :

Hi

 

In some cases, even though I select my texts, the field does not perform the calculation. Where does this come from.. I've looked through the code a lot but couldn't find it.


It would be necessary to see if the filtered selection of texts is appropriate.
In the given code this concerns layer "0" (8 . "0") and color 16 (62 . 16) for selection js and sel_t : For layer you can use (8 . "0,*OtherLayer") "OtherLayer" must be exist  😏
Adjust these or simply remove them.

It is also possible that for the selection sel_t the "Crossing" ("_C") mode is too weak if the texts are far from each other. In the code I had put (25.0 25.0 0.0) units, increase this to a reasonable value.

The more precise the filters, the more reliable the function will be.

Message 14 of 19

k005
Advisor
Advisor

ok problem - rather i found the point where i was stuck... i changed your code a bit 😃

 

Thankyou.

0 Likes
Message 15 of 19

k005
Advisor
Advisor

@CADaSchtroumpf 

 

Hi

(25.0 25.0 0.0)) --> if we read the 25s in this section from a key from the Registry ..? how can we do this?

 

* I will enter the value from another program.

0 Likes
Message 16 of 19

CADaSchtroumpf
Advisor
Advisor
Accepted solution

@k005  a écrit :

@CADaSchtroumpf 

 

Hi

(25.0 25.0 0.0)) --> if we read the 25s in this section from a key from the Registry ..? how can we do this?

 

* I will enter the value from another program.


@k005 

Hi,

Use (vl-registry-read ....)

For exemple if use in command line (vl-registry-write "HKEY_CURRENT_USER\\Test" "" "25") for you is write by your external program.

 

For this I insert the line: adapt to your key registry (here test is a string)

 

(setq dlt (vl-registry-read "HKEY_CURRENT_USER\\Test") dlt (list (atof dlt) (atof dlt) 0.0))

 

before line 41

(repeat (setq n (sslength js))

and change

 

sel_t (ssget "_C" (mapcar '- pt '(25.0 25.0 0.0)) (mapcar '+ pt '(25.0 25.0 0.0)) '((0 . "TEXT") (67 . 0) (410 . "Model") (8 . "0") (62 . 16) (370 . 0) (210 0.0 0.0 1.0)))

 

by

 

sel_t (ssget "_C" (mapcar '- pt dlt) (mapcar '+ pt dlt) '((0 . "TEXT") (67 . 0) (410 . "Model") (8 . "0") (62 . 16) (370 . 0) (210 0.0 0.0 1.0)))

 

 

Message 17 of 19

k005
Advisor
Advisor

@CADaSchtroumpf 

 

Understood. I'll try it as soon as possible and report back.

* I am very busy at the moment.

 

0 Likes
Message 18 of 19

k005
Advisor
Advisor

@CADaSchtroumpf 

 

I changed the codes as you said. It read the value from the registry. It did the operation. But it only processed 1 text. selected them all, but only changed 1 text. where did we go wrong

 

*************************

 

Ok I found it, I wrote it on the wrong line.

No problem, it's working. Thank you so much.

 

 

0 Likes
Message 19 of 19

CADaSchtroumpf
Advisor
Advisor

@k005  a écrit :

@CADaSchtroumpf 

 

Ok I found it, I wrote it on the wrong line.

No problem, it's working. Thank you so much.

 

 


@k005 

However, I saw a problem.
In the code I published I see the lines: just before creating the TEXT with (entmake)

 

                (if (zerop ang)
                  (setq dlt '(-37.2328 -4.8140 0.0) ang 0.0)
                  (setq dlt '(6.0670 -5.0771 0.0) ang (* 0.5 pi))
                )

 

I don't remember why I had set a "dlt" variable here, but that might overwrite the value of "dlt" read from the registry...
So replacing with this condition would be better...

 

                (if (zerop ang)
                  (setq ang 0.0)
                  (setq ang (* 0.5 pi))
                )

 

0 Likes