What is the correct way of copying an existing viewport, What I am actually doing is that to clone a layout by copying what is inside it, everything works smoothly except for the viewports. I tried to use the clone method, but it didn't work, I also tried to use the copyfrom method but also to no avail. In both cases the copied viewport is a dumb black rectangle
Dim exkeyvport As Autodesk.AutoCAD.DatabaseServices.Viewport = DirectCast(acTrans.GetObject(objId, OpenMode.ForRead), Autodesk.AutoCAD.DatabaseServices.Viewport)
Dim keyvport As New Autodesk.AutoCAD.DatabaseServices.Viewport
keyvport.CopyFrom(exkeyvport)
keyvport.UpdateDisplay()
NewblkTableRec.AppendEntity(keyvport)
acTrans.AddNewlyCreatedDBObject(keyvport, True)
The only way that partially worked for me was to create a viewport and copy its attributes one by one, but this is exhaustive and not reliable, so could anyone tell us of the proper way to copy a viewport?
for others who are interested on the details on how to perform the deepclone here is the code: objid refers to the viewport object id
If (objId.ObjectClass.DxfName.ToUpper = "VIEWPORT") Then
Dim id As ObjectId = newLayout.BlockTableRecordId
Dim idcol As New ObjectIdCollection
idcol.Add(objId)
Dim idmap As New IdMapping
acCurdb.DeepCloneObjects(idcol, acCurdb.CurrentSpaceId, idmap, False)
End if