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: 

How to get RailCantInfo working?

1 REPLY 1
Reply
Message 1 of 2
tassadar747
104 Views, 1 Reply

How to get RailCantInfo working?

Hi, I m looking to extract cant information from a rail alignment and to be able to edit it.

 

I am using a windows form to select an alignment and then a method, then du script procedes to excecute the code and finally export the results in an excel. I am able to get everything I need such as the radius, the curve direction... But when I try with the cant I get : "Operation not valid due to the current state of the object"

 

How can I get cant information?

 

sample of code working

 public ArrayList GetEntities(Alignment al)             
 {
     ArrayList lstEntity = new ArrayList();
     
     foreach (_AcCDb::AlignmentEntity entity in al.Entities)
     {
         lstEntity.Add(entity);
     }
     return lstEntity;
 }          

 

 

sample of code not working

 public ArrayList TEST_cant_RailInfo(Alignment al)           
{
    ArrayList lstTest = new ArrayList();
    ArrayList lstStations = GetStartStations(al);

    
    RailAlignmentInfo railInfo = al.RailAlignmentInfo;
    
    foreach (double stn in lstStations)
        {
            MessageBox.Show(stn.ToString());
            RailCANTInfo railCantInfo = railInfo.GetCantInfoAtStation(stn);    //Operation is not valid due to the current state of the object.
            lstTest.Add(railCantInfo.AppliedCANT);
        }
    

    return lstTest;
}

 

1 REPLY 1
Message 2 of 2
barnag
in reply to: tassadar747

Hi,

It is hard to tell from this code snippet. 

Do you try to read this data within a database transaction? Is it also recomended to check the type of the alignment, before do some rail alignment specific methods on it.

Try to check if you are able to get the stations listed in Alignment's CANTCriticalStaitons property:

https://help.autodesk.com/view/CIV3D/2023/ENU/?guid=2741ca6f-2f92-84d3-3469-d376a572e9a3 

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report