JJtre Posted December 3, 2010 Posted December 3, 2010 I have been working on a lisp program that will change one or multiple attributes on one or more blocks. I would however like to be able to add the current attribute values to the .dcl program, however I cannot manage to get attribute values for more than one block at a time. For example if you had two identical blocks with two separate attribute values (values not tags) and you pick both at the same time, when you open your properties window it will list the identical values (if any) and list the different values as "varies". Is there any way I can get this exact thing in autolisp? I am using vanilla lisp not visual, any help would be appreciated. Quote
BIGAL Posted December 3, 2010 Posted December 3, 2010 Start here http://www.cadtutor.net/forum/showthread.php?37127-Global-Attribute-Editor-amp-Extractor&highlight=block+edit Quote
Lee Mac Posted December 3, 2010 Posted December 3, 2010 Thanks for the plug BigAl These may also help: http://lee-mac.com/attributefunctions.html Quote
JJtre Posted December 3, 2010 Author Posted December 3, 2010 Thanks for the reply but these links work for only one block at a time (or they are visual lisp). I was kind of hoping for a way to get attribute values for several identical blocks at one time. This would allow me to tell the user if there already is a value and if there is different values for the same attribute. However I can get it to work but it ends up being about a hundred lines of text. thanks anyway Quote
Michaels Posted December 3, 2010 Posted December 3, 2010 Have you tried the command "attout" ? It's really helpful . Thanks Quote
JJtre Posted December 3, 2010 Author Posted December 3, 2010 I never knew about that command, very cool, but i don't think i can fit that into my program. I was kind of hoping for it to run internally and display it using DCL coding. ACAD already displays the info I want inside the properties window under attributes when the blocks are selected, I just need some way to pull that info out. Is there any way to get lisp to put all of the properties of selected objects into a list or string exactly the same a ACAD displays it? Quote
eyde Posted December 3, 2010 Posted December 3, 2010 Have you tried Data Extraction it will put it in a table. Quote
Michaels Posted December 3, 2010 Posted December 3, 2010 I am using the following routine which made by Mr Tharwat . ;;; This program is working almost as well as the Autocad command attout ;;; so I did this program to help people who do not have the Express tools ;;; to use my Autolisp Program instead. ;;; Hope this would help people as much as it is possible. ;;; Author *** THARWAT AL SHOUFI *** ;;; Date of creating the program November 17th. 2010 ;;; Tested with Autocad 2010 (defun c:THattout (/ Att fNme ents e) ; THARWAT Nov. 17.2010 (prompt "\n Select Attributed Block: ") (if (setq Att (ssget "_+.:S:L" '((0 . "INSERT")(66 . 1)))) (progn (setq fNme (open "D://attributes.txt" "w")) (setq ents (ssname Att 0)) (write-line (strcat "HANDLE" "\t" "BLOCKNAME" "\t" "\n" (strcat "'" (cdr (assoc 5 (entget ents)))) "\t" (cdr (assoc 2 (entget ents))) "\t") fNme ) (write-line (strcat "\n" "TAG" "\t" "VALUE") fNme ) (while (not (eq "SEQEND" (cdr (assoc 0 (setq e (entget (setq ents (entnext ents))))) ) ) ) (write-line (strcat (cdr (assoc 2 e)) "\t" (cdr (assoc 1 e))) fNme ) ) (close fNme) ) (princ "\n No Attributed Block Selected") ) (princ "\nWritten by Tharwat Al Shoufi") (princ) ) Good luck. Michaels Quote
JJtre Posted December 3, 2010 Author Posted December 3, 2010 Thanks for the help,that last one was close, but I am starting to assume that my original assumption was correct and that there is no way for vanilla lisp to display and compare attribute values from multiple blocks. Thanks for all the help, if I find anything I will defiantly post it back here. Quote
Lee Mac Posted December 4, 2010 Posted December 4, 2010 Thanks for the help,that last one was close, but I am starting to assume that my original assumption was correct and that there is no way for vanilla lisp to display and compare attribute values from multiple blocks. Thanks for all the help, if I find anything I will defiantly post it back here. Of course there is - you just have to give it more thought. The link I posted provides attribute subfunctions for a single block, but the methods utilised are applicable to any number of blocks, you just have to structure the code differently. Quote
JJtre Posted December 4, 2010 Author Posted December 4, 2010 Of course there is - you just have to give it more thought. The link I posted provides attribute subfunctions for a single block, but the methods utilised are applicable to any number of blocks, you just have to structure the code differently. OK I'll give another shot, but I have one question what does this mean/do "_+.:E:S" ? I have never seen this until I started on this task. Thanks Lee Mac for the confidence boost. Quote
Lee Mac Posted December 4, 2010 Posted December 4, 2010 what does this mean/do "_+.:E:S" ? That is a combination of ssget mode strings, a couple of which are undocumented: _ = allow for language compatibility +. = force point selection (similar to PICKAUTO=0) :E = select everything in the cursor aperture :S = forces single entity selection With regards to your task, are you looking to retrieve the values for a specific tag for all blocks in a selection? Or all values for all tags? Either could be achieved, you just need to think about how you want to structure your list output. Lee Quote
Lee Mac Posted December 4, 2010 Posted December 4, 2010 An example of retrieving multiple values, uses the same methods as demonstrated by my earlier link. A list is constructed and printed to the command line following selection, the list takes the form: ((<tag1> <value1> ... <valueN>) (<tag2> <value1> ... <valueN>) ... (<tagN> <value1> ... <valueN>)) (defun c:test ( / _assoc++ ss ) ;; Example by Lee Mac 2010 www.lee-mac.com (defun _assoc++ ( key value lst ) ( (lambda ( pair ) (if pair (subst (cons key (cons value (cdr pair))) pair lst) (cons (list key value) lst) ) ) (assoc key lst) ) ) (if (setq ss (ssget '((0 . "INSERT") (66 . 1)))) ( (lambda ( i / e el l ) (while (setq e (ssname ss (setq i (1+ i)))) (while (not (eq "SEQEND" (cdr (assoc 0 (setq el (entget (setq e (entnext e)) ) ) ) ) ) ) (setq l (_assoc++ (cdr (assoc 2 el)) (cdr (assoc 1 el)) l)) ) ) (print l) ) -1 ) ) (princ) ) Quote
JJtre Posted December 6, 2010 Author Posted December 6, 2010 Thanks, this is almost exactly what I was looking for. Thanks for your help Lee Mac. Quote
Lee Mac Posted December 6, 2010 Posted December 6, 2010 Thanks, this is almost exactly what I was looking for. Thanks for your help Lee Mac. You're welcome JJtre - I'm sure you can manipulate it to suit your needs. Next time, don't give up so easy Quote
sanalmakina Posted June 24, 2015 Posted June 24, 2015 (edited) An example of retrieving multiple values, uses the same methods as demonstrated by my earlier link. A list is constructed and printed to the command line following selection, the list takes the form: ((<tag1> <value1> ... <valueN>) (<tag2> <value1> ... <valueN>) ... (<tagN> <value1> ... <valueN>)) (defun c:test ( / _assoc++ ss ) ;; Example by Lee Mac 2010 www.lee-mac.com (defun _assoc++ ( key value lst ) ( (lambda ( pair ) (if pair (subst (cons key (cons value (cdr pair))) pair lst) (cons (list key value) lst) ) ) (assoc key lst) ) ) (if (setq ss (ssget '((0 . "INSERT") (66 . 1)))) ( (lambda ( i / e el l ) (while (setq e (ssname ss (setq i (1+ i)))) (while (not (eq "SEQEND" (cdr (assoc 0 (setq el (entget (setq e (entnext e)) ) ) ) ) ) ) (setq l (_assoc++ (cdr (assoc 2 el)) (cdr (assoc 1 el)) l)) ) ) (print l) ) -1 ) ) (princ) ) Hi, this code is useful for me too but i want to list the values to a text file with this arrangement: DN200-VA-002 DN200-VA-003 i've a schematic dwg file and i want to list the valves, stainers etc. valve attr. block name: Valve Label_block in the block it has two titles: #(TargetObject.Size) #(TargetObject.Tag) Could you help me please ? Edited June 25, 2015 by sanalmakina Quote
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.