Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am busy trying to create a load combination in Robot using C# API and visual studio. My code can be seen below:
Structure = Robot.Project.Structure;
CaseCollection = new RobotCaseCollection();
RobotLoadCombination = new RobotCaseCombination();
CaseCollection = Structure.Cases.GetAll();
int loadCombinationNumber = Structure.Cases.FreeNumber;
int loadCaseFactorNumber;
//ULS or SLS condition
if (loadCombination.Condition == "ULS")
{
RobotLoadCombination = Structure.Cases.CreateCombination(loadCombinationNumber, loadCombination.Designation, IRobotCombinationType.I_CBT_ULS, IRobotCaseNature.I_CN_SEISMIC, IRobotCaseAnalizeType.I_CAT_COMB_CODE);
}
else
{ //SLS
RobotLoadCombination = Structure.Cases.CreateCombination(loadCombinationNumber, loadCombination.Designation, IRobotCombinationType.I_CBT_SLS, IRobotCaseNature.I_CN_SEISMIC, IRobotCaseAnalizeType.I_CAT_COMB_CODE);
}
//Assign Load Case Factors to Load combination
CaseCollection = Structure.Cases.GetAll();
foreach (LoadCaseFactor loadCaseFactor in loadCaseFactors)
{
loadCaseFactorNumber = LoadCaseExist(CaseCollection, loadCaseFactor.LoadCaseName); //This is a function to retrieve the exisiting case number
RobotLoadCombination.CaseFactors.New(loadCaseFactorNumber, loadCaseFactor.Factor); //The error occurs here.
}
The above error is showing because RobotLoadCombination is null, as can be seen here:
But it only becomes null after the CreateCombination rule has run.
I have exactly the same line of code in VBA and it runs fine. Am I missing something.
Solved! Go to Solution.