dilan Posted May 28, 2018 Share Posted May 28, 2018 Hello. In my program, I select all the objects on the layer (setq ss (ssget "_X" (list (cons 8 (sel_obj_info "3DFACE" "\nSelect objects" nil)) '(0 . "3DFACE")))) Next, I want to assign a variable a name of the layer on which I select objects, but I can not do it. Help please... Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 28, 2018 Share Posted May 28, 2018 Hi, This is an example just to show you how to assign a variable with value. (if (and (setq pick (car (entsel "\nPick on any object :"))) (setq lay (cdr (assoc 8 (entget pick)))) ) (alert (strcat "Name of Variable : 'lay' , Layer name : " lay)) ) Quote Link to comment Share on other sites More sharing options...
dilan Posted May 28, 2018 Author Share Posted May 28, 2018 Hi, This is an example just to show you how to assign a variable with value. (if (and (setq pick (car (entsel "\nPick on any object :"))) (setq lay (cdr (assoc 8 (entget pick)))) ) (alert (strcat "Name of Variable : 'lay' , Layer name : " lay)) ) Thanks, I'll try. Quote Link to comment Share on other sites More sharing options...
dilan Posted May 28, 2018 Author Share Posted May 28, 2018 I try this way: (if (setq ss (ssget "_X" (list (cons 8 (sel_obj_tin_info "3DFACE" "\nУкажите поверхность ->>" nil)) '(0 . "3DFACE")))) (setq lay_surf (cdr (assoc 8 (entget ss)))) ) And I get an error: invalid argument type:lentityp Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 28, 2018 Share Posted May 28, 2018 My example was on single entity but your code is about a selection set so you need to iterate through each entity name to get its layer name and they might be varies. Can you post the codes of that function 'sel_obj_tin_info' ? Quote Link to comment Share on other sites More sharing options...
dilan Posted May 28, 2018 Author Share Posted May 28, 2018 My example was on single entity but your code is about a selection set so you need to iterate through each entity name to get its layer name and they might be varies. Can you post the codes of that function 'sel_obj_tin_info' ? (defun sel_obj_tin_info (etype msg lay / e el) (setvar 'errno 0) (if (setq e (car (entsel msg))) (setq el (entget e)) ) (cond ((= (getvar 'errno) 7) (princ "\nMissed.. Try again.") (sel_obj etype msg lay) ) ((not e) nil) ((not (wcmatch (strcase (cdr (assoc 0 el))) (strcase etype))) (princ (strcat "\nSelected object is not a " etype "... Try again.")) (sel_obj etype msg lay) ) ((eq (vla-get-lock (vla-item layers (cdr (assoc 8 el)))) :vlax-true) (princ "\nThe layer is locked.. Try again.") (sel_obj etype msg lay) ) ((and lay (wcmatch (strcase (cdr (assoc 8 el))) (strcase lay))) (princ "\nThe layer was previously selected.. Try again.") (sel_obj etype msg lay) ) (T e) ) ) Quote Link to comment Share on other sites More sharing options...
dilan Posted May 28, 2018 Author Share Posted May 28, 2018 (defun sel_obj_tin_info (etype msg lay / e el) (setvar 'errno 0) (if (setq e (car (entsel msg))) (setq el (entget e)) ) (cond ((= (getvar 'errno) 7) (princ "\nMissed.. Try again.") (sel_obj etype msg lay) ) ((not e) nil) ((not (wcmatch (strcase (cdr (assoc 0 el))) (strcase etype))) (princ (strcat "\nSelected object is not a " etype "... Try again.")) (sel_obj etype msg lay) ) ((eq (vla-get-lock (vla-item layers (cdr (assoc 8 el)))) :vlax-true) (princ "\nThe layer is locked.. Try again.") (sel_obj etype msg lay) ) ((and lay (wcmatch (strcase (cdr (assoc 8 el))) (strcase lay))) (princ "\nThe layer was previously selected.. Try again.") (sel_obj etype msg lay) ) (T e) ) ) in the previous message I made mistakes (defun sel_obj_tin_info (etype msg lay / e el) (setvar 'errno 0) (if (setq e (car (entsel msg))) (setq el (entget e)) ) (cond ((= (getvar 'errno) 7) (princ "\nMissed.. Try again.") (sel_obj_tin_info etype msg lay) ) ((not e) nil) ((not (wcmatch (strcase (cdr (assoc 0 el))) (strcase etype))) (princ (strcat "\nSelected object is not a " etype "... Try again.")) (sel_obj_tin_info etype msg lay) ) ((eq (vla-get-lock (vla-item layers (cdr (assoc 8 el)))) :vlax-true) (princ "\nThe layer is locked.. Try again.") (sel_obj_tin_info etype msg lay) ) ((and lay (wcmatch (strcase (cdr (assoc 8 el))) (strcase lay))) (princ "\nThe layer was previously selected.. Try again.") (sel_obj_tin_info etype msg lay) ) (T e) ) ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 28, 2018 Share Posted May 28, 2018 You don't need that function if you are after selecting objects with the same name and layer. So what exactly are you trying to accomplish? Quote Link to comment Share on other sites More sharing options...
dilan Posted May 28, 2018 Author Share Posted May 28, 2018 You don't need that function if you are after selecting objects with the same name and layer. So what exactly are you trying to accomplish? I want, after selecting objects on the layer through this function, to create a variable and assign it the name of the layer on which I selected the objects. Next, I want to use this variable (the name of the layer) to insert the name of the layer with which I'm working in .dcl. At the moment, I have only problems with creating this variable (layer name). Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 29, 2018 Share Posted May 29, 2018 If you look into the Read function it will do what you want (setq ent (entget (car (entsel "pick object"))))) (setq layname (cdr (assoc 8 ent))) (set (read layname) layname) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 29, 2018 Share Posted May 29, 2018 Hi, The following example would return nil if the selected object is on locked layer, besides that it would allow you to select 3DFACE object only so there is no need for your last posted function to go through all of these issues as long as the ssget filter could handle / take care of this. (and (princ "\nPick a 3Dface object :" ) (setq s (ssget "_+.:S:L:E" '((0 . "3DFACE")))) (setq ss (ssget "_X" (list (assoc 8 (entget (ssname s 0))) '(0 . "3DFACE")))) ) Quote Link to comment Share on other sites More sharing options...
dilan Posted May 29, 2018 Author Share Posted May 29, 2018 Hi, The following example would return nil if the selected object is on locked layer, besides that it would allow you to select 3DFACE object only so there is no need for your last posted function to go through all of these issues as long as the ssget filter could handle / take care of this. (and (princ "\nPick a 3Dface object :" ) (setq s (ssget "_+.:S:L:E" '((0 . "3DFACE")))) (setq ss (ssget "_X" (list (assoc 8 (entget (ssname s 0))) '(0 . "3DFACE")))) ) Hey. In the end, I did this way: (defun sel_obj_tin_info (etype msg lay / e el) (setvar 'errno 0) (if (setq e (car (entsel msg))) (setq el (entget e) layname (cdr (assoc 8 el))) ) (cond ((= (getvar 'errno) 7) (princ "\nMissed.. Try again.") (sel_obj_tin_info etype msg lay) ) ((not e) nil) ((not (wcmatch (strcase (cdr (assoc 0 el))) (strcase etype))) (princ (strcat "\nSelected object is not a " etype "... Try again.")) (sel_obj_tin_info etype msg lay) ) ((eq (vla-get-lock (vla-item layers (cdr (assoc 8 el)))) :vlax-true) (princ "\nThe layer is locked.. Try again.") (sel_obj_tin_info etype msg lay) ) ((and lay (wcmatch (strcase (cdr (assoc 8 el))) (strcase lay))) (princ "\nThe layer was previously selected.. Try again.") (sel_obj_tin_info etype msg lay) ) (T e) ) ) Now I have a layname variable that has a layer name. This is what I wanted. 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.