Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Update point with CogoPoint.TransformBy()

10 REPLIES 10
Reply
Message 1 of 11
Jeff_M
511 Views, 10 Replies

Update point with CogoPoint.TransformBy()

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();
            }
        }

 

Jeff_M, also a frequent Swamper
EESignature
10 REPLIES 10
Message 2 of 11
Partha.Sarkar
in reply to: Jeff_M

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



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 3 of 11
Jeff_M
in reply to: Partha.Sarkar

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.

Jeff_M, also a frequent Swamper
EESignature
Message 4 of 11
Jeff_M
in reply to: Jeff_M

For now I have solved this by adding the line:
ed.Regen();

I would still prefer to have the display updated without a regen.
Jeff_M, also a frequent Swamper
EESignature
Message 5 of 11
Partha.Sarkar
in reply to: Jeff_M

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



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 6 of 11

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



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 7 of 11
Jeff_M
in reply to: Partha.Sarkar

Thank you, Partha!
Jeff_M, also a frequent Swamper
EESignature
Message 8 of 11
Jeff_M
in reply to: Partha.Sarkar

Partha, I'd liketo add to this that changing ANYTHING if the point's display should trigger the redrawing of the point with the new data. If I renumber a point, it does not update the display of the point number until a regen is issued.

Jeff_M, also a frequent Swamper
EESignature
Message 9 of 11
Jeff_M
in reply to: Jeff_M

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);

Jeff_M, also a frequent Swamper
EESignature
Message 10 of 11
andrewpuller3811
in reply to: Jeff_M

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?



If a post provides a fix for your issue, click on "Accept as Solution" to help other users find solutions to problems they might have that are similar to yours.

Andrew Puller
Maitland, NSW, Australia
Windows 10 Enterprise 64bit
Intel core i7 11800 @ 2.30 GHz with 32GB Ram
Civil 3d 2021
Message 11 of 11
Jeff_M
in reply to: andrewpuller3811

Yes, having an Update method is exactly what would be nice. S, using the Reflection code previously posted, I made an Extension Method to do just that.
Jeff_M, also a frequent Swamper
EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report