getting the drawing name

Discussion in 'AutoCAD' started by debanjan, Apr 19, 2004.

  1. debanjan

    debanjan Guest

    i have 2 autoCAD drawings 'a.dwg' and b.dwg'. b.dwg is an xref in a.dwg. I am able to access to the block and get the reference name (say 'xref1'). but I want to get the path of the externally referenced drawing.

    Dim tempBlock As AcadBlock
    For Each tempBlock In doc.Blocks
    If tempBlock.IsXRef Then
    MsgBox tempBlock.Name
    End If
    Next

    I am able to get the name of the external reference but I want to get the dwg file also (b.dwg).

    please Suggest.

    Regards,
    Debanjan
     
    debanjan, Apr 19, 2004
    #1
  2. debanjan

    A Seidel Guest

    I think the answer has to do with AutoCAD years ago patching in xrefs
    as block objects that did not have a structure defined to contain the
    file name. Therefore the path property of an xref is part of some
    other type of object. Maybe this will help. It is one way to
    collect the path names. This function fills arrays containing the
    xref block names and the xref full path names. You are seeing this
    out of context, so you'll have to adjust it to your needs. The long
    statement lines have also been wrapped by this news reader. So you'll
    have to fix those.


    '//GetXrefPaths. Returns a variant array of
    '//strings, the paths of all RESOLVED xrefs
    ' Returns Pathlist as array of full path xref names
    ' Returns NameList as array of xref block names
    ' GetNested is flag for include nested xrefs or not (false = include)
    Public Function GetXrefPaths(PathList As Variant, NameList As Variant,
    GetNested As Boolean) As Variant
    Dim objXref As AcadExternalReference
    Dim objSelCol As AcadSelectionSets
    Dim objSelSet As AcadSelectionSet
    Dim objBlks As AcadBlocks
    Dim objEnt As AcadEntity
    Dim objNested As Object
    Dim objBlk As AcadBlock
    Dim intType(0) As Integer
    Dim varData(0) As Variant
    Dim varRet As Variant
    Dim strPaths() As String
    Dim strNames() As String
    Dim intcnt As Integer
    GetXrefPaths = 0
    On Error GoTo Err_Control
    Set objBlks = ThisDrawing.Blocks
    Set objSelCol = ThisDrawing.SelectionSets
    For Each objSelSet In objSelCol
    If objSelSet.Name = "GetXrefPaths" Then
    objSelCol.Item("GetXrefPaths").Delete
    Exit For
    End If
    Next
    Set objSelSet = objSelCol.Add("GetXrefPaths")
    intType(0) = 0
    varData(0) = "INSERT"
    objSelSet.Select 5, filtertype:=intType, _
    filterdata:=varData
    For Each objEnt In objSelSet
    Set objBlk = objBlks(objEnt.Name)
    If objBlk.IsXRef Then
    Set objXref = objEnt
    ReDim Preserve strPaths(intcnt)
    ReDim Preserve strNames(intcnt)
    strPaths(intcnt) = objXref.Path
    strNames(intcnt) = objXref.Name
    intcnt = intcnt + 1
    If GetNested = False Then
    For Each objNested In objBlk
    If TypeOf objNested Is AcadExternalReference Then
    ReDim Preserve strPaths(intcnt)
    ReDim Preserve strNames(intcnt)
    strPaths(intcnt) = objNested.Path
    strNames(intcnt) = " " & objNested.Name ' spaces to show
    nesting
    intcnt = intcnt + 1
    End If
    Next objNested
    End If
    End If
    Next objEnt
    varRet = strPaths
    PathList = varRet
    NameList = strNames
    Exit_Here:
    GetXrefPaths = intcnt
    Exit Function
    Err_Control:
    Select Case Err.Number
    'Add additional Case selections here
    Case Else
    MsgBox Err.Description
    Err.Clear
    Resume Exit_Here
    End Select
    End Function
     
    A Seidel, Apr 19, 2004
    #2
  3. debanjan

    mcuevas Guest

    you should be able to use the path property for the xref

    dim strTemp as string

    strTemp = tempBlock.path


    -mc


    am able to access to the block and get the reference name (say 'xref1'). but
    I want to get the path of the externally referenced drawing.
     
    mcuevas, Apr 19, 2004
    #3
  4. debanjan

    Ed Jobe Guest

    MC, Blocks don't have paths.

    Debanjan, what you have give you the block definition. But now that you have
    the name of the xref, you can search the dwg for an AcadExternalReference
    object whose Name property matches that, and it has a Path property.
     
    Ed Jobe, Apr 19, 2004
    #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.