Anyone else get this?

Discussion in 'AutoCAD' started by Tony Tanzillo, Feb 11, 2005.

  1. Below is VBA code that attempts to set the description of
    a Layer State via its dictionary entry.

    There appears to be a problem, and I'd like to know if anyone
    is seeing what I'm seeing.

    To see it, follow these steps:

    1. Open AutoCAD 2005, with a new, unnamed drawing.

    2. Via the Layer Dialog, add a new layer state, giving
    it the name "Foo", and the description "Old Description".

    3. Load the code below into the VBA IDE, and run the
    Test Macro.

    4. Open the Layer States dialog and verify that it
    changed the description of the layer state.

    5. Use the SaveAs command to save the drawing.

    What happens?

    <code>

    ' Requires a Layer State named "Foo" to be defined in the drawing

    Public Sub Test()
    SetLayerStateDescription "Foo", "New description"
    End Sub

    Public Sub SetLayerStateDescription(Name As String, Description As String)
    Dim XDict As AcadDictionary
    Dim XRecord As AcadXRecord
    Set XDict = ThisDrawing.Layers.GetExtensionDictionary("ACAD_LAYERSTATES")
    Set XRecord = XDict(Name)
    Dim Keys As Variant
    Dim Values As Variant
    XRecord.GetXRecordData Keys, Values
    Dim i As Integer
    For i = 0 To UBound(Keys)
    If Keys(i) = 301 Then
    Values(i) = Description
    XRecord.SetXRecordData Keys, Values
    Exit Sub
    End If
    Next i
    End Sub

    </code>
     
    Tony Tanzillo, Feb 11, 2005
    #1
  2. Tony Tanzillo

    fantum Guest

    No errors here but I would have expected one based on what happens to the xrecord data. GetXRecordData returns three of the values as Error 5. SetXRecordData causes those values to become Empty and the associated keys to become 5014.
     
    fantum, Feb 11, 2005
    #2
  3. Tony Tanzillo

    Kelie Guest

    "Error writiing/closing file" when trying to SAVEAS.
     
    Kelie, Feb 11, 2005
    #3
  4. Yes, I noticed that as well, from LISP.
     
    Tony Tanzillo, Feb 11, 2005
    #4
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.