Corridor BaseLine Region

Corridor BaseLine Region

ebo134
Advocate Advocate
2,201 Views
6 Replies
Message 1 of 7

Corridor BaseLine Region

ebo134
Advocate
Advocate

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

 

0 Likes
Accepted solutions (1)
2,202 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable

Hi,

 

You might be selecting values out of range.

 

Please see the Remarks and Exceptions section for -

 

BaselineRegion.StartStation  and BaselineRegion.EndStation

 

http://docs.autodesk.com/CIV3D/2014/ENU/API_Reference_Guide/html/59ca3173-611d-60ca-900c-6481a6d6aac...

 

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,

0 Likes
Message 3 of 7

partha.sarkar
Explorer
Explorer

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 :

 

http://adndevblog.typepad.com/infrastructure/2014/01/updating-civil-3d-corridor-baselineregion-start...

 

Cheers,

Partha

0 Likes
Message 4 of 7

Anonymous
Not applicable
Accepted solution

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 :

 

http://adndevblog.typepad.com/infrastructure/2014/01/updating-civil-3d-corridor-baselineregion-start...

 

Thanks,

 

0 Likes
Message 5 of 7

ebo134
Advocate
Advocate
than you guys, ok put the code in while loop for multiple corridors and test it if it works ?


thank
0 Likes
Message 6 of 7

ebo134
Advocate
Advocate
Iam sorry for my mistakes, I shouldn't interrupt the transaction procedure with return command,therefore I added ts.Commit(); before every return Command within transaction brackets and it solved my problem, thank you guys.
0 Likes
Message 7 of 7

Anonymous
Not applicable

Glad to know that !

 

Cheers,

Partha

0 Likes