Message 1 of 4
GetObject from cloned object not yet in database
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to clone a polyline3d and set all vertices Z to 0.0 and use that one in my program. I don't want to add it to the database, just use it in memory and then dispose it. I know how to access all vertices in a polyline3d that exists in the database using a transaction, but this will not work with my cloned polyline3d in memory. What's the solution?
Here's part of my code:
Dim acDoc As Document = DocumentManager.MdiActiveDocument Dim acCurDb As Database = acDoc.Database Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction() Dim idArray As ObjectId() = sSet.GetObjectIds() For Each id In idArray Dim entity As Entity = acTrans.GetObject(id, OpenMode.ForWrite, True) Select Case entity.GetType().FullName Case "Autodesk.AutoCAD.DatabaseServices.Polyline3d" Dim pl3d As Polyline3d = CType(entity, Polyline3d) dim clonedPl3d as Polyline3d = pl3d.Clone() ' accessing the vertices from the original polyline For Each vId As ObjectId In pl3d Dim vObj As Object = acTrans.GetObject(vId, OpenMode.ForWrite) Dim v3d As PolylineVertex3d = CType(vObj, PolylineVertex3d) v3d.Position = New Point3d(v3d.Position.X, v3d.Position.Y, 0.0) Next ' accessing the vertices from the cloned polyline For Each vId As ObjectId In clonedPl3d Dim vObj As Object = acTrans.GetObject(vId, OpenMode.ForWrite) ' how should this line look like? Dim v3d As PolylineVertex3d = CType(vObj, PolylineVertex3d) v3d.Position = New Point3d(v3d.Position.X, v3d.Position.Y, 0.0) Next clonedPl3d.Dispose() End Select Next End Using