.NET

Reply
Member
dan.popescu
Posts: 5
Registered: ‎03-31-2011
Message 1 of 2 (271 Views)

HOW TO COPY A LAYOUT FROM ANOTHER DRAWING?

271 Views, 1 Replies
08-25-2011 04:52 PM

I want to transfer a layout from an existing drawing.

But i have an error:

epermanentlyerased

 

fails at:

"

DB_template.WblockCloneObjects(Id_colection, Database1.LayoutDictionaryId,

New IdMapping(), DuplicateRecordCloning.Replace, False)

"

 

I read about wblockclone in this forum but I couldn't get it to work.

Can somebody help me?

 

 

PrivateSub test() 

TryDim Current_drawing AsDocument = Application.DocumentManager.MdiActiveDocument

 

Dim Drawing_Template_location AsString= "c:\drawing_template.dwg" 

Dim DB_template AsNewDatabase

 

Dim Numele_template_layout AsString= "Template_layout" 

Dim Id_Layout_t AsObjectId

 

Dim Id1 AsObjectId

 

Using Lock1 AsDocumentLock = Current_drawing.LockDocument

 

Dim Database1 AsDatabase = Current_drawing.Database

 

Dim TransManag1 AsAutodesk.AutoCAD.DatabaseServices.TransactionManager = Database1.TransactionManager

 

Using Trans1 AsTransaction = Database1.TransactionManager.StartTransaction

 

Using Trans2 AsTransaction = DB_template.TransactionManager.StartTransaction

DB_template.ReadDwgFile(Drawing_Template_location, FileOpenMode.OpenForReadAndAllShare,True, "")

Id1 = DB_template.LayoutDictionaryId

Dim Layoutdict As DBDictionary = Trans2.GetObject(Id1, OpenMode.ForRead, False, False)

 

ForEach entry As DBDictionaryEntry InLayoutdict

 

If entry.Key = Numele_template_layout Then

Id_Layout_t = entry.Value

ExitForEndIfNextIf Id_Layout_t <> ObjectId.Null Then

Dim Id_colection AsNewObjectIdCollection

Id_colection.Add(Id_Layout_t)

DB_template.WblockCloneObjects(Id_colection, Database1.LayoutDictionaryId,

New IdMapping(), DuplicateRecordCloning.Replace, False)

Trans1.Commit()

EndIf

EndUsing

EndUsing

EndUsing 

Catch ex AsException

MsgBox(ex.Message)

EndTry

EndSub

Valued Mentor
jeff
Posts: 328
Registered: ‎05-12-2009
Message 2 of 2 (269 Views)

Re: HOW TO COPY A LAYOUT FROM ANOTHER DRAWING?

08-25-2011 05:35 PM in reply to: dan.popescu
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.