
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I have been searching through the forums, and while I am finding bits and pieces, I can't seem to find exactly what I am looking for.
Here is what I would like to do with LISP:
I have attached a small sample drawing containing a few blocks. I will typically have several instances of this block titled "A-FLOOR-CALLOUT-DOOR" in a drawing. The block contains two attributes: one titled "DOOR" and the other titled "NOTE." Each block should have a unique number for the "DOOR" attribute value, starting at 1 (I figured I would write in a safeguard in the routine just in case there were two blocks with the same "DOOR" number, so the user can exit, adjust the number, and re-run the routine). The LISP will then find the block based on the "DOOR" value, starting with number 1, and then it would take the value of its second attribute "NOTE", and turn that into a variable. The idea is that I can use that variable elsewhere in the drawings (for example, a door schedule).
I put together some code - see below. The routine counts the number of block "A-FLOOR-CALLOUT-DOOR" in the drawings, and then repeats that number to times, searching for "DOOR" 1, 2, 3, and so on. This part is working, but I am stuck on how to obtain the value of the "NOTE" attribute and turn into a variable, as noted in the code. Any help on this example would be greatly appreciated. If anyone has a different approach to achieve this, I am all ears!
Thanks!
Marty
;code start
(defun C:GatherAttributes ( )
; variables
(setq BLOCK1 "A-FLOOR-CALLOUT-DOOR")
(setq ATTTAG1 "DOOR")
(setq ATTTAG2 "NOTE")
(setq ATTVAL 0)
; set-up
(vl-load-com)
;count blocks
(setq BNAME2 (cons 2 BLOCK1))
(setq BNAME1 (ssget "x" (list BNAME2)))
(setq NUMB (sslength BNAME1))
; gather attributes
(setq *mspace* (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
)
(repeat NUMB
(setq ATTVAL (+ ATTVAL 1))
(setq ATTVAL1 (itoa ATTVAL))
(vlax-for item *mspace*
(if (and (= (vla-get-objectname item)"AcDbBlockReference") (= (strcase (vla-get-name item)) BLOCK1)
)
(mapcar '(lambda (a)
(if (and (= (vla-get-TagString a) ATTTAG1) (= (vla-get-TextString a) ATTVAL1) )
;;;;how to get the second attribute value?
)
)
(vlax-safearray->list
(variant-value
(vla-GetAttributes item)
)
)
)
)
)
);end repeat
;end
(Prompt "") (terpri)
(Prompt "---") (terpri)
(Prompt "Routine is complete!") (terpri)
(princ)
)
;code end
Solved! Go to Solution.