Community
Hello everyone! I try to get position of the selected entity. But acEnt is not containts such methods or properties. What i do wrong?
Thanks!
My C# code:
//C# [CommandMethod("GetCurCoords", CommandFlags.UsePickSet)] public void GetCurCoords() { Editor acEditor = Application.DocumentManager.MdiActiveDocument.Editor; PromptSelectionResult acPSR = acEditor.GetSelection(); Document acDoc = Application.DocumentManager.MdiActiveDocument; Transaction acTrans = acDoc.TransactionManager.StartTransaction(); using (acTrans) { if (acPSR.Value.Count == 1 && acPSR.Status==PromptStatus.OK) { SelectionSet acSSet = acPSR.Value; foreach (SelectedObject acSObj in acSSet) { if (acSObj != null) { Entity acEnt = acTrans.GetObject(acSObj.ObjectId, OpenMode.ForRead) as Entity; if (acEnt != null) { acEnt.// I'm trying to get position } } } acTrans.Commit(); } } }
Hi,
An entity it's a very generic object that can or not have a position propertie, you better try to narrow your selection to specific entities that have a position propertie (DBtext, block references, etc), lines for example doesn't have "a position", just a start and end point. Please try to explain in more datail what is your aim.
Gaston Nunez
Hi,
Try this, not tested:
public Point3dCollection GetCircleCenters() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; Database db = HostApplicationServices.WorkingDatabase(); SelectionSet acSSet = default(SelectionSet); Point3dCollection ret = new Point3dCollection(); using (Transaction acTrans = db.TransactionManager.StartTransaction()) { TypedValue[] acTypValAr = new TypedValue[1]; acTypValAr.SetValue(new TypedValue(DxfCode.Start, "CIRCLE"), 0); SelectionFilter acSelFtr = new SelectionFilter(acTypValAr); PromptSelectionResult acSSPrompt = default(PromptSelectionResult); acSSPrompt = ed.SelectAll(acSelFtr); if (acSSPrompt.Status == PromptStatus.OK) { acSSet = acSSPrompt.Value; int n = acSSet.Count - 1; int i = 0; for (i = 0; i <= n; i++) { Circle circ = acSSet(i).ObjectId.GetObject(OpenMode.ForRead); ret.Add(circ.Center); } } } return ret; }
Gaston Nunez