Posts: 5
Registered: ‎12-19-2011
Message 1 of 3 (313 Views)
Accepted Solution

Multiply owned object

313 Views, 2 Replies
08-13-2012 11:39 AM

I have a function that clones drawing layouts from a source drawing to a current working (target) drawing. This function is causing a  *Warning* Multiply owned object, handle "F4" warning after the layout is cloned and the target drawing saved. Since I've audit and recovered the target drawing and found no errors, this warning is just annoying.


Here's the code:


Public Function ImportLayout(ByVal filename As String, ByVal layoutname As String) As ObjectId
Dim idLayout As ObjectId = ObjectId.Null
Dim doc As Document = ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim oLock As DocumentLock = doc.LockDocument()
Dim dbSource As New Database(False, False)
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim trans As Transaction = db.TransactionManager.StartTransaction()
dbSource.ReadDwgFile(filename, System.IO.FileShare.Read, True, Nothing)
Dim idDbdSource As ObjectId = dbSource.LayoutDictionaryId
Dim dbdLayout As DBDictionary = DirectCast(trans.GetObject(idDbdSource, OpenMode.ForRead, False, False), DBDictionary)
For Each deLayout As DictionaryEntry In dbdLayout

Dim sLayout As String = deLayout.Key.ToString()
If sLayout.ToUpper() = layoutname.ToUpper() Then
idLayout = DirectCast(deLayout.Value, ObjectId)
Exit For
End If
If idLayout <> ObjectId.Null Then
Dim idc As New ObjectIdCollection()
Dim im As IdMapping = New IdMapping()
Dim dbdict As DBDictionary = DirectCast(trans.GetObject(db.LayoutDictionaryId, OpenMode.ForRead, False, False), DBDictionary)

db.WblockCloneObjects(idc, db.LayoutDictionaryId, im, DuplicateRecordCloning.MangleName, False)
Dim ip As IdPair = im.Lookup(idLayout)
idLayout = ip.Value
Dim lm As LayoutManager = LayoutManager.Current

lm.CurrentLayout = layoutname
End If
Catch ex As System.Exception
End Try
Return idLayout
End Function


Any help would be greatly appreciated.

Thanks in advance.



ADN Support Specialist
Posts: 692
Registered: ‎03-21-2011
Message 2 of 3 (270 Views)

Re: Multiply owned object

08-16-2012 09:39 AM in reply to: JLin631



Try using the Layout.CopyFrom method to copy the layout from the source database. For this you will first need to have a layout created in the destination database. The entities in the layout block table record can then be copied using the wblockCloneObjects.


Here is a related blog post :



This blog post exports a layout to a newly created database and for your case, it is the reverse.

Developer Technical Services
Autodesk Developer Network

Posts: 5
Registered: ‎12-19-2011
Message 3 of 3 (190 Views)

Re: Multiply owned object

11-29-2012 04:12 PM in reply to: Balaji_Ram

Thanks Balaji_Ram,


I've tried both set of code in the link you've provided, but they did work.

What I did was change this line 

 db.WblockCloneObjects(idc, db.LayoutDictionaryId, im, DuplicateRecordCloning.MangleName, False)


 db.WblockCloneObjects(idc, db.LayoutDictionaryId, im, DuplicateRecordCloning.Ignore, False)

as the post suggested and it works! No more error warning we I save the drawing.



Sorry for the late reply. 


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.