Jump to content

Room Tag LISP Routine


rmjcorp

Recommended Posts

I would like to know if there exists a LISP Routine that will allow the user to click on data(text and a polyline) in a drawing and have it inserted into a pre made block with attributes? For example, if an architect sends me a DWG with room tags, employees names (seating), and I create a poly line for each room, and I have a block already made with those 3 attributes, can I select the data and have it inserted into the block? I would like to generate excel spread sheets with columns for the RM#, Employee seating, and SF as the end result. Thank you in advance.

Link to comment
Share on other sites

  • Replies 35
  • Created
  • Last Reply

Top Posters In This Topic

  • rmjcorp

    15

  • Tharwat

    14

  • Lee Mac

    5

  • irneb

    1

Top Posters In This Topic

Posted Images

Yes. basically it would be the text in the existing drawing. I would then insert my block into each room and take the text(from the existing drawing) and copy it into the block as a field. This way the data is linked and if changes are made to the original text, the attributes would reflect this change.

Link to comment
Share on other sites

A few questions:

 

  1. Is the text always inside the polyline it refers to?
  2. Is there various other possible texts which may per chance also be there?
  3. Is there some way to figure out which text is which, e.g. different layers?

If all = Yes then it's possible to write something where you simply have to pick the polyline. Otherwise you'd need to pick each text as well.

 

I have an old routine, but it's made specifically for our office, so it might need a lot of modification to suit your needs.

Link to comment
Share on other sites

1. Yes

2. Yes (but I can hide them during task)

3. Yes

-I can put employee names on own layer

-I can put room number tag on its own layer

-I can make the polylines on there own layer

Another note, I am not opposed to making multiple selections, however if I understand what you are suggesting is to just replace all three by selecting the polyline, which would be amazing.

Link to comment
Share on other sites

I dont think this will work for me because I am trying to add txt to attributes within a block. This way I can extract later and all 3 attributes will be represented together in the spreadsheet. For example, I could extract data that tells me "John Doe"(employee) is in room 201 that is 150sf.

Link to comment
Share on other sites

Would this help you with it .. ?

Select the texts which they are three text as you have mentioned and after that select a block which has attributes which are also three to contain texts in atts.

 

This is if I understood your needs well ... :)

(defun c:TesT (/ acdoc ss blk e n sset str)
 ;; Tharwat 30. Sep. 2011 ;;
 (vl-load-com)
 (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object)))
 (if (and
       (setq ss (ssget '((0 . "*TEXT"))))
       (setq blk (car (entsel "\n Select Attributes in Block :")))
       (eq (cdr (assoc 0 (setq e (entget blk)))) "INSERT")
     )
   (progn
     (setq n -1)
     (repeat (setq i (sslength ss))
       (setq sset (ssname ss (setq i (1- i))))
       (setq str (cons (cdr (assoc 1 (entget sset))) str))
     )
     (setq str (reverse str))
     (vlax-for x (vla-item (vla-get-blocks acdoc) (cdr (assoc 2 e)))
       (if (eq (vla-get-objectname x) "AcDbAttributeDefinition")
         (vla-put-textstring x (nth (setq n (1+ n)) str))
       )
     )
     (vla-regen acdoc AcAllViewports)
   )
   (princ)
 )
 (princ)
)

 

Tharwat

Link to comment
Share on other sites

It does not insert the selected into the block. I get this error "Select Attributes in Block :; error: ActiveX Server returned an error:

Parameter not optional"

Link to comment
Share on other sites

It does not insert the selected into the block. "

 

What is that selected ( lines , texts , polylines , ....... etc) ????

 

 

I get this error "Select Attributes in Block :; error: ActiveX Server returned an error:

Parameter not optional"

 

That's odd ,

 

the required things for the routine :

 

1- should have attributed block which should have 3 attributes in it .

2- when invoking the routine , you should select texts to be inserted in the attributed block and which is going to be replaced with the attributes (texts).

Link to comment
Share on other sites

Polyline for the area attribute

text for the room # and employee name attributes

 

Do the attributes need to be any special designations?

Link to comment
Share on other sites

Do the attributes need to be any special designations?

 

No , it is normal attributes .

 

Upload a piece of drawing shows before and after of your needs ( or an image) .

Link to comment
Share on other sites

Ok , invoke the routine and select ( for example ) text ( Alex and 253 and double-office ) and after that select the attributed block which is as I can see

in your images in office No# 254 .

 

And insert the same name of the attributed block that you have already selected to be inserted with the new texts .

Link to comment
Share on other sites

Awesome! Any way to change the order of which names get inserted where? If im pushing my luck just let me know :)

 

I really knew that you'd ask this question . :)

 

So of course yes there is a way , but you have to select each text a lone ( one by one ) . What you think ?

 

 

Tharwat

Link to comment
Share on other sites

I would rather do one by one because I will have to run an area routine for the area attribute anyways. I really wish I could just learn how to write this stuff for myself. Any suggestions on where to start on my own?

Link to comment
Share on other sites

Try this with singular selection for each text to become in order ...

 

(defun c:TesT (/ acdoc ss blk e n sset str)
 ;; Tharwat 30. Sep. 2011 ;;
 (vl-load-com)
 (setq n     -1
       acdoc (vla-get-ActiveDocument (vlax-get-acad-object))
 )
 (while
   (setq ss (ssget "_+.:S" '((0 . "*TEXT"))))
    (setq sset (ssname ss 0))
    (setq str (cons (cdr (assoc 1 (entget sset))) str))
 )
 (if
   (and str
        (setq blk (car (entsel "\n Select Attributed Block :")))
        (eq (cdr (assoc 0 (setq e (entget blk)))) "INSERT")
   )
    (progn
      (vlax-for x (vla-item (vla-get-blocks acdoc) (cdr (assoc 2 e)))
        (if (eq (vla-get-objectname x) "AcDbAttributeDefinition")
          (vla-put-textstring x (nth (setq n (1+ n)) str))
        )
      )
      (vla-regen acdoc AcAllViewports)
    )
    (princ)
 )
 (princ)
)

 

Tharwat

Link to comment
Share on other sites

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...