NCOPY Multiple elements and convert them to cyan color

NCOPY Multiple elements and convert them to cyan color

Anonymous
Not applicable
1,114 Views
4 Replies
Message 1 of 5

NCOPY Multiple elements and convert them to cyan color

Anonymous
Not applicable

Dear Helpers,

 

I have a lisp code that can copy single element from block and convert to cyan color.

I need a small change to the code that can copy multiple elements from block.

 

(DEFUN C:CN ()
(COMMAND "NCOPY" PAUSE "" "0,0" "@" "")
(COMMAND "CHANGE" "L" "" "P" "C" "4" ""))

 

Regards,

T.Brahmanandam

0 Likes
Accepted solutions (2)
1,115 Views
4 Replies
Replies (4)
Message 2 of 5

Moshe-A
Mentor
Mentor
Accepted solution

@Anonymous hi,

 

your lisp command is very simple and apparently to make it select multiple entities is not.

first there is a need to collect the pick points in list and than to invoke ncopy and loop through these points.

when ncopy is finished, you have to collect all new entities that were added to drawing.

 

if you do not understand what I did just ask?!

note: I changed the command name.

 

discovered weird thing: ncopy turn cmdecho to on.

 

enjoy

moshe

 

 

(defun C:MCN (/ ename0 points^ pick ss)
; (command ".ncopy" pause "" "0,0" "@" "")
; (command ".change" "l" "" "p" "c" "4" "")

 (setvar "cmdecho" 0)
 (command "_.undo" "_begin")
  
 (setq ename0 (entlast)) ; store last entity name
  
 (setq points^ '()) ; reset list buffer
 (while (setq pick (entsel "\nSelect nested entity to copy: "))
  (setq points^ (append points^ (list (cadr pick))))
 )

 (if points^
  (progn
   (command "_.ncopy")   ; start ncopy command
   (foreach pt points^  ; loop throuh picked points
    (command pt)
   ); foreach
   (command "" "0,0" "") ; finish ncopy
   (setvar "cmdecho" 0)  ; turns out that ncopy set cmdecho on.
   
   ; create selection set
   (setq ss (ssadd))
   (while (setq ename0 (entnext ename0))
    (ssadd ename0 ss)
   )
   
   (command "_.chprop" "_si" ss "_color" 4 "") ; change color
  ); progn
 ); if

 (command ".undo" "_end")
 (setvar "cmdecho" 1) 
 (princ)
)

Message 3 of 5

dbhunia
Advisor
Advisor
Accepted solution

try this

 

(defun c:DEBA (/ lastent ss)
(setq lastent (entlast))
(setq ss (ssadd))
(command "_.ncopy")
(while (> (getvar "cmdactive") 0)
(command pause "0,0" "0,0")
)
(while (setq lastent (entnext lastent))
(ssadd lastent ss)
)
(command "chprop" ss "" "C" 4 "")
)

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 4 of 5

Anonymous
Not applicable

Thank you so much for your valuable reply Sir. Can you please make it to window selection?

0 Likes
Message 5 of 5

Anonymous
Not applicable

Thank you so much for your valuable reply Sir. Can you please make it to window selection?

0 Likes