smweil Posted September 6, 2011 Posted September 6, 2011 Hello! Long time lurker, first time asking a question... I am trying to select all of the text objects that reside beneath a block (I need to include the block too). The block can only be identified by having the attribute tag, "ADREM." My initial plan of attack is to locate the block based on the attribute tag and extract the coordinates (I'm having an issue with this), then select all the objects using the coordinates as an anchor. Thanks for all the help you guys have provided (unknowingly) thus far on other issues as well, this site is quite the resource. Take care, Seth Quote
Lee Mac Posted September 6, 2011 Posted September 6, 2011 Would you do this for every block with attribute tag 'ADREM'? Just to clarify, the Text objects are not part of the block are they? Quote
smweil Posted September 6, 2011 Author Posted September 6, 2011 Wow, thanks for the quick reply! Yep, every block (there should be just one anyways). The text objects are not part of the block. Thanks again, Seth Quote
David Bethel Posted September 6, 2011 Posted September 6, 2011 Finding the insertion point of a BLOCK based on a single ATTRIBute tag name is very doable. It's the selection of the TEXT entities beneath that will be a problem..... Do have any more parameters to go by? -David Quote
smweil Posted September 6, 2011 Author Posted September 6, 2011 Finding the insertion point of a BLOCK based on a single ATTRIBute tag name is very doable. It's the selection of the TEXT entities beneath that will be a problem..... Do have any more parameters to go by? -David Thanks for you interest. Hmm...I'm not sure, but I can tell you more about the situation. The text is in a title block in paper space. It consists of bursted blocks, but the text itself is not unique (That's why I figured location is probably my best bet). BLOCK 1 Bursted Block 2 Bursted Block 3 I am trying to change the layer of all of this text... Quote
David Bethel Posted September 6, 2011 Posted September 6, 2011 A starting point: [b][color=BLACK]([/color][/b]defun c:in-ip [b][color=FUCHSIA]([/color][/b]/ ss en ed an ad af tn ip[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [color=#2f4f4f]"X"[/color] '[b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]0 . [color=#2f4f4f]"INSERT"[/color][b][color=BLUE])[/color][/b][b][color=BLUE]([/color][/b]66 . 1[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]while [b][color=MAROON]([/color][/b]setq en [b][color=GREEN]([/color][/b]ssname ss 0[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setq ed [b][color=GREEN]([/color][/b]entget en[b][color=GREEN])[/color][/b] an [b][color=GREEN]([/color][/b]entnext en[b][color=GREEN])[/color][/b] ad [b][color=GREEN]([/color][/b]entget an[b][color=GREEN])[/color][/b] af nil[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]while [b][color=GREEN]([/color][/b]and [b][color=BLUE]([/color][/b]not af[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]= [color=#2f4f4f]"ATTRIB"[/color] [b][color=RED]([/color][/b]cdr [b][color=PURPLE]([/color][/b]assoc 0 ad[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setq tn [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 2 ad[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]if [b][color=BLUE]([/color][/b]= tn [color=#2f4f4f]"ADREM"[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]progn [b][color=RED]([/color][/b]setq af T[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]setq ip [b][color=PURPLE]([/color][/b]cdr [b][color=TEAL]([/color][/b]assoc 10 ed[b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]redraw en 3[b][color=RED])[/color][/b] [color=#8b4513];;;HERE IS WHERE THE CHALLENGE IS[/color] [b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setq an [b][color=BLUE]([/color][/b]entnext an[b][color=BLUE])[/color][/b] ad [b][color=BLUE]([/color][/b]entget an[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]ssdel en ss[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] ip contains the insert point of the BLOCK -David Quote
smweil Posted September 6, 2011 Author Posted September 6, 2011 (edited) Fantastic. I'll go play with it and see what I can come up with. Thanks a lot! -Seth Edit: I think I made some head way with this line: (setq csel (ssget "_X" (list '(-4 . "*, It's sort of working, now I have to see how robust it is. Thanks! Edited September 6, 2011 by smweil Quote
David Bethel Posted September 6, 2011 Posted September 6, 2011 A lot of gatchas here: I would definitely add (0 . "TEXT") to your (ssget) filter TEXT group 11 is only set if the text is justified ( group 72 or 73 is present and non zero ) MTEXT is a totally different animal "*, I would look into an (-4 . " You could also add (67 . 1) as all entities are paperspace -David Quote
smweil Posted September 6, 2011 Author Posted September 6, 2011 So it's really close, there are just a few problems... I can't seem to include the original block in the selection set. I would like to change the layer of the entire selection, if that makes sense. Thanks again guys! (defun asbuiltlayer (/ ss en ed an ad af tn ip) (and (setq ss (ssget "X" '((0 . "INSERT")(66 . 1)))) (while (setq en (ssname ss 0)) (setq ed (entget en) an (entnext en) ad (entget an) af nil) (while (and (not af) (= "ATTRIB" (cdr (assoc 0 ad)))) (setq tn (cdr (assoc 2 ad))) (if (= tn "ADREM") (progn (setq af T) (setq ip (cdr (assoc 10 ed))) (setq csel (ssget "_X" (list '(-4 . ">=,<,*")(cons 11 ip) (cons 0 "text") (cons 67 1) ))) (setq ent1 (car (en))) (ssadd ent1 csel) (sssetfirst nil csel) (command "_.chprop" csel "" "_la" "ADREM_LAYER" "") )) (setq an (entnext an) ad (entget an))) (ssdel en ss))) (princ) ) Quote
David Bethel Posted September 6, 2011 Posted September 6, 2011 (ssadd en csel) or (command "_.chprop" csel en "" "_la" "ADREM_LAYER" "") -David Quote
David Bethel Posted September 6, 2011 Posted September 6, 2011 As a starting point the text filter will need as a minimum: [color=#8b4513];; Function to create a selection set of TEXT[/color] [color=#8b4513];; within a 3D fuzz distance [b][color=BLACK]([/color][/b]1.0[b][color=BLACK])[/color][/b] of given point[/color] [b][color=BLACK]([/color][/b]defun sstext [b][color=FUCHSIA]([/color][/b]ip / fuzz ss[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]setq fuzz [b][color=MAROON]([/color][/b]list 1.0 1.0 1.0[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [color=#2f4f4f]"X"[/color] [b][color=GREEN]([/color][/b]list '[b][color=BLUE]([/color][/b]0 . [color=#2f4f4f]"TEXT"[/color][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]"<OR"[/color][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]"<AND"[/color][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]">=,>=,>="[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cons 10 [b][color=RED]([/color][/b]mapcar '- ip fuzz[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]"<=,<=,<="[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cons 10 [b][color=RED]([/color][/b]mapcar '+ ip fuzz[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]"AND>"[/color][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]"<AND"[/color][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]">=,>=,>="[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cons 11 [b][color=RED]([/color][/b]mapcar '- ip fuzz[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]"<=,<=,<="[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cons 11 [b][color=RED]([/color][/b]mapcar '+ ip fuzz[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]"AND>"[/color][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]"OR>"[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] ss[b][color=BLACK])[/color][/b] It would actually need a lot more.... (sstext '(0 0 0)) would return any text that is not justified as well as any text located at '(0 0 0) -David Quote
David Bethel Posted September 6, 2011 Posted September 6, 2011 As ugly as it gets: [color=#8b4513];; Function to create a selection set of TEXT[/color] [color=#8b4513];; within a 3D fuzz distance [b][color=BLACK]([/color][/b]1.0[b][color=BLACK])[/color][/b] of given point[/color] [b][color=BLACK]([/color][/b]defun sstext [b][color=FUCHSIA]([/color][/b]ip / fuzz ss[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]setq fuzz [b][color=MAROON]([/color][/b]list 1.0 1.0 1.0[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [color=#2f4f4f]"X"[/color] [b][color=GREEN]([/color][/b]list '[b][color=BLUE]([/color][/b]0 . [color=#2f4f4f]"TEXT"[/color][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]"<OR"[/color][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]"<AND"[/color][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]72 . 0[b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]73 . 0[b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]">=,>=,>="[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cons 10 [b][color=RED]([/color][/b]mapcar '- ip fuzz[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]"<=,<=,<="[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cons 10 [b][color=RED]([/color][/b]mapcar '+ ip fuzz[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]"AND>"[/color][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]"<AND"[/color][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]"<OR"[/color][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]">"[/color][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]72 . 0[b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]">"[/color][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]73 . 0[b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]"OR>"[/color][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]">=,>=,>="[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cons 11 [b][color=RED]([/color][/b]mapcar '- ip fuzz[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]"<=,<=,<="[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cons 11 [b][color=RED]([/color][/b]mapcar '+ ip fuzz[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]"AND>"[/color][b][color=BLUE])[/color][/b] '[b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]"OR>"[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] ss[b][color=BLACK])[/color][/b] -David 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.