question re sortents table and draw order

Discussion in 'AutoCAD' started by ericky, Dec 4, 2004.

  1. ericky

    ericky Guest

    No one has responded to my missives concerning draw order and the sortents table. Is the sortents table new in 2005? Can anyone shed any light why the code below doesn't work? It is intended to list out the drawing entities in draw order, but it doesn't.

    Dim e as AcadEntity
    Dim b as AcadBlock
    Dim eDictionary As Object
    Dim sentityObj As AcadSortentsTable

    Set eDictionary = _
    ThisDrawing.ModelSpace.GetExtensionDictionary
    Set sentityObj = eDictionary.GetObject("ACAD_SORTENTS")
    Set b = ThisDrawing.ModelSpace

    sentityObj.GetFullDrawOrder b, True
    For Each e In sentityObj.Block
    MsgBox e.ObjectName
    Next e

    Thanks for any help you can provide.

    - ej
     
    ericky, Dec 4, 2004
    #1
  2. ericky

    Jeff Mishler Guest

    Well, I can answer I of your questions....No, the sortents table is not new
    to 2005 BUT the access to it via VBA is new.
    I don't have 2005 to test any code with, sorry.
     
    Jeff Mishler, Dec 4, 2004
    #2
  3. Sortents in NOT new in 2005.
    Don't really know if there have been changes made to it since acad2002
    But if I recall correctly, this table has a list of entity handles plus a
    long
    indicating the position for each.
     
    Jorge Jimenez, Dec 4, 2004
    #3
  4. From Jeff's post I think it may be possible that the new methods have not been implemented correctly by Autodesk. This is purely a stab in the dark. Try manually cycling the sortents table checking the index as indicated by Jorge.
    Regards - Nathan
     
    Nathan Taylor, Dec 5, 2004
    #4
  5. ericky

    fantum Guest

    Try iterating the array of entities returned in the variant "b".


    » No one has responded to my missives concerning draw order and the sortents table. Is the sortents table new in 2005? Can anyone shed any light why the code below doesn't work? It is intended to list out the drawing entities in draw order, but it doesn't.
    »
    » Dim e as AcadEntity
    » Dim b as AcadBlock
    » Dim eDictionary As Object
    » Dim sentityObj As AcadSortentsTable
    »
    » Set eDictionary = _
    » ThisDrawing.ModelSpace.GetExtensionDictionary
    » Set sentityObj = eDictionary.GetObject("ACAD_SORTENTS")
    » Set b = ThisDrawing.ModelSpace
    »
    » sentityObj.GetFullDrawOrder b, True
    » For Each e In sentityObj.Block
    » MsgBox e.ObjectName
    » Next e
    »
    » Thanks for any help you can provide.
    »
    » - ej
     
    fantum, Dec 6, 2004
    #5
  6. ericky

    ericky Guest

    No, that doesn't work either. It lists them out in creation order (lowest handle or lowest objectid first), but if you have changed the draw order using the draworder commands (bring above, send below, et al) the order does not change in b.
     
    ericky, Dec 6, 2004
    #6
  7. ericky

    ericky Guest

    Where, or in what structure or property is the long indicating the position?
     
    ericky, Dec 6, 2004
    #7
  8. ericky

    fantum Guest

    This works for me:

    Public Sub test()
    Dim e As AcadEntity
    Dim b As Variant 'AcadBlock
    Dim eDictionary As Object
    Dim sentityObj As AcadSortentsTable

    Set eDictionary = _
    ThisDrawing.ModelSpace.GetExtensionDictionary
    Set sentityObj = eDictionary.GetObject("ACAD_SORTENTS")
    Set b = ThisDrawing.ModelSpace

    sentityObj.GetFullDrawOrder b, True
    Dim x As Long
    'For Each e In sentityObj.Block
    For x = LBound(b) To UBound(b)
    MsgBox b(x).ObjectName
    'Next e
    Next x

    End Sub
     
    fantum, Dec 6, 2004
    #8
  9. ericky

    ericky Guest

    Bullseye. Thank you >>very much<<, indeed.

    - ej
     
    ericky, Dec 7, 2004
    #9
  10. ericky

    fantum Guest

    A couple of things to be aware of. The ACAD_SORTENTS dictionary may not exist which would cause an error on the call to .GetObject. Also, you may not get what you want if the SORTENTS system variable is not 127 - depends on what it is you want in that case.
     
    fantum, Dec 7, 2004
    #10
  11. ericky

    HJohn Guest

    I am working in Acad2004 and I can't find the AcadSortents table. I can't find it in either the Main dictionary or the extension dictionary of the model space. Any suggestion on how to access this table in 2004? Thanks in advance.
     
    HJohn, Dec 7, 2004
    #11
  12. I don't think the table gets added until the draworder is changed from the order it was drawn. The following is part of the only example in 2005.
    Code:
    'Gxet an extension dictionary and, if necessary, add a SortentsTable object
    Dim eDictionary As Object
    Set eDictionary = ThisDrawing.ModelSpace.GetExtensionDictionary
    ' Prevent failed GetObject calls from throwing an exception
    On Error Resume Next
    Dim sentityObj As Object
    Set sentityObj = eDictionary.GetObject("ACAD_SORTENTS")
    On Error GoTo 0
    If sentityObj Is Nothing Then
    ' No SortentsTable object, so add one
    Set sentityObj = eDictionary.AddObject("ACAD_SORTENTS", "AcDbSortentsTable")
    End If
    
     
    Nathan Taylor, Dec 7, 2004
    #12
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.