.NET

Reply
Active Contributor
Posts: 35
Registered: ‎11-17-2003
Message 1 of 1 (134 Views)

replace with blocks in a drawing with the blocks from another drawing

134 Views, 0 Replies
06-23-2009 07:11 AM
Ok, im struggling a little here, I think I have all the right functions under my hat but cant seem to string them together, what im trying to achieve is replacing all the blocks in one drawing with all the blocks of the same name in another drawing.

so the process im going through is:

1. Open up the 2 drawings and match up the block names - done
2. Create a new database and add the blocks from the source drawing that matched the final drawing - stuck
3. copy the blocks from the new database into the final drawing - this should be easy once ive got part 2 done.

Any help please?

Below is the example of where I got to but I get an error stating the block is already in the database


Dim ThisDrawing As Document = Application.DocumentManager.Open(SourceLoca.Text, True)
Dim ThisDB As Database = ThisDrawing.Database
Dim Trans As Transaction = ThisDB.TransactionManager.StartTransaction
Dim BT As BlockTable = Trans.GetObject(ThisDB.BlockTableId, OpenMode.ForRead)
Dim BTenum As SymbolTableEnumerator = BT.GetEnumerator
Dim TempDB As Database = New Database(True, True)

Do While BTenum.MoveNext = True
Dim BTR As BlockTableRecord = BTenum.Current.GetObject(OpenMode.ForRead)
TempDB.AddDBObject(BTR)
Loop
Trans.Commit()
Trans.Dispose()
MsgBox("new database done")

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community