.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Copy PolyLine to new file Error Warning: An error occurred during save...

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Martin60
622 Views, 2 Replies

Copy PolyLine to new file Error Warning: An error occurred during save...

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

 

2 REPLIES 2
Message 2 of 3
StephenPreston
in reply to: Martin60

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).

Cheers,

Stephen Preston
Autodesk Developer Network
Message 3 of 3
Martin60
in reply to: StephenPreston

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost