Jump to content

Recommended Posts

Posted

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

Posted

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

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

Posted

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

Posted

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' ?

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

Posted
(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)
   )
 )

Posted

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?

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

Posted

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)

Posted

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

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

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