Jump to content

Recommended Posts

Posted

Hello everybody,

Can anyone help me my requirement, 

I want text copy from "layer1" to "layer2" 

requesting for code

With regards.

BKRao

Posted (edited)

1   You can manually type lisp code on the command line so you can use ssget to make a selection, and then use Copy etc. (ssget '((0 . "Text")))

 

2   The Filter command is the same just select text then it detects the selection made.

 

3   Qselect ?

 

4  You can make a shorthand using the ssget mentioned aboved so Copy 'ssgt the 'ssgt is a shorthand command that is tranparently called, its a preloaded  lisp you could have a few of these for pre defined selections. The use of transparent commands is one of those hidden options in Autocad.

 

Some examples at command line type

copy 'ssgt <Enter> pick pick text is copied.

Chprop 'ssgt "" la newlayer

Note the apostrophe ' before the command this makes it transparent.

 


(defun c:ssgp ()
(ssget '((0 . "LWPOLYLINE")))
)

(defun c:ssgt ()
(ssget '((0 . "Text")))
)

(defun c:ssgm()
(ssget '((0 . "MText")))
)

(defun c:ssgl ()
(ssget '((0 . "LINE")))
)

(defun c:ssmt ()
(ssget '((0 . "*text")))
)
; 
(defun c:ssct ( / ss)
(setq ss (ssget '((0 . "*Text"))))
(command "chprop" ss "" "la" (getstring "new layer") "")
)

 

 

Edited by BIGAL
  • Thanks 1
Posted (edited)
22 hours ago, Aftertouch said:

Copy or move?

copy not move Sir

Edited by BKRao
Posted (edited)

Thank U "BIGAL" Sir

 

I am traying with below code kindly correct it Sir.

 

(defun c:ssct (/ ss sel)

(setq ss (ssget '((0 . "*Text"))))

(command "copy" ss  "" "" "")
    (setq sel (vlax-ename->vla-object (entlast)))
    (vlax-put-property sel 'layer "layer2")
  )

 

Edited by BKRao
Posted (edited)
On 05/04/2019 at 13:19, BKRao said:

Thank U "BIGAL" Sir

 

I am traying with below code kindly correct it Sir.

 

(defun c:ssct (/ ss sel)

(setq ss (ssget '((0 . "*Text"))))

(command "copy" ss  "" "" "")
    (setq sel (vlax-ename->vla-object (entlast)))
    (vlax-put-property sel 'layer "layer2")
  ) 

 

 

You need to loop through the selection set

 

You can either

 

(defun c:ssct (/ ss cnt obj n_obj)

  (setq ss (ssget '((0 . "*Text") (8 . "layer1"))))

  (repeat (setq cnt (sslength ss))
    (setq obj (vlax-ename->vla-object (ssname ss (setq cnt (1- cnt))))
          n_obj (vla-copy obj)
    )      
    (vlax-put-property n_obj 'layer "layer2")
  )
) 

 

or

 

(defun c:ssct (/ ss cnt sel)

  (setq c_doc (vla-get-activedocument (vlax-get-acad-object))
        ss (ssget '((0 . "*Text") (8 . "layer1")))
  )

  (vlax-for obj (vla-get-activeselectionset c_doc)
    (setq n_obj (vla-copy obj))      
    (vlax-put-property n_obj 'layer "layer2")
  )
)

 

The text will exactly overwrite the existing text so you will have two text items at each location. Did you by change mean to copy and move?

Edited by dlanorh
corrected code
  • Thanks 1
Posted

Copy and move

 


(defun c:ssct (/ ss  pt1 pt2 layer2)

(setq layer2 (getstring "\nEnter layer name"))
(setq ss (ssget '((0 . "*Text"))))
 (setq pt1 (getpoint "\npick start point "))
(setq pt2 (getpoint  pt1 "\npick end point"))
(repeat (setq x (sslength ss))
(command  "copy" (ssname ss (setq x (- x 1))) ""  pt1 pt2)
(command "chprop" (entlast) "" "la" Layer2 "" )
)
)

  • Thanks 1
Posted

Is this not the same as "copytolayer" command?

Posted

 

Quote

Thanking U everyone above program sufficient for my requirement. BKRao 

 

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