Author Topic: .NET xref binding - in process  (Read 1621 times)

0 Members and 1 Guest are viewing this topic.

jcbrown630

  • Guest
.NET xref binding - in process
« on: February 02, 2015, 10:01:24 AM »
I've written an inprocess extension for my end users to select and load a bunch of drawing files using a file open dialog on a windows form. The list box takes the list of files and 1 at a time opens the drawing and adjusts misc. aspects of the drawing such as layers and text styles. Lastly before closing and saving I am attempting to bind any xrefs that are in the file, and alert the user if any are missing. When I attempt to bind the xrefs the drawings appear to be wiped out, upon re-opening the files. Also the files drop to ~48kb... I'm not sure what I'm doing wrong here but the xref code is below:

                Dim xrefIDcoll As New ObjectIdCollection
                If dial.Chkbx_Xref.Checked Then
                    ProcleanD.xrefIssue = ""
                    'Application.ShowAlertDialog("Xref scan initiated")
                    Dim xgraph As XrefGraph = acDb.GetHostDwgXrefGraph(False)
                    Dim nodeQty As Int16 = xgraph.NumNodes
                    If nodeQty > 1 Then
                        ProcleanD.xrefIssue = "Xref Issue Exists"
                        For i = 0 To nodeQty - 1
                            Dim xnode As XrefGraphNode = xgraph.GetXrefNode(i)
                            Dim BTRid As ObjectId = xnode.BlockTableRecordId ' get the block table record ID for the xref
                            If BTRid.IsNull Then
                            Else
                                Dim BTR As BlockTableRecord = acTrans.GetObject(BTRid, OpenMode.ForRead)
                                If xnode.XrefStatus = XrefStatus.Unresolved Then
                                    ProcleanD.xrefIssue = "Missing Xref"
                                ElseIf xnode.Database.Filename = acDb.Filename Then

                                Else
                                    If BTR.IsFromExternalReference Then
                                        Dim xrefRefIDS As ObjectIdCollection = BTR.GetBlockReferenceIds(True, True)
                                        For Each objid As ObjectId In xrefRefIDS
                                            xrefIDcoll.Add(objid)

                                        Next

                                    End If
                                End If
                            End If ' File not found

                        Next
                        'acDb.BindXrefs(xrefIDcoll, False) ' bind the xref collection

                    End If
                End If
                acTrans.Commit()
                acEd.Regen()

I would say i'm still relatively new to writing in VB with .NET so please excuse any dumb mistakes. I'm all ears for constructive criticism  :-D :-D

jcbrown630

  • Guest
SOLVED!!!!!!
« Reply #1 on: February 04, 2015, 10:17:43 AM »
The program was saving the empty drawing that was open prior to execution of the command over the 1st file in the list. Added a closeanddiscard() to the beginning of the program prior to opening drawings for processing.

D'OH!