I am copying objects to a new database and and cloning as an Entity type succesfully for all objects.
When I save the database to a new file I get the attached error
'Warning: An error occurred during save....'
I have isolated this to Polylines and have tried to Process as Type PolyLine but still get the error.
Here is the code I use for the polyline.
(My entity processing code is identical except for object type).
Dim MyPolyLine As DatabaseServices.Polyline MyPolyLine = CType(myObjID.GetObject(DatabaseServices.OpenMode.ForRead), _ DatabaseServices.Polyline) Dim NewEntity As DatabaseServices.Polyline = CType(MyPolyLine.Clone, _ DatabaseServices.Polyline) NewEntity.SetDatabaseDefaults(NewDB) NewBTR.AppendEntity(NewEntity) NewTrans.AddNewlyCreatedDBObject(NewEntity, True) NewEntity.Layer = MyPolyLine.Layer NewEntity.Linetype = "ByLayer" NewEntity.Material = "ByLayer"
Thanks
Martin
Solved! Go to Solution.
Solved by StephenPreston. Go to Solution.
Using Clone to copy objects is dangerous - it performs a shallow clone of the entity. I suggest you use Database.WblockCloneObjects or Database.DeepcloneObjects (depending on whether you're copying between databases or between them).
Thanks Stephen
The Database.WblockCloneObjects method was the one I needed.
Certainly removed my problem and simplified my code.
No longer needed to manage layers and BlockReferences need no additional handling.
Thanks again
Martin