The following code work to rotate a point 90 degrees from a basepoint lying 100 units south of the selected point. When done in a drawing conatining a surface which is defined by said point, and that surface is set to auto-rebuild, the surface rebuilds right away, but the cogopoint still displays in the original postion. A REGEN forces the point to actually display in it's new location. I don't want to force a REGEN, how can I get the display to update?
[CommandMethod("PtTransform")] public void PtTransformcommand() { Document doc = Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; Database db = doc.Database; PromptEntityOptions entOpts = new PromptEntityOptions("\nSelect CogoPoint:"); entOpts.SetRejectMessage("...not a CogoPoint, try again."); entOpts.AddAllowedClass(typeof(CogoPoint), false); PromptEntityResult entRes = ed.GetEntity(entOpts); if (entRes.Status != PromptStatus.OK) return; using (Transaction tr = db.TransactionManager.StartTransaction()) { CogoPoint point = (CogoPoint)entRes.ObjectId.GetObject(OpenMode.ForWrite); Point3d basePoint = new Point3d(point.Location.X, point.Location.Y - 100, 0); double rotationAngle = Math.PI * 0.5; //rotate 90 degrees double currentMarkerRotation = point.MarkerRotation; Matrix3d UCSmatrix = Application.DocumentManager.MdiActiveDocument.Editor.CurrentUserCoordinateSystem; CoordinateSystem3d curUCS = UCSmatrix.CoordinateSystem3d; point.TransformBy(Matrix3d.Rotation(rotationAngle, curUCS.Zaxis, basePoint)); point.MarkerRotation = currentMarkerRotation; tr.Commit(); db.TransactionManager.QueueForGraphicsFlush(); } }
Hi Jeff,
You could try two things here :
1. Call FlushGraphics() after the QueueForGraphicsFlush() call.
2. Try using UpdateScreen() [ from Application or Editor ].
Hope this helps.
Thanks,
Partha
Thanks, Partha. I should've mentioned I've tried all kinds of combinations using the QueueForGraphicsFlush(), FlushGraphics(), and UpdateScreen(). All attempts with any one, or all, of these results in the same problem, the point does not display correctly until I manually Regen.
Hi Jeff,
Just an update : I could repro the issue and saw only by Regen I could resolve it, however you wanted to avoid Regen; I will check with on that later if anyother path exists.
Thanks,
Partha
I have logged an API wish list to update the API so that CogoPoint.TransformBy() also redraws the Point after updating the location.
Till it is addressed, let's use Regen().
Thanks,
Partha
For anyone else running into this, I can get the CogoPoint object to update immediately by using the COM "Update" method via Reflection:
pt.AcadObject.GetType().InvokeMember("Update", System.Reflection.BindingFlags.InvokeMethod, null, pt.AcadObject, null);
I'm not sure how other objects behave, but would it be better to have an update method on the points so that you could call it when you want, rather than any update causing the point to regen?