rmjcorp Posted September 30, 2011 Share Posted September 30, 2011 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. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 30, 2011 Share Posted September 30, 2011 Would the data (text or polyline) gonna be replaced into the attribute text in a block ? Quote Link to comment Share on other sites More sharing options...
rmjcorp Posted September 30, 2011 Author Share Posted September 30, 2011 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. Quote Link to comment Share on other sites More sharing options...
irneb Posted September 30, 2011 Share Posted September 30, 2011 A few questions: Is the text always inside the polyline it refers to? Is there various other possible texts which may per chance also be there? 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. Quote Link to comment Share on other sites More sharing options...
rmjcorp Posted September 30, 2011 Author Share Posted September 30, 2011 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. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 30, 2011 Share Posted September 30, 2011 I guess you need a routine to add objects to block . If yes ? check this out ... http://lee-mac.com/addobjectstoblock.html Quote Link to comment Share on other sites More sharing options...
rmjcorp Posted September 30, 2011 Author Share Posted September 30, 2011 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. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 30, 2011 Share Posted September 30, 2011 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 Quote Link to comment Share on other sites More sharing options...
rmjcorp Posted September 30, 2011 Author Share Posted September 30, 2011 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" Quote Link to comment Share on other sites More sharing options...
Tharwat Posted October 1, 2011 Share Posted October 1, 2011 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). Quote Link to comment Share on other sites More sharing options...
rmjcorp Posted October 1, 2011 Author Share Posted October 1, 2011 Polyline for the area attribute text for the room # and employee name attributes Do the attributes need to be any special designations? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted October 1, 2011 Share Posted October 1, 2011 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) . Quote Link to comment Share on other sites More sharing options...
rmjcorp Posted October 1, 2011 Author Share Posted October 1, 2011 Here is the before and after Quote Link to comment Share on other sites More sharing options...
Tharwat Posted October 1, 2011 Share Posted October 1, 2011 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 . Quote Link to comment Share on other sites More sharing options...
rmjcorp Posted October 1, 2011 Author Share Posted October 1, 2011 Oh I think I figured it out. Basically I have to re-insert the block after I run the routine. Am I correct? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted October 1, 2011 Share Posted October 1, 2011 Oh I think I figured it out.Basically I have to re-insert the block after I run the routine. Am I correct? Of course .... Quote Link to comment Share on other sites More sharing options...
rmjcorp Posted October 1, 2011 Author Share Posted October 1, 2011 Awesome! Any way to change the order of which names get inserted where? If im pushing my luck just let me know Quote Link to comment Share on other sites More sharing options...
Tharwat Posted October 1, 2011 Share Posted October 1, 2011 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 Quote Link to comment Share on other sites More sharing options...
rmjcorp Posted October 1, 2011 Author Share Posted October 1, 2011 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? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted October 1, 2011 Share Posted October 1, 2011 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.