How to select all the objects(or layers) of a drawing

Status
Not open for further replies.

Lingsha

Usenet Archive
Joined
Dec 17, 2001
Messages
3
Reaction score
0
I'm trying to copy all the layer of one image to a newly created layer of same drawing. I want to select all the objects, then make the new layer active. I tried using sendcommand to select:

acadDoc.SendCommand "_Select" & vbCr

How do specify selected objects "all"? Would you please help me?
Thanks a lot.
 
(Lingsha) wrote:
I'm trying to copy all the layer of one image to a newly created layer of same drawing. I want to select all the objects, then make the new layer active. I tried using sendcommand to select:

acadDoc.SendCommand "_Select" & vbCr

How do specify selected objects "all"? Would you please help me?
Thanks a lot.

Try something like this:

Public Sub CopyToNewLayer

Dim OldEntity As AcadEntity
Dim NewEntity As AcadEntity
Dim SourceLayer As String
Dim TargetLayer As String

SourceLayer = InputBox("Enter source layer name:")
TargetLayer = InputBox("Enter target layer name:")

ThisDrawing.Layers.Add TargetLayer

For Each OldEntity In ThisDrawing.ModelSpace
If OldEntity.Layer = SourceLayer Then
Set NewEntity = OldEntity.Copy
NewEntity.Layer = TargetLayer
End If
Next OldEntity

For Each OldEntity In ThisDrawing.PaperSpace
If OldEntity.Layer = SourceLayer Then
Set NewEntity = OldEntity.Copy
NewEntity.Layer = TargetLayer
End If
Next OldEntity

End Sub
 
Lingsha schrieb:
I'm trying to copy all the layer of one image to a newly created layer of same drawing. I want to select all the objects, then make the new layer active. I tried using sendcommand to select:

acadDoc.SendCommand "_Select" & vbCr

Do you have to use VBA? In LISP the selection of all entities of a drawing is simply: (ssget "X")

Tom Berger
 
Tom Berger wrote:
Lingsha schrieb:
>
> I'm trying to copy all the layer of one image to a newly created layer
> of same drawing. I want to select all the objects, then make the new
> layer active. I tried using sendcommand to select:
>
> acadDoc.SendCommand "_Select" & vbCr

Do you have to use VBA? In LISP the selection of all entities of a drawing is simply: (ssget "X")

Tom Berger

To select all entities in a drawing using VBA:

Dim SS As AcadSelectionSet
Set SS = ThisDrawing.SelectionSets.Add("SS")
SS.Select acSelectionSetAll

To copy all entities in a drawing to the clipboard using the
SendCommand function:

ThisDrawing.SendCommand "_copyclip" & vbCr & "All" & vbCr & vbCr

To paste the contents of the clipboard into a drawing using the
SendCommand function:

ThisDrawing.SendCommand "_pasteclip" & vbCr & "0,0" & vbCr
 
Status
Not open for further replies.

Latest threads

Back
Top