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

copy one geometry from one layer to ALL layers in the same .dwg (using a loop?)

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
paopen69
449 Views, 5 Replies

copy one geometry from one layer to ALL layers in the same .dwg (using a loop?)

Hi all!

I'm totally a newbie with lisp and i need to copy one geometry from layer (A) to about 300 layers in the same dwg. I think the best solution is to loop from layer1 to layer300 without specifying layers'names, because I've got one problem: my dwg comes from a very old acad version (I think v.12) with special characters as layers' name (i.e. "/", à, ò, spaces, and so on). Due to specifications I can't rename that layers and I'm not able to make my acad 2013 recognize layers named using "/" symbol. 

How can i do?

Thanks in advance for your kind help!

Paolo

 

Tags (1)
5 REPLIES 5
Message 2 of 6
hmsilva
in reply to: paopen69

Welcome to the Autodesk Community, paopen69

 

At the moment I have no AutoCAD with me, so, just a thought...

 

Backup your file first, the instead of the open command, try the recover command, to see if AutoCAD corrects the the layer names.
I can't see a way to copy to a layer, without specifying the layer name, maybe someone else can...

 

I can't reproduce the layer names, if possible, attach your dwg, might be easier to assist.

 

HTH
Henrique

EESignature

Message 3 of 6
paopen69
in reply to: paopen69

Thanks very much for your kind answer!
here attached is the "seed_1436.dwg".

It's the result of a merge of 1436 .dwg's layers.

On layer "0" there are the geometries to copy in all layers (424 total). They are 1arc, 1point,one 3dpoly,1poly,1closed poly, 1ellipse,1block.

 

This dwg is my seed...my schema...I will use it in Safe software FME Spatial ETL to create an ArcGIS file geodatabase (.gdb)'schema, and then copy inside (with an FME translation)1436 dwg containing (not one by one, but all together), the same layers of my seed_1436.dwg.

 

I tried to recover the draw but layers with special characters are renamed in a "strange way" (i.e. "AUDIT_I_140118183906-0").

Due to FME translation I can't rename the dwg's layers.

I know...my english is not so good and my workflow is quite complex to understand.

To summarize I've got 2 solutions:

1) copy one geometry from one layer to ALL layers in the same .dwg as I posted. maybe using a loop in lisp like "for..."

2) substitute ALL the special characters in ALL the 1436 dwg layers'name

Thanks in advance for your help!
Paolo

 

 

Message 4 of 6
hmsilva
in reply to: paopen69

Paolo,

 

if I understood correctly, perhaps something like this

Untested...

 

(defun c:C2AllLayers ( / ENT HND ITM NEWLAY NUM OBJLAY SS TBLNAME VLAOBJ)
  (vl-load-com)
  (prompt "\nSelect the objects to copy to All Layers: ")
  (if (setq ss (ssget))
    (progn
      (setq itm	0
	    num	(sslength ss)
      );; setq
      (while (< itm num)
	(setq hnd    (ssname ss itm)
	      ent    (entget hnd)
	      objlay (cdr (assoc 8 ent))
	      vlaobj (vlax-ename->vla-object hnd)
	);; setq
	(while (setq TblName (tblnext "Layer" (null TblName)))
	  (if
	    (not (wcmatch (setq newlay (cdr (assoc 2 TblName))) objlay))
	     (vla-put-layer (vla-copy vlaobj) newlay)
	  );; if
	);; while
	(setq itm (1+ itm))
      );; while
    );; progn
  );; if
  (princ)
);; C2AllLayers

 

Hope that helps

Henrique

 

EESignature

Message 5 of 6
paopen69
in reply to: paopen69

Wow! It works! And It's perfect!

Just what I was looking for!

Very good job!

Thanks very much Henrique!

 

Message 6 of 6
hmsilva
in reply to: paopen69

You're welcome, Paolo
Glad I could help

Henrique

EESignature

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

Post to forums  

Autodesk Design & Make Report

”Boost