style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Roland Jungreithmayr" <
href="mailto:roland@thening.at">roland@thening.at> wrote in message
href="news:5247009@discussion.autodesk.com">news:5247009@discussion.autodesk.com...
Ok, here now a picture, for what I
mean:
[img src="@116199"]
My Code:
I can find out which xref the blocktable
contains, but not if it is from the main drawing or from a subdrawing
(xref)
Private
size=2> Function
FindXrefRecursive(ByRef
db As Database,
ByVal Lev
color=#0000ff size=2>As
size=2>Integer,
size=2>ByVal dt
size=2>As System.Data.DataTable,
color=#0000ff size=2>ByVal baseKey
color=#0000ff size=2>As
size=2>String) A
s
color=#0000ff size=2>Integer
size=2>Dim i
size=2>As
size=2>Integer =
0
Dim tm
color=#0000ff size=2>As
DBTransactionManager = db.TransactionManager
size=2>Dim myT
size=2>As Transaction =
tm.StartTransaction
size=2>Try
face="Courier New">Dim bt
As BlockTable =
CType
size=2>(tm.GetObject(db.BlockTableId, OpenMode.ForRead,
color=#0000ff size=2>False
size=2>), BlockTable)
Dim
size=2> btr As
face="Courier New"> BlockTableRecord
color=#0000ff size=2>Dim urOrg
size=2>As
Uri
Dim file2load
As
face="Courier New">String
color=#0000ff size=2>DimdbX
size=2>As
Autodesk.AutoCAD.DatabaseServices.Database
size=2>For
size=2>Each btrID
size=2>As ObjectId
size=2>In bt
btr =
CType
size=2>(tm.GetObject(btrID, OpenMode.ForRead,
size=2>False),
BlockTableRecord)
If
btr.IsFromExternalReference
color=#0000ff size=2>Then
urOrg =
color=#0000ff size=2>New
Uri(db.OriginalFileName)
If
size=2> btr.PathName.StartsWith(
size=2>".")
color=#0000ff size=2>Then
file2load
=
Microsoft.VisualBasic.FileIO.FileSystem.CombinePath(IO.Path.GetDirectoryName(db
.OriginalFileName), b tr.PathName)
color=#0000ff size=2>Else
size=2>file2load = btr.PathName
size=2>End
color=#0000ff size=2>If
'add to
table:
'dt.Rows.Add(baseKey &
color=#800000 size=2>"." & i, btr.PathName,
file2load)
dbX =
New
Database(False,
False
face="Courier New">)
dbX.ReadDwgFile(file2load,
IO.FileShare.ReadWrite, F alse
size=2>, Nothing
face="Courier New">)
FindXrefRecursive(dbX, Lev + 1, dt,
baseKey & "."
face="Courier New"> & i)
dbX.Dispose()
i +=
1
End
If
color=#0000ff size=2 ce="Courier New" fa>Next
face="Courier New" color=#0000ff size=2>Finally
face="Courier New">myT.Dispose()
size=2>End
color=#0000ff size=2>Try
face="Courier New">End
Function
"Roland Jungreithmayr" <Hello,
href="mailto:roland@thening.at">
size=2>roland@thening.at> schrieb im
Newsbeitrag
e="Arial" fac>news:5242435@discussion.autodesk.com
size=2>...
I have to make
all xrefs's to relative path xrefs: I found a solution that
works fine in
the first level of xref.
Now I want to find out, if a xref is not
referenced to the main drawing, so
it is an xref in an xref.
Has anyone
an idea?
roland
Dim graphXref As XrefGraph
graphXref =
db.GetHostDwgXrefGraph(True)
Debug.WriteLine(graphXref.NumNodes)
For idx
As Integer = 1 To graphXref.NumNodes - 1
Dim nodeXref As
XrefGraphNode
nodeXref = graphXref.GetXrefNode(idx)
If Not nodeXref Is
Nothing Then
Dim btrId As ObjectId
btrId =
nodeXref.BlockTableRecordId
Dim BTR As BlockTableRecord =
CType(tm.GetObject(btrId, OpenMode.ForRead, False), BlockTableRecord)
Dim
path As String = BTR.PathName
Debug.WriteLine("xref = " & nodeXref.Name
& " path=" & path & " " & nodeXref.IsNested & " " &
nodeXref.NumIn & " " & nodeXref.NumOut)
End If
Next
Result in Debugwindow (base on the drawing. from
which I made the screenshot)
face="Courier New">(Debug.WriteLine("xref = " & nodeXref.Name & " path="
& path & " " & nodeXref.IsNested & " " & nodeXref.NumIn
& " " & nodeXref.NumOut)
xref = Polygon
path=..\..\..\Projekte\xref\Polygon.dwg True 1 0
face="Courier New" size=2>xref = quadrat path=C:\Projekte\xref\vz1\quadrat.dwg
False 2 0
xref = Main
path=..\..\..\Projekte\xref\Main.dwg False 1 4
face="Courier New" size=2>xref = Dreieck
path=..\..\..\Projekte\xrefUpPfad\vzU1\Dreieck.dwg True 1 0
face="Courier New" size=2>xref = kreis path=C:\Projekte\xref\vz1\vz2\kreis.dwg
True 1 0
roland
Can't find what you're looking for? Ask the community or share your knowledge.