ObjectDBX & Xrefs

Discussion in 'AutoCAD' started by Dave F, Jan 30, 2004.

  1. Dave F

    Dave F Guest

    Hi

    Is it possible to find which xref's within a drawing are loaded?
    I understand that ObjectDBX is a bit sketchy with xrefs.

    I also want to do that same for the .ctb file.
    Ant Ideas?

    TIA
    Dave F.
     
    Dave F, Jan 30, 2004
    #1
  2. Dave F

    Dave F Guest

    Since posting if done this:

    It finds the Xrefs but can't tell me whether they're loaded or not.
    All the xrefs appear to hsve no XRefDatabase.
    Any Ideas?

    TIA
    Dave F.

    Sub fxTransmit()
    Dim dbxDoc As AxDbDocument
    Dim BlksColl As AcadBlocks
    Dim BlkObj As AcadBlock
    Dim objBlock As AcadDatabase

    Set dbxDoc = AcadApplication.GetInterfaceObject("ObjectDBX.AxDbDocument")
    dbxDoc.Open "P:\6076\Plot\Terminal\s2501 Ground Plan.dwg"

    Set BlksColl = dbxDoc.Blocks

    For Each BlkObj In BlksColl ' cycles through all the blocks in the
    dwg
    If BlkObj.IsXRef Then ' is it an Xref?
    On Error Resume Next
    Set objBlock = dbxDoc.Blocks(BlkObj.Name).XRefDatabase ' tests to
    see if it's loaded
    If Err = 0 Then ' if it's loaded
    Debug.Print BlkObj.Name
    End If ' unloaded
    End If ' xref
    Next ' block
    End
    End Sub
     
    Dave F, Jan 30, 2004
    #2
  3. Dave,

    To get a xref, you need to iterate through the entities and then see if it
    is a block, then
    see if isxref. Next see if you can set an object to the
    oblkreference.xrefdatabase.
    Trap for the error. If there's an error, then the xref isn't loaded.


    Here's a little code:

    Public Function IsXrefFound(oDwg As AxDbDocument, strXrefName As String,
    strBlockName As String, strFoundPath As String) As Integer
    Dim oBlk As AcadBlock
    Dim oXref As AcadDatabase
    Dim fso As FileSystemObject
    Dim strPath As String
    Dim oBlkRef As AcadBlockReference
    Dim strDwgPath As String

    'returns
    '0=Not xref
    '1=Not Found or Loaded
    '2=Found at Stored Path
    '3=Found in Parent Root

    Set fso = New FileSystemObject
    strDwgPath = fso.GetParentFolderName(oDwg.Name)

    On Error Resume Next
    Set oBlk = oDwg.Blocks(strXrefName)
    Set oXref = oBlk.XRefDatabase
    If Err <> 0 Then
    IsXrefFound = 1
    End If

    If oBlk.IsXRef Then
    strPath = fso.GetParentFolderName(strFoundPath)
    If Len(strPath) = 0 Or Left(strPath, 1) = "." Then
    strPath = strDwgPath & "\" & strPath & "\" &
    fso.GetFileName(strFoundPath)
    End If
    strPath = fso.GetAbsolutePathName(strPath)
    If fso.FileExists(strPath) Then
    IsXrefFound = 2 'xref found at stored path
    strFoundPath = strPath
    Exit Function
    Else
    strFoundPath = strDwgPath & "\" & fso.GetFileName(strFoundPath)
    If fso.FileExists(strFoundPath) Then
    IsXrefFound = 3 'xref Found in parent drawing's local directory
    Exit Function
    Else
    IsXrefFound = 1 'xref not found or loaded
    strFoundPath = ""
    Exit Function
    End If
    End If
    Else
    IsXrefFound = 0 ' not an xref
    End If
    End Function


    - Ted Schaefer
    WD Partners
     
    xxxTed Schaefer, Jan 30, 2004
    #3
  4. Dave F

    Dave F Guest

    Hi

    After reading through articles on the web, There's _seems_ to be consensus
    that ObjectDBX does not return XrefDatabase info, and so what I want to do
    can't be done.

    Is this correct?

    TIA
    Dave F.
     
    Dave F, Feb 1, 2004
    #4
  5. When you access drawings via ObjectDBX, xrefs are not
    resolved or loaded. However, you can easily recurse
    into an XRef by getting the name of the referenced DWG
    file, and opening that in ObjectDBX as well.

    So, the answer to your question is yes, it can be done,
    but it does require a bit more programming.
     
    Tony Tanzillo, Feb 1, 2004
    #5
  6. Dave F

    Anne Brown Guest

    Dave (and all) -

    Here is a tip on using the discussion groups to your best
    advantage. Please do not change the subject line of discussion
    group messages to which you are replying. It breaks the ability
    of the search engine to group the messages, makes it harder to
    follow the thread and is quite confusing. If it is a new subject,
    please start a new message; if a reply, put your text answer in
    the body of your message and leave the header the same.

    The message "I need clarification" is in answer to "ObjectDBX &
    Xrefs".

    Thanks for your future cooperation.
     
    Anne Brown, Feb 1, 2004
    #6
  7. Dave F

    Dave F Guest

    Tony,

    Thanks for the reply.
    I understand what your saying. Unfortunately I don't want to get any info
    from the Xref.

    I'm writing an equivalent to the etransmit command, & just need to know if
    the Xref is loaded or, as you say, seeing that the drawing hasn't been
    loaded, would be _attempted_ to be loaded.

    Is there a 'key' in the database of the drawing that would let me know if it
    would load the Xref if the drawing was opened?

    TIA
    Dave F.
     
    Dave F, Feb 2, 2004
    #7
  8. Interpreting the status of the XRef requires access to the
    block's flags (the DXF group 70 data), which isn't exposed
    to ActiveX.
     
    Tony Tanzillo, Feb 2, 2004
    #8
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.