.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

xref in xref

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
345 Views, 4 Replies

xref in xref

Hello,

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
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous


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,
color=#0000ff size=2>ByVal
Lev
size=2>As

size=2>Integer
,
size=2>ByVal
dt
size=2>As
System.Data.DataTable,
size=2>ByVal
baseKey
size=2>As

size=2>String
)
size=2>As

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
),
BlockTable)
Dim btr
As

size=2> BlockTableRecord
Dim
size=2> urOrg
As

face="Courier New"> Uri

size=2>Dim
file2load
size=2>As

color=#0000ff size=2>String
Dim
size=2> dbX
As

face="Courier New">
Autodesk.AutoCAD.DatabaseServices.Database

size=2>For

size=2>Each
btrID
size=2>As
ObjectId
size=2>In
bt
btr =
CType(tm.GetObject(btrID,
OpenMode.ForRead,
False

face="Courier New">), BlockTableRecord)

color=#0000ff size=2>If
btr.IsFromExternalReference

size=2>Then
urOrg =
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),
btr.PathName)

size=2>Else
file2load =
btr.PathName
End

size=2>If

'add to
table:
'dt.Rows.Add(baseKey &
color=#800000 size=2>"."
& i, btr.PathName,
file2load
)
dbX =
New Database(
color=#0000ff size=2>False
,
size=2>False

size=2>)
dbX.ReadDwgFile(file2load, IO.FileShare.ReadWrite,

color=#0000ff size=2>False
,
size=2>Nothing

size=2>)
FindXrefRecursive(dbX, Lev + 1, dt, baseKey &

color=#800000 size=2>"."

& i)
dbX.Dispose()
i += 1

size=2>End

color=#0000ff size=2>If

size=2>Next

size=2>Finally

size=2>myT.Dispose()
End
size=2>

size=2>Try

face="Courier New">End

Function

 

 

 

Hello,

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
Message 3 of 5
Anonymous
in reply to: Anonymous



title="AcDbXrefGraphNode::btrId Function">AcDbXrefGraphNode
class=492453323-21042006> can be used.


class=492453323-21042006>I don't have sample around though.


 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


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>Dim
dbX

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

 

 

 

Hello,

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
Message 4 of 5
Anonymous
in reply to: Anonymous

Autodesk.AutoCAD.DatabaseServices.XrefGraph
Autodesk.AutoCAD.DatabaseServices.XrefGraphNode

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"Roland Jungreithmayr" wrote in message 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 Function FindXrefRecursive(ByRef db As Database, ByVal Lev As Integer, ByVal dt As System.Data.DataTable, ByVal baseKey As String) A s Integer
Dim i As Integer = 0
Dim tm As DBTransactionManager = db.TransactionManager
Dim myT As Transaction = tm.StartTransaction
Try

Dim bt As BlockTable = CType(tm.GetObject(db.BlockTableId, OpenMode.ForRead, False), BlockTable)
Dim btr As BlockTableRecord
Dim urOrg As Uri
Dim file2load As String
Dim dbX As Autodesk.AutoCAD.DatabaseServices.Database
For Each btrID As ObjectId In bt
btr = CType(tm.GetObject(btrID, OpenMode.ForRead, False), BlockTableRecord)
If btr.IsFromExternalReference Then
urOrg = New Uri(db.OriginalFileName)
If btr.PathName.StartsWith(".") Then
file2load = Microsoft.VisualBasic.FileIO.FileSystem.CombinePath(IO.Path.GetDirectoryName(db .OriginalFileName), b tr.PathName)
Else
file2load = btr.PathName
End If
'add to table:
'dt.Rows.Add(baseKey & "." & i, btr.PathName, file2load)
dbX = New Database(False, False)
dbX.ReadDwgFile(file2load, IO.FileShare.ReadWrite, F alse, Nothing)
FindXrefRecursive(dbX, Lev + 1, dt, baseKey & "." & i)
dbX.Dispose()
i += 1
End If
Next
Finally
myT.Dispose()
End Try
End Function



"Roland Jungreithmayr" schrieb im Newsbeitrag news:5242435@discussion.autodesk.com...
Hello,

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
Message 5 of 5
Anonymous
in reply to: Anonymous


Thanks Tony + Jimmy,

 

I tried now the following code, but I don't know
which informations now are usefull for me:

 


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)


size=1>

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


mayby a quicktip for me?


roland


 

 

 


size=2>Autodesk.AutoCAD.DatabaseServices.XrefGraph
Autodesk.AutoCAD.DatabaseServices.XrefGraphNode


--

size=2>http://www.caddzone.com



size=2>AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007

href="http://www.acadxtabs.com">
size=2>http://www.acadxtabs.com



size=2>"Roland Jungreithmayr" <

href="mailto:roland@thening.at">
size=2>roland@thening.at
> wrote in message

size=2>news:5247009@discussion.autodesk.com

size=2>...
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 Function FindXrefRecursive(ByRef db As Database,
ByVal Lev As Integer, ByVal dt As System.Data.DataTable, ByVal baseKey As
String) A s Integer
Dim i As Integer = 0
Dim tm As DBTransactionManager =
db.TransactionManager
Dim myT As Transaction =
tm.StartTransaction
Try

Dim bt As BlockTable =
CType(tm.GetObject(db.BlockTableId, OpenMode.ForRead, False), BlockTable)
Dim
btr As BlockTableRecord
Dim urOrg As Uri
Dim file2load As String
Dim
dbX As Autodesk.AutoCAD.DatabaseServices.Database
For Each btrID As ObjectId
In bt
btr = CType(tm.GetObject(btrID, OpenMode.ForRead, False),
BlockTableRecord)
If btr.IsFromExternalReference Then
urOrg = New
Uri(db.OriginalFileName)
If btr.PathName.StartsWith(".") Then
file2load =
Microsoft.VisualBasic.FileIO.FileSystem.CombinePath(IO.Path.GetDirectoryName(db
.OriginalFileName), b tr.PathName)
Else
file2load = btr.PathName
End
If
'add to table:
'dt.Rows.Add(baseKey & "." & i, btr.PathName,
file2load)
dbX = New Database(False, False)
dbX.ReadDwgFile(file2load,
IO.FileShare.ReadWrite, F alse, Nothing)
FindXrefRecursive(dbX, Lev + 1, dt,
baseKey & "." & i)
dbX.Dispose()
i += 1
End
If
Next
Finally
myT.Dispose()
End Try
End
Function
 
 
 
"Roland Jungreithmayr" <

href="mailto:roland@thening.at">
size=2>roland@thening.at
> schrieb im
Newsbeitrag

face=Arial size=2>news:5242435@discussion.autodesk.com

face=Arial size=2>...
Hello,

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost