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: 

SetSlope method for BeginAlignment or EndAlignment

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
joantopo
560 Views, 5 Replies

SetSlope method for BeginAlignment or EndAlignment

Hi.

I´m trying to modify slopes for BeginAlignment.

 

This is my code block but it doesn´t anything.

 

  #region peralte inicio alineación y final alineación

            if (variables_globales.peralteTransversal == false)
            {
                //añadimos el peralte para el p.k=0 y para el p.k final si se trata de rectas.

                if (variables_globales.ListaentitiesAlign[0].SubentityType == AlignmentSubEntityType.Line)
                {
                    //abrimos la base de datos por si tenemos que escribir.
                    Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
                    Database db = doc.Database;
                    Editor ed = doc.Editor;

                    using (DocumentLock docLock = doc.LockDocument())
                    {
                        using (Transaction trans = db.TransactionManager.StartTransaction())
                        {
                            Alignment align = trans.GetObject(Id, OpenMode.ForWrite) as Alignment;

                            SuperelevationCriticalStationCollection ColeccionPuntosCriticos = align.SuperelevationCriticalStations;
                            SuperelevationCriticalStation PuntoCritico = null;
                            foreach (SuperelevationCriticalStation puntoCritico in ColeccionPuntosCriticos)
                            {
                                SuperelevationCriticalStationType tipo = SuperelevationCriticalStationType.EndNormalCrown;
                                switch (tipo)
                                {
                                    case SuperelevationCriticalStationType.BeginAlignment:
                                        #region INICIO BOMBEO
                                        double Peralte_Izquierdo = Math.Abs(variables_globales.Bombeo) * (-1);
                                        double Peralte_Derecho = Math.Abs(variables_globales.Bombeo) * (-1);
                                        double PK = 0;

                                        PK = variables_globales.ListaentitiesAlign[0].StartStation;

                                        PuntoCritico = ColeccionPuntosCriticos.GetCriticalStationAt(PK, 0.01);


                                        //siempre dibujaremos el carril exterior izquierdo y el carril exterior derecho.
                                        PuntoCritico.SetSlope(SuperelevationCrossSegmentType.LeftOutLaneCrossSlope, Peralte_Izquierdo / 100);  //CARRIL EXTERIOR IZQUIERDO
                                        PuntoCritico.SetSlope(SuperelevationCrossSegmentType.RightOutLaneCrossSlope, Peralte_Derecho / 100);  //CARRIL EXTERIOR DERECHO

                                        if (variables_globales.TotalCarriles_Izquierda > 1)
                                        {
                                            PuntoCritico.SetSlope(SuperelevationCrossSegmentType.LeftInLaneCrossSlope, Peralte_Izquierdo / 100);  //CARRIL Interior IZQUIERDO
                                        }

                                        if (variables_globales.TotalCarriles_Derecha > 1)
                                        {
                                            PuntoCritico.SetSlope(SuperelevationCrossSegmentType.RightInLaneCrossSlope, Peralte_Derecho / 100);  //CARRIL Interior DERECHO

                                        }

                                        if (variables_globales.Arcen_Exterior == true)
                                        {
                                            PuntoCritico.SetSlope(SuperelevationCrossSegmentType.LeftOutShoulderCrossSlope, Peralte_Izquierdo / 100);  //arcen exterior izquierdo
                                            PuntoCritico.SetSlope(SuperelevationCrossSegmentType.RightOutShoulderCrossSlope, Peralte_Derecho / 100);  //arcen exterior derecho
                                        }

                                        if (variables_globales.Arcen_Interior == true)
                                        {
                                            PuntoCritico.SetSlope(SuperelevationCrossSegmentType.LeftInShoulderCrossSlope, Peralte_Izquierdo / 100);  //arcen interior izquierdo
                                            PuntoCritico.SetSlope(SuperelevationCrossSegmentType.RightInShoulderCrossSlope, Peralte_Derecho / 100);  //arcen interior derecho
                                        }

                                        #endregion

                                        break;
                                }

                            } //end foreach

                        } //end transaction
                    } //end lock

                }
            }
            #endregion

 

variables_globales.ListaentitiesAlign is a list of all subentities of Alignment and I check if the first subentity is a line.

I use switch but you don´t have use it.

 

 

 

 

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
5 REPLIES 5
Message 2 of 6
joantopo
in reply to: joantopo

I have removed "swith" proces.

 

                if (variables_globales.ListaentitiesAlign[0].SubentityType == AlignmentSubEntityType.Line)
                {
                  
                    Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
                    Database db = doc.Database;
                    Editor ed = doc.Editor;

                    using (DocumentLock docLock = doc.LockDocument())
                    {
                        using (Transaction trans = db.TransactionManager.StartTransaction())
                        {
                            Alignment align = trans.GetObject(Id, OpenMode.ForWrite) as Alignment;

                            SuperelevationCriticalStationCollection ColeccionPuntosCriticos = align.SuperelevationCriticalStations;
                            SuperelevationCriticalStation PuntoCritico = null;

                            #region INICIO BOMBEO
                            double Peralte_Izquierdo =-2;
                            double Peralte_Derecho = -2;


                            PuntoCritico = ColeccionPuntosCriticos[0];

                         
                            PuntoCritico.SetSlope(SuperelevationCrossSegmentType.LeftOutLaneCrossSlope, Peralte_Izquierdo / 100);  //CARRIL EXTERIOR IZQUIERDO
                            PuntoCritico.SetSlope(SuperelevationCrossSegmentType.RightOutLaneCrossSlope, Peralte_Derecho / 100);  //CARRIL EXTERIOR DERECHO

                            if (variables_globales.TotalCarriles_Izquierda > 1)
                            {
                                PuntoCritico.SetSlope(SuperelevationCrossSegmentType.LeftInLaneCrossSlope, Peralte_Izquierdo / 100);  //CARRIL Interior IZQUIERDO
                            }

                            #endregion

                        } //end transaction
                    } //end lock

                }
      
     

 

and now I´m using  The first item of the collection:

 PuntoCritico = ColeccionPuntosCriticos[0];

 

But I can´t change slopes for BeginAlignment yet.

 

I need help, I want change slopes for each "crossSegmentType" for "BeginAlignment" type.

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
Message 3 of 6
joantopo
in reply to: joantopo

Sorry, I can change slopes for CrossSegments in BeginAlignment  but when finish Transaction, then  slopes have again the default slopes values.

 

I don ´t understand why happen that.Smiley Frustrated

 

It´s only happen with BeginAlignment or EndAlignment, with other SuperelevationCriticalStation Type I haven´t  any problems.

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
Message 4 of 6
Partha.Sarkar
in reply to: joantopo

Hi,

 

This seems to be working fine for me in Civil 3D 2014 (Win7 - 64 bit).

 

I could set the slope and see the value changed in the view as well.

 

Here is my test code -

 

         

// get the critical station at the start station

             

double startStation = align.StartingStation;

             

SuperelevationCriticalStation scsStartStn = criteriaStationColl.GetCriticalStationAt(startStation, 0.01);

             

double getSlopeValue = scsStartStn.GetSlope(SuperelevationCrossSegmentType.LeftOutLaneCrossSlope);

              scsStartStn.SetSlope(

SuperelevationCrossSegmentType.LeftOutLaneCrossSlope, -0.05);    

 

Does it help ?

 

Thanks,

Partha Sarkar

ADN



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 5 of 6
joantopo
in reply to: Partha.Sarkar

Sorry.

 

I have forgotten the line code "  trans.Commit();" at the end of Transaction process.

 

                      trans.Commit();
                        } //end transaction

 

Now it works fine.

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
Message 6 of 6
hosneyalaa
in reply to: Partha.Sarkar

@Partha.Sarkar  AND @joantopo 

 

Thank you all
I was looking for a solution to this problem
Thanks

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report