Jump to content

Recommended Posts

Posted

Is there a quicker way to convert formatted MTEXT to ATTRIBUTES?

 

 

Room Tags from drawings exported from Revit appears as MTEXT and we need to convert it into our standard room tag attribute wherein it will follow whatever is the Format of the MTEXT to the attribute.

 

 

Example :

In MTEXT, it is in ARIAL at 500 height, it will also be the same in the attribute.

 

 

I have attached a sample file though the HEIGHT of the Text in attribute may vary.

Sample.dwg

  • Replies 37
  • Created
  • Last Reply

Top Posters In This Topic

  • rlx

    11

  • CAD_Noob

    10

  • devitg

    5

  • Tharwat

    5

Top Posters In This Topic

Posted (edited)

Hi Cad_noob, welcome to this forum,

 

 

I don't have much time because of work , both @home as here @work so I can't give a one-click-and-done for this one but maybe some else can. The way I would do this would be (Q)select all mtext and explode them , place all your blocks near the texts and then use the row-to-row function from my VT utility , its somewhere on this forum , just search for my username 'RLX'. But its still semi manual , so if somebody else has a more or fully automated routine... even better.

 

 

gr. Rlx

 

 

ps. I had one link in the back of my mind that could be modified to do the job and now I remember it :

 

 

http://www.cadtutor.net/forum/showthread.php?101120-Help-with-lisp-to-move-text-to-specific-locations-w-a-better-narrative

 

 

It can automatically see which texts belong to a group so the only thing that has to change is in stead of move the objects , put their values in a block. Maybe if you ask the author really nicely... I think its quite a brilliant routine!

Edited by rlx
Posted

Hi CAD-Noob, how do you see each group of mtex could be selected .

I guess there is a lot .

Maybe if you can show , at least , 4 to 5 area, it will help .

I think that such Mtext , all at the same Layer must be inside a polyline.

If so it can be selected from each room

 

I start doing the first defun to put the text as att

Posted

I find a problem, the Mtext are not drawn in order .

It is a list from the selection set by window.

 

("XXXX.XX m²" "ROOM NAME" "XX-XXXX" "(XXX)")

 

You can see there is no natural order , downward , neither upward

 

 

 

 

Did you made any change?

Posted
Hi CAD-Noob, how do you see each group of mtex could be selected .

I guess there is a lot .

Maybe if you can show , at least , 4 to 5 area, it will help .

I think that such Mtext , all at the same Layer must be inside a polyline.

If so it can be selected from each room

I start doing the first defun to put the text as att

Yes all can be the same layer. We just need the font style and the font height to match exactly

Currently i am using a CopyText i downloaded somewhere wherein you pick on the MTEXT then pick on the Attrib and it will match the content of the MTXEXT to the attribute but it will not match the Style and Height.

Hi Cad_noob, welcome to this forum,

 

I don't have much time because of work , both @home as here @work so I can't give a one-click-and-done for this one but maybe some else can. The way I would do this would be (Q)select all mtext and explode them , place all your blocks near the texts and then use the row-to-row function from my VT utility , its somewhere on this forum , just search for my username 'RLX'. But its still semi manual , so if somebody else has a more or fully automated routine... even better.

 

gr. Rlx

 

ps. I had one link in the back of my mind that could be modified to do the job and now I remember it :

 

http://www.cadtutor.net/forum/showthread.php?101120-Help-with-lisp-to-move-text-to-specific-locations-w-a-better-narrative

 

It can automatically see which texts belong to a group so the only thing that has to change is in stead of move the objects , put their values in a block. Maybe if you ask the author really nicely... I think its quite a brilliant routine!

Thanks for the welcome. I will check this one out and see if it will be of any help.

Posted
Hi CAD-Noob, how do you see each group of mtex could be selected .

I guess there is a lot .

Maybe if you can show , at least , 4 to 5 area, it will help .

I think that such Mtext , all at the same Layer must be inside a polyline.

If so it can be selected from each room

I start doing the first defun to put the text as att

Yes, that is how i see it. I can isolate them though.

Is it possible to window the selected MTEXT and after windowing enter the Block Name, (which i think is best if its in the Autocad support path)

Hi Cad_noob, welcome to this forum,

 

I don't have much time because of work , both @home as here @work so I can't give a one-click-and-done for this one but maybe some else can. The way I would do this would be (Q)select all mtext and explode them , place all your blocks near the texts and then use the row-to-row function from my VT utility , its somewhere on this forum , just search for my username 'RLX'. But its still semi manual , so if somebody else has a more or fully automated routine... even better.

 

gr. Rlx

 

ps. I had one link in the back of my mind that could be modified to do the job and now I remember it :

 

http://www.cadtutor.net/forum/showthread.php?101120-Help-with-lisp-to-move-text-to-specific-locations-w-a-better-narrative

Thanks for the welcome.

I will check on this and see if it helps.

 

It can automatically see which texts belong to a group so the only thing that has to change is in stead of move the objects , put their values in a block. Maybe if you ask the author really nicely... I think its quite a brilliant routine!

I find a problem, the Mtext are not drawn in order .

It is a list from the selection set by window.

("XXXX.XX m²" "ROOM NAME" "XX-XXXX" "(XXX)")

You can see there is no natural order , downward , neither upward

 

 

 

Did you made any change?

I prefer the Room, then the (xxx) then number then area if its not too much to ask.

Posted

Of course it is the way to do , but as I can see the they are not a natural order , downward, so it mus be sort as it´s Y value.

 

Again , please show me a true dwg sample , at least 4 of 4 mtext group area .

 

I think I can do it with just 2 or 3 user picks , the area-poly , one mtext, and the sample blk reference. then lisp will do all the task.

Posted

Just a quicky :

 

 

(defun c:RoomTag ( / ss tl ip bn)
 (vl-load-com)
 (princ "\n<<< Select Mtexts >>> ")
 (if (and (setq ss (ssget '((0 . "MTEXT")))) (setq ss (sss ss))
   (tblsearch "block" (setq bn "Room_Tag")))
   (progn
     (setq tl (mapcar '(lambda (x) (cdr (assoc 1 (entget x)))) ss)
    ip (cdr (assoc 10 (entget (car ss)))))
     (setvar "ATTREQ" 0)(command-s "-insert" bn ip 1 1 0)
     (mapcar '(lambda (att val) (wai bn att val)) '("RM_TAG" "RM_VENT" "RM_NO." "RM_AREA") tl)
     (mapcar 'entdel ss)
   )
 )
)

(defun sss ( %ss )
 (vl-sort
   (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
  '(lambda (x y) (> (caddr (assoc 10 (entget x))) (caddr (assoc 10 (entget y)))))
 )
)
(defun wai (b a v)
 (setq a (strcase a) b (ent->vla b))
 (vl-some '(lambda (x)(if (= a (strcase (vla-get-tagstring x)))(progn (vla-put-textstring x v) v)))
       (vlax-invoke b 'getattributes)))
(defun ent->vla ( e )
 (cond ((= (type e) 'VLA-OBJECT) e)
((= (type e) 'ENAME)(vlax-ename->vla-object e))
((and (= (type e) 'STR) (tblsearch "block" e))
 (ent->vla (ssname (ssget "x" (list (cons 0 "INSERT")(cons 2 e))) 0)))
(t nil)
 )
)

 

 

it has room for improvement , I know...

 

 

gr. RLX

Posted

I have attached a simple example plan.

 

 

I have tried rlx lisp but it's not working. but thanks for the effort.

appreciate it a lot.

SAMPLE.dwg

Posted

@RLX I'm getting this error :

 

 

 

 

Command: ROOMTAG

>>

Select objects: 1 found

Select objects: 1 found, 2 total

Select objects: 1 found, 3 total

Select objects: 1 found, 4 total

Select objects:

; error: no function definition: WAI

Posted

My bad...sorry.

I missed the WAI sub-function when I copied the code.

it's working. Only the placement is a bit off,

and the rectangle of the Room Number is left behind.

Posted
I have attached a simple example plan.

 

 

I have tried rlx lisp but it's not working. but thanks for the effort.

appreciate it a lot.

 

 

Its working for me , kinda. Routine assumes block "Room_Tag" is present in drawing. You select the mtex with a window but you have so give enter to commit selection (room for improvement) and then it inserts block Room_Tag with attributes and deletes the mtexts (but leaves the polyline behind , also room for improvement). It doesn't do the entire drawing if that's what you expected because that would need a more complex approach like used in the route I posted the link for. I could improve by first selecting two points (getpoint / getcorner) , and then use ssget with a window so I could also delete the polyline with the mtext's

 

 

gr. Rlx

Posted
My bad...sorry.

I missed the WAI sub-function when I copied the code.

it's working. Only the placement is a bit off,

and the rectangle of the Room Number is left behind.

 

 

Ok , no problem. If aligmentpoint (middle or center whatever , dxf code 11) is always present in upper mtext I can align the symbol better. Will see if I have some time later , now have to do some work for the boss...

 

 

gr. Rlx

Posted
My bad...sorry.

I missed the WAI sub-function when I copied the code.

it's working. Only the placement is a bit off,

and the rectangle of the Room Number is left behind.

 

 

this one should behave a little better :

 

 



(defun c:RoomTag ( / p1 p2 ss tl ip bn old-att-req)
 (vl-load-com)
 (setq old-att-req (getvar "ATTREQ"))
 (princ "\n<<< Select Mtexts >>> ")
 (cond
   ((not (and (setq p1 (getpoint "\nSelect 1st corner :"))
       (setq p2 (getcorner p1 "\nSelect 2nd corner :"))))
    (princ "\nNothing selected"))
   ((not (setq ss (ssget "w" p1 p2 '((0 . "MTEXT"))))) (princ "\nNo Mtext's found"))
   ((not (= (sslength ss) 4)) (princ "\nYou must select 4 Mtext's"))
   ((not (tblsearch "block" (setq bn "Room_Tag"))) (princ "\nBlock 'Room_Tag' not present"))
   (t
     (setq ss (sss ss) tl (mapcar '(lambda (x) (cdr (assoc 1 (entget x)))) ss)
    ip (cdr (assoc 10 (entget (caddr ss)))))
     (setvar "ATTREQ" 0)(command-s "-insert" bn ip 1 1 0)
     (mapcar '(lambda (att val) (wai bn att val)) '("RM_TAG" "RM_VENT" "RM_NO." "RM_AREA") tl)
     (mapcar 'entdel ss)
     (if (setq ss (ssget "w" p1 p2 '((0 . "LWPOLYLINE"))))
(progn (entdel (ssname ss 0))(setq ss nil)))
     (setvar "ATTREQ" old-att-req)
   )
 )
)


 

 

only replace main function c:RoomTag

gr. Rlx

Posted
this one should behave a little better :

 

 



(defun c:RoomTag ( / p1 p2 ss tl ip bn old-att-req)
 (vl-load-com)
 (setq old-att-req (getvar "ATTREQ"))
 (princ "\n<<< Select Mtexts >>> ")
 (cond
   ((not (and (setq p1 (getpoint "\nSelect 1st corner :"))
       (setq p2 (getcorner p1 "\nSelect 2nd corner :"))))
    (princ "\nNothing selected"))
   ((not (setq ss (ssget "w" p1 p2 '((0 . "MTEXT"))))) (princ "\nNo Mtext's found"))
   ((not (= (sslength ss) 4)) (princ "\nYou must select 4 Mtext's"))
   ((not (tblsearch "block" (setq bn "Room_Tag"))) (princ "\nBlock 'Room_Tag' not present"))
   (t
     (setq ss (sss ss) tl (mapcar '(lambda (x) (cdr (assoc 1 (entget x)))) ss)
    ip (cdr (assoc 10 (entget (caddr ss)))))
     (setvar "ATTREQ" 0)(command-s "-insert" bn ip 1 1 0)
     (mapcar '(lambda (att val) (wai bn att val)) '("RM_TAG" "RM_VENT" "RM_NO." "RM_AREA") tl)
     (mapcar 'entdel ss)
     (if (setq ss (ssget "w" p1 p2 '((0 . "LWPOLYLINE"))))
(progn (entdel (ssname ss 0))(setq ss nil)))
     (setvar "ATTREQ" old-att-req)
   )
 )
)


 

 

only replace main function c:RoomTag

gr. Rlx

 

Hi RLX I'm getting this error :

 

ROOMTAG
<<< Select Mtexts >>>
Select 1st corner :
Select 2nd corner :; error: no function definition: COMMAND-S

Posted

it's working perfectly now :)

 

I replaced the line

(setvar "ATTREQ" 0)(command-s "-insert" bn ip 1 1 0)

 

with this one

(setvar "ATTREQ" 0)(command "-insert" bn ip 1 1 0)

 

Thanks so much! I believe this will be beneficial not just to me but to others who are working both in revit and autocad.

Posted
Hi RLX I'm getting this error :

 

ROOMTAG
<<< Select Mtexts >>>
Select 1st corner :
Select 2nd corner :; error: no function definition: COMMAND-S

 

Replace command-s with:

(if command-s
 command-s
 command
)

Posted
Command: command-s

Unknown command "COMMAND-S". Press F1 for help.

 

Command-s is not supported by some acad old version

Change to

 

COMMAND

Posted
Command-s is not supported by some acad old version

 

command-s started with AutoCAD 2017 if I am not mistaken.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...