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

Explode help

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
ProfWolfMan
848 Views, 4 Replies

Explode help

 

Dear sirs,
Below is my code to bind all xrefs in current drawing.
(assumed that there is no nested xref)
Now i want to explode all of that binded xrefs(block references).
anyone can help me this?
--------------------------------------------------------------------------------------
Public Sub BindXrefDwgs()
        doc = Application.DocumentManager.MdiActiveDocument
        db = doc.Database
        Using docklock As DocumentLock = doc.LockDocument()
            Using DWGMTrans As Transaction = db.TransactionManager.StartTransaction
                Dim XrefGr As XrefGraph = db.GetHostDwgXrefGraph(True)
                Dim XrefGrCol As GraphNodeCollection = New GraphNodeCollection
                Dim xrefdwgs As New ObjectIdCollection
                Dim index As Integer = 0
                For index = 0 To XrefGr.NumNodes
                    XrefGrCol.Add(XrefGr.GetXrefNode(index))
                Next
                For Each XrefGrNode As XrefGraphNode In XrefGrCol
                    If XrefGrNode.XrefStatus <> XrefStatus.FileNotFound Then
                        xrefdwgs.Add(XrefGrNode.BlockTableRecordId)
                    End If
                Next
                Try
                    db.BindXrefs(xrefdwgs, False) 'bind
                Catch
                Finally
                    DWGMTrans.Commit()
                    DWGMTrans.Dispose()
                End Try
            End Using
        End Using
End Sub
--------------------------------------------------------------------------------------

 

Thanks & Regards,
G
4 REPLIES 4
Message 2 of 5

If you just want to explode the main Xref block and place all the resulting objects in Model or Paper space, then you just open the BlockReference and call ExplodeToOwnerSpace()

 

If you want more control over the objects, or want to explode nested blocks or whatever, then you open the BlockReference and call bref.Explode(DbObjectCollection).  You pass it an empty DbObjectCollection and the resulting objects created by the Explode are put into the Collection.  Then you are responsible for both Adding those objects to the Database and erasing the original object.

 

I have never used ExplodeToOwnerSpace, so I am not sure, but I think in that case you would also be responsible for erasing the original object, but the exploded objects are automatically added to whatever the parent BlockTableRecord was.

Dave O.                                                                  Sig-Logos32.png
Message 3 of 5

Hi,

 

Now i wrote a procedure to explode all block references.

But i got error msg as eCannotScaleNonUniformly.

I have uniformly scaled blocks only. Below is my code.

Anyone can help me, please.

 

note: code is attached.

Thanks & Regards,
G
Message 4 of 5

hi,

 

now i try some other way using 'explodetoownerspace'.

but i did not achive result.

i got 'einvalidinput' error.

 

please help me.

Thanks & Regards,
G
Message 5 of 5
Jeffrey_H
in reply to: ProfWolfMan

This worked for me with non-uniformed scaled blocks

 

        <CommandMethod("ExplodeBlocks")> _
        Public Sub ExplodeBlocks()
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor

            Using trx As Transaction = db.TransactionManager.StartTransaction

                Dim bt As BlockTable = db.BlockTableId.GetObject(OpenMode.ForRead)

                For Each btrObjId As ObjectId In bt

                    Dim btr As BlockTableRecord = btrObjId.GetObject(OpenMode.ForRead)

                    If btr.IsLayout Or btr.IsAnonymous Then
                        Continue For
                    End If
                    Dim objIdColl As ObjectIdCollection = btr.GetBlockReferenceIds(True, True)

                    For Each objId As ObjectId In objIdColl
                        Dim acBref As BlockReference = objId.GetObject(OpenMode.ForWrite)
                        MsgBox(acBref.Name)
                        acBref.ExplodeToOwnerSpace()
                    Next
                Next
                trx.Commit()
            End Using
        End Sub

 

You can also find your answers @ TheSwamp

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