This is the routine that i use to insert a generic entity and work fine also
with polyline
Ciao
GPaolo
Public Shared Function HmInsEnt(ByRef Entity As AcDb.Entity, _
Optional ByRef Color As String = "-1", _
Optional ByRef Layer As String = "-1", _
Optional ByVal LineType As String = "-1") As AcDb.ObjectId
Dim Ed As AcEd.Editor = Editor
Dim db As AcDb.Database = Database
Dim tm As DBTransMan = TransactionManager
Dim myT As AcDb.Transaction = tm.StartTransaction
Dim objId As AcDb.ObjectId = Nothing
Try
Dim bt As AcDb.BlockTable = myT.GetObject(db.BlockTableId,
AcDb.OpenMode.ForRead, False)
AcAs.Application.DocumentManager.MdiActiveDocument.LockDocument(AcAs.Documen
tLockMode.AutoWrite, Nothing, Nothing, True)
Dim btr As AcDb.BlockTableRecord =
myT.GetObject(bt(AcDb.BlockTableRecord.ModelSpace), _
AcDb.OpenMode.ForWrite, False)
If Color <> "-1" Then
Entity.ColorIndex = Color
End If
If Layer <> "-1" Then
Entity.Layer = Layer
End If
If LineType <> "-1" Then
Select Case Entity.GetType.Name.ToUpper
Case "DBTEXT", "MTEXT"
Case Else
Entity.Linetype = LineType
End Select
End If
objId = btr.AppendEntity(Entity)
tm.AddNewlyCreatedDBObject(Entity, True)
myT.Commit()
Return objId
Catch ex As Exception
Return Nothing
Finally
myT.Dispose()
AcAs.Application.DocumentManager.MdiActiveDocument.LockDocument.Dispose()
End Try
End Function
ha scritto nel messaggio news:5365319@discussion.autodesk.com...
Get ObjectId of the PolyLine that I just create!
This code shows me this Error: FATAL ERROR: Unhandled e0434f4dh Exception
at 7c812a5bh
I want to get "my3dPoly" objectid, it's the object that I just create by
this code...
private ObjectIdDrawPoly(Polyline3d my3dPoly)
{
Database db = HostApplicationServices.WorkingDatabase;
Autodesk.AutoCAD.DatabaseServices.TransactionManager transMgr =
db.TransactionManager;
Transaction trans = transMgr.StartTransaction();
try
{
BlockTableRecord btr =
(BlockTableRecord)trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
btr.AppendEntity(my3dPoly);
trans.AddNewlyCreatedDBObject(my3dPoly, true);
trans.Commit();
}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{ ed.WriteMessage("Error Message: " + ex.Message); }
finally
{ if (my3dPoly != null) my3dPoly.Dispose(); }
//--> Error is Here!!!
return my3dPoly.ObjectId;
}
Thank You For Your Help,
Babak