ahyin Posted November 22, 2011 Posted November 22, 2011 Dear All, Anyone can help me to correct my code, I want to select cirlce in two layer, I'm not understand how to use (-4 ." (setq layername (getstring "\nFirst layername ")) (setq layername1 (getstring "\nSecond layername")) (setq sset (ssget "x" (list (-4 . "<or") (cons 8 layername) (cons 8 layername1)(-4 . "or>") '(0 . "CIRCLE")(cons 410 (getvar "CTAB"))))) Quote
pBe Posted November 22, 2011 Posted November 22, 2011 (cons 8 (strcat layername "," layername1)) Quote
ahyin Posted November 22, 2011 Author Posted November 22, 2011 Thanks ! It work now. (cons 8 (strcat layername "," layername1)) Quote
pBe Posted November 22, 2011 Posted November 22, 2011 (cons 8 (strcat layername "," layername1)) You're welcome ahyin Quote
ahyin Posted November 24, 2011 Author Posted November 24, 2011 Thanks pBe, can you teach me how to modify this code, there are so many repeat code in the middle. (if (= value1 1) (setq sset (ssget "x" (list (cons 8 (vlax-get-property a 'Name)) '(0 . "CIRCLE")(cons 410 (getvar "CTAB"))))) (if (null sset) (terpri) (progn (setq old-osmode (getvar"osmode")) (setq ctr 0) (vl-cmdf "osmode" 0) (repeat (sslength sset) (setq item (ssname sset ctr)) (setq ron (vlax-ename->vla-object item)) ... ... ... ))) (if (= value2 1) (setq sset (ssget "x" (list (cons 8 (vlax-get-property b 'Name)) '(0 . "CIRCLE")(cons 410 (getvar "CTAB"))))) (if (null sset) (terpri) (progn (setq old-osmode (getvar"osmode")) (setq ctr 0) (vl-cmdf "osmode" 0) (repeat (sslength sset) (setq item (ssname sset ctr)) (setq ron (vlax-ename->vla-object item)) ... ... ... ))) (if (= value3 1) (setq sset (ssget "x" (list (cons 8 (vlax-get-property c 'Name)) '(0 . "CIRCLE")(cons 410 (getvar "CTAB"))))) (if (null sset) (terpri) (progn (setq old-osmode (getvar"osmode")) (setq ctr 0) (vl-cmdf "osmode" 0) (repeat (sslength sset) (setq item (ssname sset ctr)) (setq ron (vlax-ename->vla-object item)) ... ... ... ))) Quote
pBe Posted November 24, 2011 Posted November 24, 2011 (edited) Tell me, how do you assign values to these variables? value3 value2 value1? was it from toggle buttons? Also, what is a b c? IAcadLayer? It will be difficult to "teach" you if i'll be second guessing everytime you post a question. Edited November 24, 2011 by pBe Quote
ahyin Posted November 25, 2011 Author Posted November 25, 2011 Thanks for your reply, Yes the value is collected by toggle button. And the a,b and c is the layer name, if I selected from toggle button then it will perform the function and select from layer a, layer b or layer c. Because I have many item select from toggle buton, if I use this method, the program code repeated many times. Tell me, how do you assign values to these variables? value3value2 value1? was it from toggle buttons? Also, what is a b c? IAcadLayer? It will be difficult to "teach" you if i'll be second guessing everytime you post a question. Quote
pBe Posted November 25, 2011 Posted November 25, 2011 are you sure value1 to value is an integer and not a string? (= value1 1); Quote
ahyin Posted November 25, 2011 Author Posted November 25, 2011 Yes, it is integer because this value is returned by toggle selection box. After user selected, it return to the program, if equal to 1 then perform the following function. Thanks are you sure value1 to value is an integer and not a string?(= value1 1); Quote
pBe Posted November 25, 2011 Posted November 25, 2011 I see.... see if this works for you (if (and (Setq lst (vl-remove-if 'null (mapcar '(lambda (y m) (if (eq (eval y) 1) (vlax-get-property (eval m) 'Name) ) ) '(value1 value2 value3) '(a b c) ) ) ) (setq sset (ssget "x" (list (cons 8 (apply 'strcat (mapcar '(lambda (j) (strcat "," j)) lst ) ) ) '(0 . "CIRCLE") (cons 410 (getvar "CTAB")) ) ) ) ) (progn (setq old-osmode (getvar"osmode")) (setq ctr 0) (setvar "osmode" 0) (repeat (sslength sset) (setq item (ssname sset ctr)) (setq ron (vlax-ename->vla-object item)) ... ... ... )) ) toggle anyhoo. if the above doesnt work for you change this (eq (eval y) 1) to (eq (eval y) "1") IMO, it would be better if you use list box (like i suggested before) HTH Quote
ahyin Posted November 25, 2011 Author Posted November 25, 2011 Thanks for quick response, I will try it. And thanks for your suggestion. 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.