C. Roberts Posted September 30 Share Posted September 30 I am trying to write something that will look inside the ROFSHT block, if it exists, for a text string that contains "ZL24". The ROFSHT block may not contain "ZL24" so it needs to check for that as well. If it does have a text string that contains "ZL24" it won't always be the same exact string. For example the full string in one drawing could be "PANELS: 24 Ga. ZL24 - GALVALUME" but in another the "GALVALUME" portion could be different. I don't know if I am going about it the correct way but I have a portion of lisp that creates a list of all text entities in the ROFSHT block if it exists. (if (setq ent (tblobjname "BLOCK" "ROFSHT")) (while (setq ent (entnext ent)) (if (= (cdr (assoc 0 (entget ent))) "TEXT") (setq textList (cons (cdr (assoc 1 (entget ent))) textList)) ) ) ) This returns a list looking like this: ("PANELS: 24 Ga. ZL24 - GALVALUME" "ROOF SHEETING PLAN" "PANELS: 24 Ga. ZL24 - GALVALUME" "ROOF SHEETING PLAN" " OUT-TO-OUT OF STEEL" "100'-0\"" "5\"" "5\"" "25'-0\"" "25'-0\"" "25'-0\"" "25'-0\"" "4" "3" "2" "5" "1" "50'-0\" OUT-TO-OUT OF STEEL" "A" "D" "1" "25'-0\"" "25'-0\"") Do I need to iterate through the list and use wcmatch with a pattern of "*ZL24*" and if the condition is T it will insert the block I tell it to? Or Do I need to add wcmatch to the code above? Or Is there a different way to achieve this? At any rate I'm lost on how to accomplish this the rest of the way. I have attached a sample drawing that has the ROFSHT block in it. Thanks RoofDwg2.dwg Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 30 Share Posted September 30 After looking at the dwg I am confused why is the ROFSHT even a block ? Why not a roof layout on its own and the label could be a 2 line attribute block. Did you copy and paste from another dwg ? When pasting don't use the paste as block option. The quickest answer is EXPLODE !! For me I would look at using a label block when doing this type of thing this way it has a name, text style, a color and a layer. Quote Link to comment Share on other sites More sharing options...
fuccaro Posted October 1 Share Posted October 1 After you get that list, you can test to see if there is a string containing "ZL24 " (foreach l1 textList (cond ((wcmatch l1 "*ZL24*") (princ (strcat l1 " OK\n"))) ) ) On the other hand, assuming that the program doesn't need textList for something else, you could test the texts as you get them, something like: (if (setq ent (tblobjname "BLOCK" "ROFSHT")) (while (setq ent (entnext ent)) (if (= (cdr (assoc 0 (setq el (entget ent)))) "TEXT") (cond ((wcmatch (setq txt1 (cdr (assoc 1 el)) "*ZL24*") (princ (strcat txt1 " OK\n"))) ) ) ) ) Quote Link to comment Share on other sites More sharing options...
fuccaro Posted October 1 Share Posted October 1 Or maybe a little bit simpler: (defun c:pp() (if (setq ent (tblobjname "BLOCK" "ROFSHT")) (while (setq ent (entnext ent)) (setq el (entget ent) a0 (cdr (assoc 0 el))) (cond ((and (= a0 "TEXT") (wcmatch (setq txt1 (cdr (assoc 1 el))) "*ZL24*")) (princ txt1)) ) ) ) (princ) ) 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.