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

NCOPY with window selection

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
SAFizzy
2364 Views, 8 Replies

NCOPY with window selection

Hello Friends

 

i am looking for NCOPY with window selection, but can't find any solution. can some one help me by customizing through lisp rutine so i can copy objects by window selection.

 

Regards

8 REPLIES 8
Message 2 of 9
ВeekeeCZ
in reply to: SAFizzy
Message 3 of 9
ВeekeeCZ
in reply to: ВeekeeCZ

Playing with this approach, but it fails on (entnext)...

 

(defun c:CopyNestedObjects (/ enl ss sn) 
  (command "_.-REFEDIT" pause "_Ok" "_All" "_No")
  (setq enl (entlast))
  (if (setq ss (ssget "_:L"))
    (command "_.COPY" ss "" "0,0" "0,0"))
  (setq sn (somehow-select-all-new))
  (if (> (sslength sn) 0)
    (command "_.REFSET" "_R" ss ""))
  (command "_.REFCLOSE" "_Disc")
  (command-s "_.MOVE" ss "")
  (princ)
)
Message 4 of 9
Kent1Cooper
in reply to: ВeekeeCZ


@ВeekeeCZ wrote:

Playing with this approach, but it fails on (entnext)...


 

I assume it's not really necessary to remove the newly-copied  objects from the Block.  You can remove the original selection, and leave the newly-copied ones as part of the Block.  Does this work [untested]?

(defun C:NCopyM (/ ss) ; = NCOPY Multiple objects
  (command "_.-REFEDIT" pause "_Ok" "_All" "_No")
  (if (setq ss (ssget "_:L"))
    (command
      "_.COPY" ss "" "0,0" "0,0"
      "_.REFSET" "_R" ss ""
    ); command
  ); if
  (command "_.REFCLOSE" "_Disc")
  (command-s "_.MOVE" ss "")
  (princ)
)
Kent Cooper, AIA
Message 5 of 9
ВeekeeCZ
in reply to: Kent1Cooper


@Kent1Cooper wrote:

@ВeekeeCZ wrote:

Playing with this approach, but it fails on (entnext)...


 

I assume it's not really necessary to remove the newly-copied  objects from the Block.  You can remove the original selection, and leave the newly-copied ones as part of the Block.  Does this work [untested]?

(defun C:NCopyM (/ ss) ; = NCOPY Multiple objects
  (command "_.-REFEDIT" pause "_Ok" "_All" "_No")
  (if (setq ss (ssget "_:L"))
    (command
      "_.COPY" ss "" "0,0" "0,0"
      "_.REFSET" "_R" ss ""
    ); command
  ); if
  (command "_.REFCLOSE" "_SAVE") 
  (command-s "_.MOVE" ss "")
  (princ)
)

 

It isn't unless you actually save the changes to the original. That I didn't want to do...

But maybe @SAFizzy  wouldn't mind... 

Message 6 of 9
ВeekeeCZ
in reply to: ВeekeeCZ

Seems that a vla-copy method does a better job.

 

(vl-load-com)

(defun c:CopyNestedObjects (/ ss sn doc obj objnew)
  
  (command "_.-REFEDIT" pause "_Ok" "_All" "_No")

  (if (and (setq ss (ssget "_:L"))
	   (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
	   (setq sn (ssadd))
	   )	 
    (repeat (setq i (sslength ss))
      (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
      (if (setq objnew (vla-Copy obj))
	(ssadd (vlax-vla-object->ename objnew) sn))))
  
  (if (> (sslength sn) 0)
    (command "_.REFSET" "_R" sn ""))
  (command "_.REFCLOSE" "_Disc")
  (command-s "_.MOVE" sn "")
  (princ)
)
 
Message 7 of 9
SAFizzy
in reply to: ВeekeeCZ

@ВeekeeCZ thanks for help. 

that's what i am looking for, only if we can skip pause and confirmation in middle so that command work directly like copy, it will be perfect.

 

Thanks

Message 8 of 9
braudpat
in reply to: ВeekeeCZ

Hello @ВeekeeCZ 

 

1) Thanks for your routine ! So Kudos for you ...

 

2) But I have a small defect : the routine seems to run ONLY ONCE !

I can't re-run the routine on the XREF to extract again entities from an other area !?

 

Thanks, Regards, Patrice (The Old French EE Froggy)

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 9 of 9
ВeekeeCZ
in reply to: braudpat

Hm... well, I would not expect much from it. It was just kinda 'proof of concept', I did not test it much. And the 'refedit' is not really 'custom-friendly' command.

Anyway, it seems to me to be working quite fain (2020). I am able to repeat the command, no confirmation receiving... a yes, there would be still the need to select an insert which from you copy objects. At least for the first time. 

 

If you give me more information - possibly a test file, command-line listing, or screen capture... I could look into that.

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

Post to forums  

Forma Design Contest


AutoCAD Beta