Populate room name and id if is in block range. Also populate value same values form selected blocks.

Populate room name and id if is in block range. Also populate value same values form selected blocks.

robertas_suminskas2
Enthusiast Enthusiast
1,192 Views
11 Replies
Message 1 of 12

Populate room name and id if is in block range. Also populate value same values form selected blocks.

robertas_suminskas2
Enthusiast
Enthusiast

Afternoon and Happy Friday

 

Aha Another idea.

 

We have drawing from architects or consultant with room names and ID. We received a lot drawings with a lot mess as people they not interested to work more efficient  or consistent. It takes so much time to setup things.

 

Room names and ID can appear in MTEXT or TEXT. Until now we use dynamic block with attributes (see below in pictures). We draw block to each room and manually adding names. It would be helpful is possible to automacly pick up text if is block range and populate two attributes. 

 

In this situation we have MText but it would nice if is would be more flexible:

  • Chose if is MText, Text or Both
  • Able to separate  word by any symbol (or string). e.g. Laundry  - D1.
  • In some drawing are two texts (also it can MText or Text) which Above is Room Name and Below is Room ID.
  • Where is places we you have to draw more block with same room name. e.g. Some rooms have L Shape or other shapes. In this situation it would nice to populated selected blocks with same Room and ID attribute values.
 

Please example below.

 

Regards,

 

Robertas

 

0 Likes
1,193 Views
11 Replies
Replies (11)
Message 2 of 12

pbejse
Mentor
Mentor

@robertas_suminskas2 wrote:

Room names and ID can appear in MTEXT or TEXT. Until now we use dynamic block with attributes (see below in pictures). We draw block to each room and manually adding names. It would be helpful is possible to automacly pick up text if is block range and populate two attributes. 

 


Aha, another request. But it's better now that you include an actual drawing sample and pretty pictures too.

Are those MTEXT or TEXT  are on the XREF file? 

 

How does this work?

- It would be helpful is possible to automacly pick up text if is block range and populate two attributes. 

 

 

 

0 Likes
Message 3 of 12

robertas_suminskas2
Enthusiast
Enthusiast

@pbejse wrote:

@robertas_suminskas2 wrote:

Room names and ID can appear in MTEXT or TEXT. Until now we use dynamic block with attributes (see below in pictures). We draw block to each room and manually adding names. It would be helpful is possible to automacly pick up text if is block range and populate two attributes. 

 


Aha, another request. But it's better now that you include an actual drawing sample and pretty pictures too.

Are those MTEXT or TEXT  are on the XREF file? 

 

How does this work?

- It would be helpful is possible to automacly pick up text if is block range and populate two attributes. 

 

 

 


 

Q. Are those MTEXT or TEXT  are on the XREF file?

A. At the moment is MTEXT but if possible to make to work with TEXT as well for flexibility. 

A. The file is always going to be x-Ref. In this example file it was created with eTransmit (to post on this forum) which actually binding x-ref.

 

Q. - It would be helpful if is possible to automatically pick up text if is block range and populate two attributes.

A. e.g. We have block with width and height. It text falls into block zone (range, area) when block is going to read particular x-ref layer text and populate attributes. On drawing example we did all manually.

 

I think I come up with more automation. Lets say first we draw block zones for rooms. So LISP read all block and populates block attributes from x-ref text layer. I think that we need additional block attribute to link Blocks together if room shape is not square. So it can take values from linked block.

 

Thank you so much for looking into this.

 

 

0 Likes
Message 4 of 12

Moshe-A
Mentor
Mentor

@robertas_suminskas2  hi,

 

i not fully understand what is the range thing?

 

here is cpyatt function that let you pick two text objects (text or mtext) plus a block reference (one shot) than copies the text into the "area_id" & "area_name" attributes. 

 

tell me if this works for you?

 

Moshe

 

 

 

 

(defun c:cpyatt (/ ss0 ss1 ss2 elist ename text)

 (if (and
       (setq ss0 (ssget '((-4 . "<or")
                          	(0 . "mtext,text")
                                (0 . "insert") (-4 . "&") (66 . 1)
                          (-4 . "or>")
                         )
                 )
       )
       (= (sslength ss0) 3)
     )
  (progn
   (setq ss1 (ssadd) ss2 (ssadd)) 
   (foreach ename (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss0)))
    (setq elist (entget ename))

    (if (eq (cdr (assoc '0 elist)) "INSERT")
     (ssadd ename ss1)
     (ssadd ename ss2)
    )
   ); foreach
   
   (cond
    ((not (= (sslength ss1) 1))
     (vlr-beep-reaction)
     (prompt "\ninvalid number blocks selected.")
    )
    ((not (= (sslength ss2) 2))
     (vlr-beep-reaction)
     (prompt "\ninvalid number texts selected.")
    )
    ( t
     (setq ename (ssname ss1 0))

     (foreach ent (vl-remove 'listp (mapcar 'cadr (ssnamex ss2)))
      (setq text (cdr (assoc '1 (entget ent))))
      (if (member (type (read text)) (list 'INT 'REAL))
       (setpropertyvalue ename "area_id" text)
       (setpropertyvalue ename "area_name" text)
      )  
     ); foreach
     
    ); case
   ); cond
   
  ); progn
 ); if

 (princ)
)

 

 

 

 

 

0 Likes
Message 5 of 12

robertas_suminskas2
Enthusiast
Enthusiast

I just updated dwg file with some text examples and inserted architect drawing example. Thing to pay attention what not all the time room names will be as two text objects. Sometimes it can be as one MTEXT object which have room name and ID. Please see example in drawing below.

 

Thank you so much.

 

0 Likes
Message 6 of 12

robertas_suminskas2
Enthusiast
Enthusiast

Thank so much for helping.

 

I did test. For some reason it doesn't populate are ID.

 

Regards

 

Robertas

0 Likes
Message 7 of 12

pbejse
Mentor
Mentor

@robertas_suminskas2 wrote:

I just updated dwg file with some text examples and inserted architect drawing example. Thing to pay attention what not all the time room names will be as two text objects. Sometimes it can be as one MTEXT object which have room name and ID. Please see example in drawing below.

 

Thank you so much.

 


I was about to ask you where is the MTEXT on the attached second floor.dwg sample at post 1? So you're saying , for testing purposes, the file source for MTEXT is bounded, but in real case scenario, it willl remain as XREF? correct?

 

Regarding those different format shown on the attached second floor.dwg in your last post, they wont be a mixed of it on one project? or there is still a possibility that it might happen?

 

0 Likes
Message 8 of 12

pbejse
Mentor
Mentor

Use this for now , while we're trying to figure out how do this for multiple room names "automagically"

(defun c:qac (/ ent block str p)
(defun _rms (str)
  	(setq str (vl-string-right-trim " " str)
	      str (vl-string-left-trim " " str))
  )  
  (while
    (and (setq ent (Car (nentselp "\nSelect room data")))
	 (princ "\nSelect block OKT - Zones")
	 (setq block (ssget "_+.:S:E:L" '((0 . "INSERT"))))
    )
     (setq block (ssname block 0)
	   str	 (LM:UnFormat (cdr (assoc 1 (entget ent))) t)
     )
     (setq p (vl-string-position 45 str))
     (mapcar '(lambda (tg st)
		(setpropertyvalue block tg st)
	      )
	     '("AREA_ID" "AREA_NAME")
	     (list (_rms (substr str (+ 2 p))) (_rms (substr str 1 p)))
     )
  )
  (princ)
)

command: qac

Select room data
Select block OKT - Zones

 

Download the LM:UnFormat function form this link UnFormat Function 

 

 

0 Likes
Message 9 of 12

robertas_suminskas2
Enthusiast
Enthusiast

@pbejse wrote:

@robertas_suminskas2 wrote:

I just updated dwg file with some text examples and inserted architect drawing example. Thing to pay attention what not all the time room names will be as two text objects. Sometimes it can be as one MTEXT object which have room name and ID. Please see example in drawing below.

 

Thank you so much.

 


I was about to ask you where is the MTEXT on the attached second floor.dwg sample at post 1? So you're saying , for testing purposes, the file source for MTEXT is bounded, but in real case scenario, it willl remain as XREF? correct?

 

Regarding those different format shown on the attached second floor.dwg in your last post, they wont be a mixed of it on one project? or there is still a possibility that it might happen?

 


Q.  So you're saying , for testing purposes, the file source for MTEXT is bounded, but in real case scenario, it will remain as XREF? correct?

A. It will remain x-ref as we all always making external drawing x-ref.

 

Q. Regarding those different format shown on the attached second floor.dwg in your last post, they wont be a mixed of it on one project? or there is still a possibility that it might happen?

A.  There is still a possibility that it might be mixed. 

 

Thank You so much for helping.

0 Likes
Message 10 of 12

robertas_suminskas2
Enthusiast
Enthusiast

Thank you so much.

 

I tested and it worked only with example e.g. 3.

 

I Numbered examples on attached drawings for easy description. Please see below.

 

Regards,

 

Robertas

0 Likes
Message 11 of 12

pbejse
Mentor
Mentor

@robertas_suminskas2 wrote:

Thank you so much.

I tested and it worked only with example e.g. 3.

 


As I intended to be

 

1 & 2 is basically the same, 3 is easy depending on will there be a different "separator" between the name and ID, or even the other way around , but 4 and 5 is something to think about, so we end up wtih 3

  • 1 & 2
  • 3 --> Separator issue
  • 4 & 5 --> based on position

i'm thinking the user should be prompted for the format at the very start of the program.

 

pbejse_2-1614512157288.png

 

 

 

0 Likes
Message 12 of 12

robertas_suminskas2
Enthusiast
Enthusiast

@pbejse wrote:

@robertas_suminskas2 wrote:

Thank you so much.

I tested and it worked only with example e.g. 3.

 


As I intended to be

 

1 & 2 is basically the same, 3 is easy depending on will there be a different "separator" between the name and ID, or even the other way around , but 4 and 5 is something to think about, so we end up wtih 3

  • 1 & 2
  • 3 --> Separator issue
  • 4 & 5 --> based on position

i'm thinking the user should be prompted for the format at the very start of the program.

 

pbejse_2-1614512157288.png

 

 

 


Q. 3 --> Separator issue. I'm thinking the user should be prompted for the format at the very start of the program.

 

pbejse_2-1614512157288.png

 

A. Oh. This is a great idea. To addition this I am thing if we could define separator at beginning. Separator it can be even a string. In some instances they use symbols -, _ but you never in that condition you will receive drawings. Lets we have Room name Reception Room - R.09, Reception Room _ R.09, Reception Room #R.09. Instead making predefined values is possible dynamic where user is tells that it should be use. In this example at beginning I will enter values in field like "_", "-", " - ", "#". So program runs and check this values for each MTEXT. In this scenario I put 4 (one value is it have three character " - ") values but in most cases maybe I will just to enter one value. 

 

Q. 4 & 5 --> based on position. 4 and 5 is something to think about. 

A. Maybe I can propose. We know that text is always close to each other.

  1. Maybe we can measure approx. distance between next close text string and enter at the beginning of program (we take the biggest distance). If text falls into this distance range when program will know that we have to add this text. In this case we probably have think that not all texts string will be arranged from top to bottom. It maybe can be that texts string can arranged from left to right as seperate texts strings. e.g. Reception Room 04. In this example we have seperate 3 text string which is goes from left to right.
  2. Second stage join texts from 3 string or more into two strings by criteria. Criteria it would be when user will enter at the beginning of program.
  3. You already did 🙂 . Writing values into block attributes.

Thank you so much for helping.

0 Likes