.NET

.NET

Reply
Member
5 Posts
0 Kudos
Registered: ‎03-31-2011
Post 1 of 2

HOW TO COPY A LAYOUT FROM ANOTHER DRAWING?

274 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
341 Posts
53 Kudos
Registered: ‎05-12-2009
Post 2 of 2

Re: HOW TO COPY A LAYOUT FROM ANOTHER DRAWING?

08-25-2011 05:35 PM in reply to: dan.popescu
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!