Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

NCOPY Multiple elements and convert them to cyan color

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
tnvsb
928 Views, 4 Replies

NCOPY Multiple elements and convert them to cyan color

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

4 REPLIES 4
Message 2 of 5
Moshe-A
in reply to: tnvsb

@tnvsb 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
in reply to: tnvsb

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
tnvsb
in reply to: Moshe-A

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

Message 5 of 5
tnvsb
in reply to: dbhunia

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost