I want to move all objects from one layer to another.
How do I go about that?
Solved! Go to Solution.
Solved by 3wood. Go to Solution.
@Anonymous wrote:
I want to move all objects from one layer to another.
How do I go about that?
One simple way [among many possibilities]:
(command
"_.chprop"
(ssget "_X" (list (cons 8 "YourSourceLayerName"))); find everything on the Layer
"" ; complete selection
"_layer"
"YourTargetLayerName"
"" ; end Chprop command
); command
That assumes the source Layer is not locked. And it does only things in the current space, but if you want things in all spaces [Model and all Paper-space Layouts], that is also possible.
If you don't need it automated, QSELECT and the Properties box will do the same for you with no routine, and hardly any more effort on the User's part.
Or, if you want to completely remove the source Layer from the drawing, use LAYMRG.
Hi, could you translate this code to vba please? Thanks in advance. I hope you could.
@Anonymous wrote:
Hi, could you translate this code to vba please? ....
I can't. Maybe someone who knows VBA will see this and pitch in.
Hi,
>> could you translate this code to vba please
Here it is, without testing and without warrenty 😉
Const FromLayer As String = "Layer1" 'layer from which the entities have to be selected Const DestLayer As String = "Layer2" 'new/destination layer for that entities Const pSelSetName As String = "mySelSet" Public Sub chLay() Dim tCounter As Integer Dim tSelSet As AcadSelectionSet Dim tDxfCodes(0) As Integer Dim tDxfValues(0) As Variant 'create SelectionSet On Error Resume Next Set tSelSet = ThisDrawing.SelectionSets.Item(pSelSetName) If (Not (tSelSet Is Nothing)) Then tSelSet.Clear Else Err.Clear Set tSelSet = ThisDrawing.SelectionSets.Add(pSelSetName) End If 'create selection filter tDxfCodes(0) = 8 tDxfValues(0) = FromLayer 'create selection Call tSelSet.Select(acSelectionSetAll, , , tDxfCodes, tDxfValues) If (Err.Number = 0) And (tSelSet.Count > 0) Then 'Create Layer, just make sure it exists Dim tLayer As AcadLayer Set tLayer = ThisDrawing.Layers.Add(DestLayer) 'now go through the selectionset and change the layer of the objects Dim tEnt As AcadEntity For Each tEnt In tSelSet tEnt.Layer = DestLayer tCounter = tCounter + 1 Next Call MsgBox("Entities modified: " & CStr(tCounter)) Else Call MsgBox("Error selecting objects." & vbCrLf & Err.Description) End If End Sub
- alfred -
@bobbyrubyii wrote:How can I select things in all places?
Thaw and unlock all layers then hit Ctrl+A.
@Anonymous wrote:I want to move all objects from one layer to another.
How do I go about that?
You don't have to select the objects. Merge the layer to the desired one. There are a couple of ways to do this.
@bobbyrubyii wrote:
How can I select things in all places?
The (ssget "_X") thing will find all of them, but if you want to change their Layer, it will be necessary to either step through them and use (vla) or (subst)/(entmod) methods to change it for things not in the current space, or to change the current space to where each one is, and change its Layer there.
You can use LAYMRG [see end of Message 2, and Message 11], as long as you're aware of the differences:
LAYMRG will remove the source Layer from the drawing, whereas other methods won't [a disadvantage if you want to keep that Layer around].
LAYMRG will also change the Layer of nested objects, i.e. pieces of Block definitions, which the other methods won't [a definite advantage if you need that].
Can't find what you're looking for? Ask the community or share your knowledge.