Jump to content

Is there a lisp to move selected objects to a desired layer but does not change their current colors?


Elektrik

Recommended Posts

So if a object is on layer 1 and its color is by ByLayer, you want it now on layer2 but with color of  layer 1 or if its not bylayer the color should just maintain anyway.

Link to comment
Share on other sites

8 hours ago, BIGAL said:

So if a object is on layer 1 and its color is by ByLayer, you want it now on layer2 but with color of  layer 1 or if its not bylayer the color should just maintain anyway.

 

Yes, a object is on layer 1 and its color is by ByLayer, I want it now on layer2 but with color of  layer 1.

Link to comment
Share on other sites

Elektrik, this VLA approach should set you in the right direction. No error trapping.

 

(defun C:LAYER-TEST ( / doc lay suf sel lyr col )

  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (setq lay (vla-get-layers doc))
  (setq suf "_1")

  (if (ssget)

    (progn

      (vlax-for	x (setq	sel (vla-get-activeselectionset doc))

	(cond

	  ((not	(tblsearch "Layer" (setq lyr (strcat (vla-get-layer x) suf))))
	   (vla-put-color
	     (vla-add lay lyr)
	     (setq col (vla-get-color (vla-item lay (vla-get-layer x))))
	   )
	   (vla-put-layer x lyr)
	  )

	  ( t

	   (if (not (= (vla-get-color (vla-item lay lyr)) col))
	     (progn
	       (vla-put-color (vla-item lay lyr) col)
	       (vla-put-layer x lyr)
	     )
	   )

	  )

	)

      )

      (vla-delete sel)

    )
  )

  (princ)
  
)

(princ)

 

  • Like 1
Link to comment
Share on other sites

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