Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to select all objects on a particular layer

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
Anonymous
33978 Views, 11 Replies

How to select all objects on a particular layer

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

How do I go about that?

11 REPLIES 11
Message 2 of 12
Kent1Cooper
in reply to: Anonymous


@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
Message 3 of 12
3wood
in reply to: Anonymous

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

Capture.PNG

Message 4 of 12
Anonymous
in reply to: 3wood

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

Message 5 of 12
Anonymous
in reply to: Kent1Cooper

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

Message 6 of 12
Kent1Cooper
in reply to: Anonymous


@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
Message 7 of 12
Alfred.NESWADBA
in reply to: Anonymous

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)
Message 8 of 12
Anonymous
in reply to: Alfred.NESWADBA

Thank you, Alfred. Thanks a lot 

Message 9 of 12
bobbyrubyii
in reply to: Kent1Cooper

How can I select things in all places?

Message 10 of 12
RobDraw
in reply to: bobbyrubyii


@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.
Message 11 of 12
RobDraw
in reply to: Anonymous


@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.
Message 12 of 12
Kent1Cooper
in reply to: bobbyrubyii


@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

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

Post to forums  

Forma Design Contest


Autodesk Design & Make Report