Jump to content

Recommended Posts

Posted

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")))))

Posted

Thanks ! It work now.

 

 
(cons 8 (strcat layername "," layername1))

Posted
 
(cons 8 (strcat layername "," layername1))

 

You're welcome ahyin :)

Posted

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))
    ...
    ...
    ...
    ))) 

Posted (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 by pBe
Posted

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? 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. :)

Posted

are you sure value1 to value is an integer and not a string?

(= value1 1);

Posted

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);

Posted

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) :D

 

HTH

Posted

Thanks for quick response, I will try it. And thanks for your suggestion.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...