Move elements from one layer to another

Discussion in 'AutoCAD' started by antoniomiranda, Jun 28, 2003.

  1. Hello,

    I have 2 elements on layer 12, one in a line with color=2, linetype=4; other is an arc with color=5 and linetype=2.

    I want to move or copy the line to layer 55, with color=8 and linetype=3; and the arc element to layer 66, with color=7 and linetype=1.

    If possible specify the method to copy and the method to move elements.

    Thank's
    António Miranda
     
    antoniomiranda, Jun 28, 2003
    #1
  2. antoniomiranda

    Mark Propst Guest

    Hello,
    I have 2 elements on layer 12, one in a line with color=2, linetype=4; other
    is an arc with color=5 and linetype=2.
    I want to move or copy the line to layer 55, with color=8 and linetype=3;
    and the arc element to layer 66, with color=7 and linetype=1.

    If possible specify the method to copy

    the basic idea is: (just one way)
    first get your object you want to copy, either with a selection set or
    however,
    then get your element properties, store in variables,
    oClr = object.Color
    'find the current owner, not sure about the syntax here and no time to
    confirm...
    but you get the idea (is; the line in mspace, pspace or a block?)
    oOwner = object.OwnerId
    oOwner = oOwner.Name ?????

    then create a new object with desired properties, using your variables
    set Block = oOwner? Model Space, paper space or a block name - depending on
    where you want your line 'copied" to.
    set oLine = ThisDrawing.Block.AddLine pt1 pt2
    oLine.Color = oClr
    etc with other properties

    and the method to move elements.
    just change the start point and endpoint for a line to wehre you want to
    move it
    oLine.Startpoint = newStartpoint
    oLine.Endpoint = newEndpoint

    similar with arc, including centerpoint

    and if you want to change the properties, color etc, do as above
    oObject.Color = newColor ...etc

    that's realbrief and not coded for you but does it help with an idea of what
    to do:?
    sorry I'm in a hurry now and don't have time to give a better explanation
    but hopefully that helps get you started, and I'm sure you'll get lots of
    better answers soon anyway...
    :)

    good luck
    Mark
    I'll check back later and see if you got what you needed.
     
    Mark Propst, Jun 28, 2003
    #2
  3. antoniomiranda

    HJohn Guest

    Here is a small example to copy or move entities from one layer to another, you can change it to your needs. Hope it helps.

    Public Sub ChangeLayers()
    Dim Obj As AcadEntity
    Dim I As Integer
    Dim Cur_Lay As AcadLayer
    Dim New_Lay As String
    Dim Pt As Variant
    Dim SS As AcadSelectionSet
    Dim Action As String
    Dim ActList As String
    Dim Ent As AcadEntity

    Set SS = ThisDrawing.SelectionSets.Add("$SS01$")
    ThisDrawing.Utility.Prompt Chr(13) & "Select entities to be copied or moved to new layer"
    SS.SelectOnScreen
    ThisDrawing.Utility.GetEntity Ent, Pt, "Select an entity on destination layer: "
    New_Lay = Ent.Layer
    ActList = "Copy Move"
    ThisDrawing.Utility.InitializeUserInput 1, ActList
    Action = UCase$(ThisDrawing.Utility.GetKeyword("Enter command [Copy/Move]: "))
    Set Ent = Nothing
    If Action = "COPY" Then
        For Each Obj In SS
            Set Ent = Obj.Copy
            Ent.Layer = New_Lay
            'You can add any properties need here...
        Next Obj
    ElseIf Action = "MOVE" Then
        For Each Obj In SS
            Obj.Layer = New_Lay
            'You can add any properties need here...
        Next Obj
    End If
    ThisDrawing.SelectionSets.Item("$SS01$").Delete
    End Sub
     
    HJohn, Jun 28, 2003
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.