Jump to content

Recommended Posts

Posted

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.

Posted

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

Posted

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

Posted
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

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