Jump to content

Is There a Lisp to make Ncopy Command use the current layer to bring the Copied objects to it automatically


Recommended Posts

Posted

Hi, I'm asking if there Is a Lisp to make Ncopy Command use the current layer to bring the Copied objects in to it automatically 

Thanks in advance

  • Like 1
Posted (edited)

COPYTOLAYER  Didn't realize n was for nested.

 

;Nested Copy to current Layer
(defun C:NCL (/ LastEnt SS en)
  (setq LastEnt (entlast))
  (C:ncopy)
  (setq SS (ssadd))
  (if (setq en (entnext LastEnt))
    (while en
      (ssadd en SS)
      (setq en (entnext en))
    )
  )
  (setvar 'cmdecho 0)
  (command "_.Chprop" SS "" "LA" (getvar 'clayer) "")
  (setvar 'cmdecho 1)
)

 

Edited by mhupp
  • Like 1
Posted
1 hour ago, mhupp said:

COPYTOLAYER  Didn't realize n was for nested.

 

;Nested Copy to current Layer
(defun C:NCL (/ LastEnt SS en)
  (setq LastEnt (entlast))
  (C:ncopy)
  (setq SS (ssadd))
  (if (setq en (entnext LastEnt))
    (while en
      (ssadd en SS)
      (setq en (entnext en))
    )
  )
  (setvar 'cmdecho 0)
  (command "_.Chprop" SS "" "LA" (getvar 'clayer) "")
  (setvar 'cmdecho 1)
)

 

Thanks, but it return this error (; error: no function definition: C:NCOPY)

Posted

Do you have the command loaded? its an express tool command on my end in BricsCAD.

 

 

 

Posted
28 minutes ago, mhupp said:

Do you have the command loaded? its an express tool command on my end in BricsCAD.

 

 

 

Yes, Ncopy Command is Loaded and working

Posted

Would it need to be (command "ncopy") rather than (c:ncopy) if it is a normal command rather than LISP command?

 

For me after that it is saying "expects a point or settings"

  • Like 1
Posted

(C:Ncopy) works for me in bricscad so you don't have to use pauses.

Posted
15 minutes ago, tombu said:

NCOPY (Command) https://help.autodesk.com/view/ACD/2022/ENU/?guid=GUID-12FCCFDF-9B3B-48D0-AC46-DF1D3519B0E5

Many of the original Bonus or Express Tools are simply AutoCAD commands now.

Those that are still lisp are only autoloaded with the command names. To use (c:xxxxx) you would have to preload the lisp before calling it.

 

This may help: 

 

I Appreciated it but that is not what I'm looking for, this command (NCopy) get the line on the same layer as xref not my drawing current layer

Posted (edited)
5 hours ago, Ahmed Khaled said:

I Appreciated it but that is not what I'm looking for, this command (NCopy) get the line on the same layer as xref not my drawing current layer

Try

(defun c:ncl ( / ent elist clayer)
	(setq ent (entlast))
  (command "_.ncopy" "\\" "" "_non" '(0 0) "_non" '(0 0))
	(while (/= (entlast) ent)
		(setq ent (entlast) elist (entget ent) elist (entget (entlast)) elist (subst (cons 8 (getvar 'clayer))(assoc 8 elist) elist))
		(entmod elist)
		(command "_.ncopy" "\\" "" "_non" '(0 0) "_non" '(0 0))
	)
  (princ)
)

 

Edited by tombu
Updated to repeat until you press Esc key.
  • Thanks 1
Posted
39 minutes ago, tombu said:

Try

(defun c:ncl ( / elist)
  (command "_.ncopy" "\\" "" "_non" '(0 0) "_non" '(0 0))
	(setq elist (entget (entlast)) elist (subst (cons 8 (getvar 'clayer))(assoc 8 elist) elist))
	(entmod elist)
  (princ)
)

 

 

It Works Perfectly 

Thank You Very Much

Posted
1 hour ago, tombu said:

Try

(defun c:ncl ( / elist)
  (command "_.ncopy" "\\" "" "_non" '(0 0) "_non" '(0 0))
	(setq elist (entget (entlast)) elist (subst (cons 8 (getvar 'clayer))(assoc 8 elist) elist))
	(entmod elist)
  (princ)
)

 

Could you please make the command repeat itself until i press any key (like ESC) to exit it

Posted
2 hours ago, Ahmed Khaled said:

Could you please make the command repeat itself until i press any key (like ESC) to exit it

I updated the code in my post above to repeat until you press the Esc key.

  • Like 1
  • Agree 1
  • Thanks 1
Posted
2 hours ago, tombu said:

I updated the code in my post above to repeat until you press the Esc key.

 

Thanks. I couldn't have done it without you.

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