lisp to copy all entities to layer with a suffix

lisp to copy all entities to layer with a suffix

allanthebruce
Advocate Advocate
2,369 Views
23 Replies
Message 1 of 24

lisp to copy all entities to layer with a suffix

allanthebruce
Advocate
Advocate

Hi There, 

Wondering if its possible to duplicate all layers (that have entities and those entities) in a drawing to layers of the same name but with a suffix. e.g. _2D and then flatten all layers that have _2D in layer name?

Thanks

Al

0 Likes
2,370 Views
23 Replies
Replies (23)
Message 21 of 24

ВeekeeCZ
Consultant
Consultant

Just a simple idea... start with new drawing.

 

(vl-load-com)

(defun c:DuplicateFileFlatten ( / file)
  (if (setq file (getfiled "Select a dwg" "" "dwg" 0))
    (progn
      (command "_.INSERT" (strcat "*" file) '(0 0 0) 1 0)
      (vlax-for item (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
	(vl-catch-all-apply 'vla-put-name (list item (strcat (vla-get-name item) "_2D"))))
      (if (not acet-flatn) (load "flattensup.lsp"))
      (acet-flatn (ssget "_X") nil)
      (command "_.INSERT" (strcat "*" file) '(0 0 0) 1 0)
      ))
  (princ)
)

btw If you have C3D, CONVERT3DPOLYS command returns a better result. FLATTEN keeps flat 3d polylines, but CONVERT3DPOLYS turns then into lwpolylines.

0 Likes
Message 22 of 24

john.uhden
Mentor
Mentor
Is there a finite list of 2D layers that will be created? I mean, if we're going to create layers, they might as well be created with the desired color and linetype.

The easiest way to do that would be to insert an empty drawing but containing all the required layers (with color, etc.)

I am seriously upset (every year) that we are nearing the end of the home-grown tomato season. I've been enjoying them from our garden at least once a day since about August 1. My favorite is a tomato sandwich on very light toast with plenty of mayonnaise and some salt. Or just a salad bowl filled with tomatos and topped with ranch dressing (Hidden Valley).

John F. Uhden

0 Likes
Message 23 of 24

allanthebruce
Advocate
Advocate

Thanks for all replies!

Spring is here have some snow peas, tomatoes, beetroot and herbs going!!

Things are looking up.

Cheers

Allan

0 Likes
Message 24 of 24

john.uhden
Mentor
Mentor
Um, how about the non-veggie part of my message?

John F. Uhden

0 Likes