bend Posted November 30, 2016 Posted November 30, 2016 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. Quote
BIGAL Posted November 30, 2016 Posted November 30, 2016 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 Quote
Lee Mac Posted November 30, 2016 Posted November 30, 2016 I assume you are aware of the built-in COPYTOLAYER command? Quote
bend Posted December 2, 2016 Author Posted December 2, 2016 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 Quote
Grrr Posted December 2, 2016 Posted December 2, 2016 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 Quote
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.