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

Renaming Xref's in Xref Palette

2 REPLIES 2
Reply
Message 1 of 3
BrentBurgess1980
322 Views, 2 Replies

Renaming Xref's in Xref Palette

Hi all

The code below changes the Xref BlockTableRecord Name within the drawing. Works well, but I would like to know if there is a way to rename the xref in the xref palette?

Dim Doc As Document = AcApp.DocumentManager.MdiActiveDocument
Dim Ed As Editor = Doc.Editor
Dim Db As DatabaseServices.Database = Doc.Database
Dim Tr As DatabaseServices.Transaction = Db.TransactionManager.StartTransaction()

Using Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument
Using Tr

Dim DbXrGraph As DatabaseServices.XrefGraph = Db.GetHostDwgXrefGraph(True)

' look at all Nodes in the XrefGraph. Skip 0 node since it is the drawing itself.


For i As Integer = 1 To DbXrGraph.NumNodes - 1
Dim XrGraphNode As DatabaseServices.XrefGraphNode = DbXrGraph.GetXrefNode(i)
If Not XrGraphNode.IsNested Then
Dim btr As DatabaseServices.BlockTableRecord
Try
btr = DirectCast(Tr.GetObject(XrGraphNode.BlockTableRecordId, DatabaseServices.OpenMode.ForWrite), DatabaseServices.BlockTableRecord)
Debug.Print(btr.Name)
If btr.Name = StrOldNameThen
btr.Name = StrNewName
Tr.Commit()
Exit For
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
Next
End Using
End Using

Any help is appreciated.

Brent
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: BrentBurgess1980

This is a defect in the References Palette.

Whomever design that feature doesn't understand how complicated modeless
user interfaces are.

Basically, a modeless UI must listen for any changes that would affect the
data that it displays, and that's what the Reference's palette is failing to
do in this case.

One longshot is to try starting the -XREF command (the command line version
with the leading dash), and just exit the command and see if the palette
updates.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6255132@discussion.autodesk.com...
Hi all

The code below changes the Xref BlockTableRecord Name within the drawing.
Works well, but I would like to know if there is a way to rename the xref in
the xref palette?

Dim Doc As Document = AcApp.DocumentManager.MdiActiveDocument
Dim Ed As Editor = Doc.Editor
Dim Db As DatabaseServices.Database = Doc.Database
Dim Tr As DatabaseServices.Transaction =
Db.TransactionManager.StartTransaction()

Using
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument
Using Tr

Dim DbXrGraph As DatabaseServices.XrefGraph =
Db.GetHostDwgXrefGraph(True)

' look at all Nodes in the XrefGraph. Skip 0 node since it
is the drawing itself.


For i As Integer = 1 To DbXrGraph.NumNodes - 1
Dim XrGraphNode As DatabaseServices.XrefGraphNode =
DbXrGraph.GetXrefNode(i)
If Not XrGraphNode.IsNested Then
Dim btr As DatabaseServices.BlockTableRecord
Try
btr =
DirectCast(Tr.GetObject(XrGraphNode.BlockTableRecordId,
DatabaseServices.OpenMode.ForWrite), DatabaseServices.BlockTableRecord)
Debug.Print(btr.Name)
If btr.Name = StrOldNameThen
btr.Name = StrNewName
Tr.Commit()
Exit For
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
Next
End Using
End Using

Any help is appreciated.

Brent
Message 3 of 3

Hi Tony,

Thanks for the tip. Starting the -xref and exiting does not work, however, -xref, reload, does.

Will use that one for now.

Cheers

Brent

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