Salut, peut être que ce bout de code pourra t'être utile:
//--------------------------------------------------------------------------
// Fonction d'insertion du bloc
private static Point3d Insertion(Database db, Editor BarreCommande, ObjectId IdBlocRef)
{
ObjectId IdNewbloc;
Point3d PtbaseEtiq = Point3d.Origin;
Transaction tr = db.TransactionManager.StartTransaction();
BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForWrite);
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[blockTableRecord.ModelSpace], OpenMode.ForWrite);
using (tr)
{
try
{
Point3d Position = new Point3d(0, 0, 0);
BlockReference br = new BlockReference(Position, IdBlocRef);
IdNewbloc = br.ObjectId;
Matrix3d ucsRotation = BarreCommande.CurrentUserCoordinateSystem;
ucsRotation = ucsRotation.PostMultiplyBy(Matrix3d.Displacement(ucsRotation.Translation));
br.TransformBy(ucsRotation);
btr.AppendEntity(br);
tr.AddNewlyCreatedDBObject(br, true);
PromptSelectionResult psr = BarreCommande.SelectLast();
if (psr.Status == PromptStatus.OK)
{
PromptPointResult ppr = BarreCommande.Drag(psr.Value, "\nPoint d'insertion: ", delegate(Point3d pt, ref Matrix3d mat)
{
pt = pt.TransformBy(BarreCommande.CurrentUserCoordinateSystem);
if (Position == pt)
return SamplerStatus.NoChange;
else
{
mat = Matrix3d.Displacement(br.Position.GetVectorTo(pt));
}
return SamplerStatus.OK;
}
);
if (ppr.Status == PromptStatus.OK)
{
Point3d PtWCS_insert = ppr.Value.TransformBy(BarreCommande.CurrentUserCoordinateSystem);
Matrix3d mat = Matrix3d.Displacement(br.Position.GetVectorTo(PtWCS_insert));
br.TransformBy(mat);
PtbaseEtiq = br.Position;
}
}
tr.Commit();
}
catch (System.Exception ex)
{
BarreCommande.WriteMessage("\nErreur!!\n " + ex.Message + "\n");
}
}
return PtbaseEtiq;
}
// FIN FONCTION
//--------------------------------------------------------------------------