Screen update become slow when using GetSplitCurve() with DBObject.HangOverTo()

Screen update become slow when using GetSplitCurve() with DBObject.HangOverTo()

trithuongle
Advocate Advocate
271 Views
2 Replies
Message 1 of 3

Screen update become slow when using GetSplitCurve() with DBObject.HangOverTo()

trithuongle
Advocate
Advocate

Good evening everyone. I have a question.

I have below code to split an original curve into 2 new curves then hangover 1 of them with original curve.

Point3dCollection splitPnts = new Point3dCollection();
                splitPnts.Add(trimPnt);

                using (DBObjectCollection splitCurvs = memCurv.GetSplitCurves(splitPnts))
                {
                    //baseEd.WriteMessage($"\nSplit curves 's number : {splitCurvs.Count}");
                    //baseEd.WriteMessage($"\nSplit curves 's point : X = {splitPnts[0].X} , Y = {splitPnts[0].Y}");

                    //Find closet points  :
                    Point3d cloPnt1 = ((Curve)splitCurvs[0]).GetClosestPointTo(stdPnt, false);
                    Point3d cloPnt2 = ((Curve)splitCurvs[1]).GetClosestPointTo(stdPnt, false);

                    if (cloPnt1.DistanceTo(trimPnt) <= KRTolerance)
                        memCurv.HandOverTo(splitCurvs[1], true, true);
                    else
                        memCurv.HandOverTo(splitCurvs[0], true, true);

                }

The problem is after the command is finish , the original curve is still the same and i have to drag my mouse about 1~2 seconds for screen update .

I tried to use Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView();

But it didn't work . Please help .

Thanks in advance !

 

0 Likes
272 Views
2 Replies
Replies (2)
Message 2 of 3

hippe013
Advisor
Advisor

Is it possible to see your code in its entirety? 

0 Likes
Message 3 of 3

trithuongle
Advocate
Advocate

@hippe013 

Hi , It is ok . I sent it as below .

Now ,  i also put my alternative way to achieve this , but actually i want to finish in the old way with screen update not become slow.

 

        void CmdTE_TrimCurves(Editor baseEd, Transaction baseTr,
                              Curve boCurv, Curve memCurv,
                              Point3dCollection intPnts, Point3d stdPnt)
        {
            //Variable for trim point :
            Point3d trimPnt;

            //Upgrate member curve to 'OpenForWrite'
            memCurv.UpgradeOpen();

            trimPnt = intPnts[0];

            //Find point to trim :
            if (intPnts.Count > 1)
            {
                for (int i = 1; i < intPnts.Count; i++)
                {
                    if (stdPnt.DistanceTo(intPnts[i]) <
                        stdPnt.DistanceTo(trimPnt))
                        trimPnt = intPnts[i];
                }
            }

            #region [Trim curve]
            try
            {
                Point3dCollection splitPnts = new Point3dCollection() { trimPnt };

                using (DBObjectCollection splitCurvs = memCurv.GetSplitCurves(splitPnts))
                {
                    //Find closet points  :
                    Point3d cloPnt = ((Curve)splitCurvs[0]).GetClosestPointTo(stdPnt, false);

                    #region [codes part that seem to make process became slow]
                    ////Trim curve :
                    //if (cloPnt.DistanceTo(trimPnt) <= KRTolerance)
                    //    memCurv.HandOverTo(splitCurvs[1], true, true);
                    //else
                    //    memCurv.HandOverTo(splitCurvs[0], true, true);
                    #endregion

		    #region [My alternative solution for now]
                    Curve retCurv;
                    if (cloPnt.DistanceTo(trimPnt) <= KRTolerance)
                        retCurv = (Curve)splitCurvs[1];
                    else
                        retCurv = (Curve)splitCurvs[0];

                    ObjectId retId;
                    using (Transaction tr = db().TransactionManager.StartTransaction())
                    {
                        retId = AppendEnt(tr, retCurv);
                        tr.Commit();
                    }

                    memCurv.SwapIdWith(retId, true, true);
                    memCurv.Erase();
  		    #endregion
                }
            }

            catch (System.Exception ex)
            {
		ed.WriteMessage($"\nError : {ex.Message}");
                return;
            }
            
            #endregion
        }

Thanks in advance ! 

0 Likes