MikeP Posted April 26, 2010 Posted April 26, 2010 Can someone write me a lisp that would use the quick select command to find all the red circles in my selection (size does not matter) and change the color from red to green Thanks Mike Quote
MikeP Posted April 26, 2010 Author Posted April 26, 2010 Did you try QSelect?[ATTACH]19234[/ATTACH] common. yes, that is what i have been using all along. I was hoping a lisp command would make things go a little faster. Plus I can modify the lisp command to use it for things other than just red circles. Quote
alanjt Posted April 26, 2010 Posted April 26, 2010 common. yes, that is what i have been using all along. I was hoping a lisp command would make things go a little faster. Plus I can modify the lisp command to use it for things other than just red circles. Ahh, OK. This will only select select red circles (ignoring locked layers): (ssget "_:L" '((0 . "CIRCLE")(62 . 1))) Can you code the change or do you need help? Quote
MikeP Posted April 26, 2010 Author Posted April 26, 2010 Ahh, OK. This will only select select red circles (ignoring locked layers): (ssget "_:L" '((0 . "CIRCLE")(62 . 1))) Can you code the change or do you need help? Can you just provide me with a breakdown of how you got to the code you have now. (Im still trying to learn) Thanks Mike I tried it and it does not give me a error, it just does nothing "(defun c:rtg () (ssget "_:L" '((0 . "CIRCLE")(62 . 1))) (princ) )" is ^ correct? actually I just realized that is only half the code, how to get it change to green. Quote
alanjt Posted April 26, 2010 Posted April 26, 2010 Dig through this site. This will also help: ;;; VLA & DXF Info of selected Primary or Nested object ;;; Alan J. Thompson (defun c:Info (/ #Choice #Obj) (vl-load-com) (initget 0 "Nested Primary") (and (or (setq #Choice (getkword "\nNested or Primary object [Nested/<Primary>]: ")) (setq #Choice "Primary") ) ;_ or (cond ((eq #Choice "Primary") (setq #Obj (entsel "\nSelect Primary object for VLA & DXF info: ")) ) ((eq #Choice "Nested") (setq #Obj (nentsel "\nSelect Nested object for VLA & DXF info: ")) ) ) ;_ cond (not (textscr)) (princ "\nVLA Info:\n\n") (vlax-dump-object (vlax-ename->vla-object (car #Obj)) T) (princ "\nDXF Info:\n") (mapcar 'print (entget (car #Obj))) ) ;_ and (princ) ) ;_ defun Quote
MikeP Posted April 26, 2010 Author Posted April 26, 2010 Here is what I have come up with, I know im close. but far from it at the same time. (defun c:rtg () (ssget "_:L" '((0 . "CIRCLE")(62 . 1))) (command "change" "p" "color" "red") (princ) ) Quote
alanjt Posted April 26, 2010 Posted April 26, 2010 You are very close, just think about how Change works. eg. Select objects: Specify change point or [Properties]: p Enter property to change [Color/Elev/LAyer/LType/ltScale/LWeight/Thickness/Material/Annotative]: color New color [Truecolor/COlorbook] <BYLAYER>: green Enter property to change [Color/Elev/LAyer/LType/ltScale/LWeight/Thickness/Material/Annotative]: Define your selection to a variable also. Don't mess with Previous nonsense. (setq ss (ssget "_:L" '((0 . "CIRCLE")(62 . 1)))) (command "_.change" ss "" "_P"... Quote
MikeP Posted April 26, 2010 Author Posted April 26, 2010 (defun c:rtg () (setq ss (ssget "_:L" '((0 . "CIRCLE")(62 . 1)))) (command "_.change" ss "" "P" "color" "green") (princ) ) so that is what I have now, but its stopping at the "p" part and asking me to click "color". when I click "color", "3 (green)" is already entered, I just have to press enter twice to exit the command. how can I just make it go through without any prompts?? Quote
Lee Mac Posted April 26, 2010 Posted April 26, 2010 Another way: (defun c:Colr ( / i ss e ) (if (setq i -1 ss (ssget "_:L" '((0 . "CIRCLE") (62 . 1)))) (while (setq e (ssname ss (setq i (1+ i)))) (Update (PutDXF 62 3 (entget e))))) (princ)) (defun PutDXF ( code value elist ) (entmod (subst (cons code value) (assoc code elist) elist))) (defun Update ( elist ) (entupd (cdr (assoc -1 elist)))) Quote
MikeP Posted April 26, 2010 Author Posted April 26, 2010 Another way: (defun c:Colr ( / i ss e ) (if (setq i -1 ss (ssget "_X" '((0 . "CIRCLE") (62 . 1)))) (while (setq e (ssname ss (setq i (1+ i)))) (Update (PutDXF 62 3 (entget e))))) (princ)) (defun PutDXF ( code value elist ) (entmod (subst (cons code value) (assoc code elist) elist))) (defun Update ( elist ) (entupd (cdr (assoc -1 elist)))) one problem, you have no way of selecting. I cant do the entire drawing, only what i select Quote
Lee Mac Posted April 26, 2010 Posted April 26, 2010 Just change the ssget mode string. code updated. 1 Quote
alanjt Posted April 26, 2010 Posted April 26, 2010 (defun c:rtg () (setq ss (ssget "_:L" '((0 . "CIRCLE")(62 . 1)))) (command "_.change" ss "" "P" "color" "green") (princ) ) so that is what I have now, but its stopping at the "p" part and asking me to click "color". when I click "color", "3 (green)" is already entered, I just have to press enter twice to exit the command. how can I just make it go through without any prompts?? So close! You forgot the ending "". Also I added an if statement to ensure a selection was made before issuing the change command and localized your ss variable. (defun c:rtg (/ ss) (if (setq ss (ssget "_:L" '((0 . "CIRCLE") (62 . 1)))) (command "_.change" ss "" "_P" "color" "green" "") ) (princ) ) Another way: LoL While correct, you're putting the cart before the horse. Don't you think? Let him get comfortable with making selections and simple changes first.:wink: Quote
Hangman Posted April 26, 2010 Posted April 26, 2010 Lee, ... You're Awesome !! It's funny, ... when guru's such as yourself are posting code, it is automatically assume the reader knows what the code is - simply because you use it so often, you don't give it a second thought. I find myself posting without an explanation all to often, but that's because I know you guys understand it much better than myself. I find the explanation listed after the line of code help tremendously. And your help Lee is ALWAYS welcome !! Quote
stevesfr Posted April 26, 2010 Posted April 26, 2010 So close! You forgot the ending "". Also I added an if statement to ensure a selection was made before issuing the change command and localized your ss variable. (defun c:rtg (/ ss) (if (setq ss (ssget "_:L" '((0 . "CIRCLE") (62 . 1)))) (command "_.change" ss "" "_P" "color" "green" "") ) (princ) ) LoL While correct, you're putting the cart before the horse. Don't you think? Let him get comfortable with making selections and simple changes first.:wink: Doesn't seem to be foolproof here. If the circle is on a layer whose color is red, it doesn't change it to green. However, typing change etc., the same circle can be made green. WTH? Quote
alanjt Posted April 26, 2010 Posted April 26, 2010 Doesn't seem to be foolproof here. If the circle is on a layer whose color is red, it doesn't change it to green. However, typing change etc., the same circle can be made green. WTH? Because there's a big difference between a circle that's red (object level) and a circle that's on a layer that's red. The ssget filter only selects red (object level) circles to change to green. Isn't that desired result? Quote
stevesfr Posted April 26, 2010 Posted April 26, 2010 Because there's a big difference between a circle that's red (object level) and a circle that's on a layer that's red. The ssget filter only selects red (object level) circles to change to green.Isn't that desired result? Understood !!! As someone recently said, "Learn something new every day !" Thx Alan Quote
alanjt Posted April 26, 2010 Posted April 26, 2010 Understood !!!As someone recently said, "Learn something new every day !" Thx Alan Happy CAD'ing. Quote
Lee Mac Posted April 27, 2010 Posted April 27, 2010 Lee, ... You're Awesome !! It's funny, ... when guru's such as yourself are posting code, it is automatically assume the reader knows what the code is - simply because you use it so often, you don't give it a second thought. I find myself posting without an explanation all to often, but that's because I know you guys understand it much better than myself. I find the explanation listed after the line of code help tremendously. And your help Lee is ALWAYS welcome !! Thanks Hangman - I don't always get a chance to provide the explanation after each line, but glad it helps. Quote
MikeP Posted April 29, 2010 Author Posted April 29, 2010 So close! You forgot the ending "". Also I added an if statement to ensure a selection was made before issuing the change command and localized your ss variable. (defun c:rtg (/ ss) (if (setq ss (ssget "_:L" '((0 . "CIRCLE") (62 . 1)))) (command "_.change" ss "" "_P" "color" "green" "") ) (princ) ) LoL While correct, you're putting the cart before the horse. Don't you think? Let him get comfortable with making selections and simple changes first.:wink: works great thanks. now how can I change this so that it only selects objects under layer "3D_HWR" and explodes them? (defun c:hex (/ ss) (if (setq ss (ssget "_:L" '((0 . "layer") ("3D_HWR")))) (command "explode" "") ) (princ) ) ^^^^Am I close or way off?^^^^ 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.