Jump to content
bend

Change Layer and Copy.

Recommended Posts

bend

Hello,

 

I'm very new to LISP and wanted a hand with writing a simple script to copy a line and change the layer to a specific layer. It going from Layer "50" to "TRAV" and I wanted this changed line copied on to of itself.

 

I have a pretty good understanding of TCL as I have written in that when using Surpac but I'm at a new job now and trying to educate myself with a few basic but useful scripts.

 

Any help will be great.

Share this post


Link to post
Share on other sites
BIGAL

There are various ways a couple of examples using lisp. Copy and paste to the command line then just type copyself.

 

(defun c:copyself ()
(setq Newlyr (getstring "Enter destination layer ")) 
(command "copy" (Entsel) "" '(0 0) '(0 0));;creates a copy on same layer
(command "-chprop" (entlast) "" "LA" NewLyr "");;changes orig to new layer
)

(defun c:copyself ()
(setq Newlyr (getstring "Enter destination layer "))
(vla-copy (vlax-ename->vla-object (car (entsel)))) ;creates a copy on same layer
(vla-put-layer (vlax-ename->vla-object  (entlast)) newlayer) ;changes copy to new layer
)

Some more help

http://www.cadtutor.net/forum/showthread.php?98213-Copy-text-into-same-place-but-in-different-layer

Share this post


Link to post
Share on other sites
Lee Mac

I assume you are aware of the built-in COPYTOLAYER command?

Share this post


Link to post
Share on other sites
bend

Hello,

 

Thanks very much for this, although I am getting the following. "Select object: Error: ActiveX Server returned an error: Parameter not optional"

 

The destination layer will always be TRAV is it possible to have this fixed?

 

B

Share this post


Link to post
Share on other sites
Grrr
Hello,

 

Thanks very much for this, although I am getting the following. "Select object: Error: ActiveX Server returned an error: Parameter not optional"

 

The destination layer will always be TRAV is it possible to have this fixed?

 

B

 

Obviously:

"You are passing a nil argument to some vla-whatever function."

 

So there was a typo:

(setq [color="red"]Newlyr [/color](getstring "Enter destination layer "))
(vla-copy (vlax-ename->vla-object (car (entsel)))) ;creates a copy on same layer
(vla-put-layer (vlax-ename->vla-object  (entlast)) [color="red"]Newlyr[/color]) ;changes copy to new layer

Share this post


Link to post
Share on other sites
bend

Thanks very much.

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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