Hi guys
I have problem with editing start and end station of Corridor Baseline regions,my code doing change but after the finishing the command the changes will not takeplaces ,Can anyone help
thank
here its my code:
[CommandMethod("CutRegion2")] public void CutRegion2() { Document doc = appy.DocumentManager.MdiActiveDocument; CivilDocument cdoc = CivilApplication.ActiveDocument; Editor ed = appy.DocumentManager.MdiActiveDocument.Editor; Transaction ts = null; PointGroup pg = null; Alignment al = null; using (ts = appy.DocumentManager.MdiActiveDocument.TransactionManager.StartTransaction()) { using (DocumentLock dl = doc.LockDocument()) { PromptEntityOptions opt = null; PromptDoubleOptions odt1 = null; PromptDoubleOptions odt2 = null; SO so = null; bool flag = true; while (flag) { opt = null; so = null; al = null; odt1 = null; odt2 = null; opt = new PromptEntityOptions("\nPlease Select A Corridor"); opt.SetRejectMessage("\n... Error, The Selection Must be Corridor!"); opt.AddAllowedClass(typeof(Corridor), false); PromptEntityResult ent = ed.GetEntity(opt); if (ent.Status != PromptStatus.OK) { flag = false; return; } Corridor cor = (Corridor)ent.ObjectId.GetObject(OpenMode.ForWrite); foreach (Baseline bl in cor.Baselines) { al = ts.GetObject(bl.AlignmentId, OpenMode.ForWrite) as Alignment; foreach (BaselineRegion br in bl.BaselineRegions) { PromptPointOptions ppo = new PromptPointOptions("\nplease, pick a point"); ppo.AllowNone = true; PromptPointResult ppr = ed.GetPoint(ppo); if (ppr.Status != PromptStatus.OK) return; double sta1 =0; double sta2 =0; double off=0; al.StationOffset(ppr.Value.X,ppr.Value.Y,ref Sta1,off); ppo = new PromptPointOptions("\nplease, pick a point"); ppo.AllowNone = true; ppr = ed.GetPoint(ppo); if (ppr.Status != PromptStatus.OK) return; al.StationOffset(ppr.Value.X,ppr.Value.Y,ref Sta2,off); try { br.SartStation(sta1); br.EndStation(sta2); //cor.Rebuild(); } catch (System.Exception ex) { } break; } break; } } } //===================================================================================================== ts.Commit(); } }
Solved! Go to Solution.
Solved by Partha.Sarkar. Go to Solution.
Hi,
You might be selecting values out of range.
Please see the Remarks and Exceptions section for -
BaselineRegion.StartStation and BaselineRegion.EndStation
Instead of tring the update the values in a for each loop, could you try updating for a single BaselineRegion and check if it updates the values correctly ?
Thanks,
Hi,
I have done a quick test now and I can confirm you they are working fine. I have posted a code snippet in our IM DevBlog :
Cheers,
Partha
Hi,
I have done a quick test now and I can confirm you they are working fine. I have posted a code snippet in our IM DevBlog :
Thanks,
Glad to know that !
Cheers,
Partha