Jump to content

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


Ahmed Khaled

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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: 

 

  • Like 1
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
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
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...