Macro to put objects on a certain layer.

Macro to put objects on a certain layer.

Anonymous
Not applicable
1,119 Views
7 Replies
Message 1 of 8

Macro to put objects on a certain layer.

Anonymous
Not applicable

I'm using Autocad 2013 OEM with WoodCadCam interface.

I want to make a macro that puts certain objects in a certain layer.

I can't use the command CHPROP or COPYTOLAYER.

Can anyone help me out here?

Thanks!

0 Likes
1,120 Views
7 Replies
Replies (7)
Message 2 of 8

ВeekeeCZ
Consultant
Consultant

Why not? Have you tried .CHPROP? - note the dot.

Does it have to be a macro?

 

Maybe a lisp... 

(vl-load-com)

(defun c:PutToLayer (/ layer obj ss i)

  (setq layer "MyLayer")
  
  (if (and (setq ss (ssget "_:L"))
	   (or (tblsearch "LAYER" layer)
	       (vl-cmdf "_.layer" "_n" layer ""))
	   )
    (repeat (setq i (sslength ss))
      (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
      (vla-put-layer obj layer)))
  (princ)
)
0 Likes
Message 3 of 8

dbhunia
Advisor
Advisor

Try this......

 

First make the layer current into which you want to move the selected objects.....

 

^C^C_select;\_change;p;;p;la;$m=$(getvar,clayer);;

 

Or if you enter the layer name manually then try this......By this no need to make the layer current into which you want to move the selected objects.....

 

^C^C_select;\_change;p;;p;la;

 

Why don't use Quick select to select the certain objects and put them into the selected layer (by selecting the layer from Layers tool).......


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

Anonymous
Not applicable

Hello,

Thank you, but I can't use AutoLisp, or the command change or select.

It is an oem version. That is the thing.

0 Likes
Message 5 of 8

ВeekeeCZ
Consultant
Consultant

I see. In my understanding of OEM limits, this should work. But cannot test it.

 

(defun c:PutToLayerMyLayer (/ layer ed ss i)

  (setq layer "MyLayer")
  
  (if (and (or (tblsearch "LAYER" layer)
	       (prompt (strcat "\nLayer '" layer "' was not found in the drawing.")))
	   (setq ss (ssget "_:L")))
    (repeat (setq i (sslength ss))
      (setq ed (entget (ssname ss (setq i (1- i)))))
      (entmod (subst (cons 8 layer)
		     (assoc 8 ed)
		     ed))))
  (princ)
)
0 Likes
Message 6 of 8

Anonymous
Not applicable

I can't use Lisp routines either.

0 Likes
Message 7 of 8

ВeekeeCZ
Consultant
Consultant

And are you even able to do that somehow manually right now? 

0 Likes
Message 8 of 8

Anonymous
Not applicable

Of course. I can select them with my mouse and select the concerning layer, and it works. But I need a command line command to use it in a macro.

0 Likes