How to select all objects on a particular layer

This widget could not be displayed.

How to select all objects on a particular layer

Anonymous
Not applicable

I want to move all objects from one layer to another.

How do I go about that?

0 Likes
Reply
Accepted solutions (1)
35,053 Views
11 Replies
Replies (11)

Kent1Cooper
Consultant
Consultant

@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.

Kent Cooper, AIA

3wood
Advisor
Advisor
Accepted solution

Use QSELECT to select all object in a layer, then use pull-down layer toolbar to change their layer in one go.

Capture.PNG

Anonymous
Not applicable

Thank you to you both. "qselect" was exactly what I was looking for.

0 Likes

Anonymous
Not applicable

Hi, could you translate this code to vba please? Thanks in advance. I hope you could. 

0 Likes

Kent1Cooper
Consultant
Consultant

@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.

Kent Cooper, AIA
0 Likes

Alfred.NESWADBA
Consultant
Consultant

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 -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2024
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes

Anonymous
Not applicable

Thank you, Alfred. Thanks a lot 

0 Likes

bobbyrubyii
Contributor
Contributor

How can I select things in all places?

0 Likes

RobDraw
Mentor
Mentor

@bobbyrubyii wrote:

How can I select things in all places?


Thaw and unlock all layers then hit Ctrl+A.


Rob

Drafting is a breeze and Revit doesn't always work the way you think it should.
0 Likes

RobDraw
Mentor
Mentor

@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.


Rob

Drafting is a breeze and Revit doesn't always work the way you think it should.
0 Likes

Kent1Cooper
Consultant
Consultant

@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].

Kent Cooper, AIA
0 Likes