Associating Extended data with Layers.

Discussion in 'AutoCAD' started by vasantshetty, Aug 23, 2003.

  1. vasantshetty

    vasantshetty Guest

    Dear All,

    I would like to have your help on this small problem i am facing.
    I would like to attach an information to a layer as soon as it is created. say scale.

    I tried using event object added and used the following code.
    ============================================================
    Private Sub AcadDocument_ObjectAdded(ByVal Object As Object)
    Dim aobj As AcadObject
    Dim DataType(0 To 1) As Integer
    Dim Data(0 To 1) As Variant
    Dim lscale As Double

    Set aobj = Object
    If aobj.ObjectName = "AcDbLayerTableRecord" Then
        lscale = ThisDrawing.Utility.GetReal("Enter the scale for layer : ")
        DataType(0) = 1001
        Data(0) = aobj.Name ' layer
        DataType(1) = 1040
        Data(1) = lscale ' real

    ThisDrawing.Layers.Item(aobj.Name).SetXData DataType, Data

    End If

    End Sub
    ============================================================

    But this deosnt work since the object is open for editing, it deosnt allow us to add extened data for the same.

    My requirement is that the moment i create a layer this scale information must get associated with the layer and user wont be able to edit or modify it.

    Can anyone help me out with a solution???

    Thanking in advance,

    Vasant Shetty
     
    vasantshetty, Aug 23, 2003
    #1
  2. One way to make this work would be to create two variables at module scope: a
    boolean and a string. In your ObjectAdded event, set the boolean to true and
    the string to the name of the layer. Then create and EndCommand event. In the
    EndCommand event check the value of the boolean. If it is true, you know a
    layer has been added and the string should contain it's name. You can safely
    modify the layer now, because it is no longer opened by AutoCAD. Once you are
    done, set the boolean back to false and the string to vbNullString.

    to add extened data for the same.
    get associated with the layer and user wont be able to edit or modify it.
     
    Chuck Gabriel, Aug 26, 2003
    #2
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.