.NET

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

HOW TO COPY A LAYOUT FROM ANOTHER DRAWING?

265 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
Posts: 319
Registered: ‎05-12-2009
Message 2 of 2 (263 Views)

Re: HOW TO COPY A LAYOUT FROM ANOTHER DRAWING?

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

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