Message 1 of 16
Resetting Z Point coordinates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello friends;
I want to set the Z values of all objects in the drawing to 0. But I think there is an error somewhere in this code. It does not give 0 to Z values.
Thanks in advance to the helpful friend.
private void btnMesleki_Click(object sender, EventArgs e)
{
this.Close();
// Aktif belgeyi al
Aapp.Document doc = aCap.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
// Kullanıcıdan nesneleri seçmesini iste
PromptSelectionResult selRes = ed.GetSelection();
if (selRes.Status != PromptStatus.OK)
{
ed.WriteMessage("Seçim iptal edildi veya hatalı.");
return;
}
// Seçilen nesneleri al
using (Transaction trans = db.TransactionManager.StartTransaction())
using (Aapp.DocumentLock docLock = Adoc.LockDocument())
{
SelectionSet selSet = selRes.Value;
foreach (ObjectId objId in selSet.GetObjectIds())
{
Entity ent = trans.GetObject(objId, Adb.OpenMode.ForWrite) as Entity;
if (ent != null)
{
// Z koordinatını sıfırla
ent.TransformBy(Matrix3d.Displacement(new Vector3d(0, 0, -ent.GeometricExtents.MinPoint.Z)));
}
}
// İşlemleri tamamla
trans.Commit();
}
// Ekrana yazı bas
ed.WriteMessage("Seçilen nesnelerin Z koordinatları sıfırlandı.");
}