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: 

Corridor BaseLine Region

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
ebo134
1198 Views, 6 Replies

Corridor BaseLine Region

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

 

6 REPLIES 6
Message 2 of 7
Partha.Sarkar
in reply to: ebo134

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,



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 3 of 7

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

Message 4 of 7
Partha.Sarkar
in reply to: ebo134

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,

 



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 5 of 7
ebo134
in reply to: Partha.Sarkar

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


thank
Message 6 of 7
ebo134
in reply to: ebo134

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.
Message 7 of 7
Partha.Sarkar
in reply to: ebo134

Glad to know that !

 

Cheers,

Partha



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

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

Post to forums  

Rail Community


Autodesk Design & Make Report