/***************************************************/ /**** Private methods ****/ /***************************************************/ private bool CreateObject(Loadcase bhLoadCase) { int err; int loadCaseId = bhLoadCase.Number; int loadCaseCount = 0; int uID = 1; err = St7.St7GetNumLoadCase(uID, ref loadCaseCount); if (loadCaseCount < loadCaseId) { err = St7.St7NewLoadCase(uID, bhLoadCase.Name); if (!St7ErrorCustom(err, "Could not create a load case number " + loadCaseId)) { return(false); } } else // updating { StringBuilder currentLoadCaseName = new StringBuilder(St7.kMaxStrLen); err = St7.St7GetLoadCaseName(uID, loadCaseId, currentLoadCaseName, St7.kMaxStrLen); if (!String.Equals(currentLoadCaseName.ToString(), bhLoadCase.Name, StringComparison.OrdinalIgnoreCase)) { err = St7.St7SetLoadCaseName(uID, loadCaseId, bhLoadCase.Name); if (!St7ErrorCustom(err, "Could not update a load case number " + loadCaseId)) { return(false); } } } err = St7.St7SetLoadCaseType(uID, loadCaseId, St7LoadCaseTypeFromNature(bhLoadCase.Nature)); err = St7.St7EnableLSALoadCase(uID, loadCaseId, 1); return(true); }
private List <Loadcase> ReadLoadcase(List <string> ids = null) { List <Loadcase> loadCases = new List <Loadcase>(); int err = 0; int loadCaseCount = 0; err = St7.St7GetNumLoadCase(1, ref loadCaseCount); if (!St7ErrorCustom(err, "Could not get loadcases")) { return(loadCases); } for (int ldCs = 1; ldCs <= loadCaseCount; ldCs++) { StringBuilder loadCaseName = new StringBuilder(St7.kMaxStrLen); err = St7.St7GetLoadCaseName(1, ldCs, loadCaseName, St7.kMaxStrLen); if (!St7ErrorCustom(err, "Could not get a name of loadcase " + ldCs)) { continue; } int caseType = 0; err = St7.St7GetLoadCaseType(1, ldCs, ref caseType); if (!St7ErrorCustom(err, "Could not get a type of loadcase " + ldCs)) { continue; } Loadcase ldcase = null; if (caseType == St7.lcNoInertia) { ldcase = BH.Engine.Structure.Create.Loadcase(loadCaseName.ToString(), ldCs); } else if (caseType == St7.lcAccelerations) { ldcase = BH.Engine.Structure.Create.Loadcase(loadCaseName.ToString(), ldCs, LoadNature.Notional); } else if (caseType == St7.lcSeismic) { ldcase = BH.Engine.Structure.Create.Loadcase(loadCaseName.ToString(), ldCs, LoadNature.Seismic); } else if (caseType == St7.lcGravity) { ldcase = BH.Engine.Structure.Create.Loadcase(loadCaseName.ToString(), ldCs, LoadNature.Dead); } else { BHError("Load Type is not supported"); } if (!(ldcase is null)) { SetAdapterId(ldcase, ldCs); ldcase.Number = ldCs; loadCases.Add(ldcase); } } return(loadCases); }
/***************************************************/ /**** Adapter overload method ****/ /***************************************************/ // Method that returns the next free index for a specific object type as 'object'. // 'object' is required as ID is software specific (could be int, string, Guid or anything else). // NextId is called in the base Adapter Push method, just before the call to Create(); // it follows that at the point of index assignment, the objects have not yet been created in the target software. // This is to ensure that the object exported in the software will have the the ID that we decided here. protected override object NextFreeId(Type objectType, bool refresh = false) { //Change from object to what the specific software is using int index = 1; int uID = 1; if (!refresh && m_indexDict.TryGetValue(objectType, out index)) { index++; } else if (objectType == typeof(Loadcase)) { int err = 0; int loadCaseCount = 0; err = St7.St7GetNumLoadCase(uID, ref loadCaseCount); // check if it is default loadcase and override it if (loadCaseCount == 1) { StringBuilder loadCaseName = new StringBuilder(St7.kMaxStrLen); err = St7.St7GetLoadCaseName(1, 1, loadCaseName, St7.kMaxStrLen); if (loadCaseName.ToString() == "Load Case 1") { loadCaseCount = 0; } } if (St7Error(err)) { index = loadCaseCount + 1; } } else if (objectType == typeof(Node)) { int err = 0; int nodeCount = 0; err = St7.St7GetTotal(uID, St7.tyNODE, ref nodeCount); if (St7Error(err)) { index = nodeCount + 1; } } else if (objectType == typeof(St7RigidMPLink)) { int err = 0; int linkCount = 0; err = St7.St7GetTotal(uID, St7.tyLINK, ref linkCount); if (St7Error(err)) { index = linkCount + 1; } } else if (objectType == typeof(LoadCombination)) { int err = 0; int loadComboCount = 0; err = St7.St7GetNumLSACombinations(uID, ref loadComboCount); if (St7Error(err)) { index = loadComboCount + 1; } } else if (objectType == typeof(Bar)) { int err = 0; int beamCount = 0; err = St7.St7GetTotal(uID, St7.tyBEAM, ref beamCount); if (St7Error(err)) { index = beamCount + 1; } } else if (typeof(IAreaElement).IsAssignableFrom(objectType)) { int err = 0; int plateCount = 0; err = St7.St7GetTotal(uID, St7.tyPLATE, ref plateCount); if (St7Error(err)) { index = plateCount + 1; } } else if (typeof(IFace).IsAssignableFrom(objectType)) { int err = 0; int plateCount = 0; err = St7.St7GetTotal(uID, St7.tyPLATE, ref plateCount); if (St7Error(err)) { index = plateCount + 1; } } else if (typeof(ISectionProperty).IsAssignableFrom(objectType)) { int err = 0; int[] propCount = new int[St7.kMaxEntityTotals - 1]; int[] propLastNumbers = new int[St7.kMaxEntityTotals - 1]; err = St7.St7GetTotalProperties(uID, propCount, propLastNumbers); if (St7Error(err)) { index = propLastNumbers[St7.ipBeamPropTotal] + 1; } } else if (typeof(ISurfaceProperty).IsAssignableFrom(objectType)) { int err = 0; int[] propCount = new int[St7.kMaxEntityTotals - 1]; int[] propLastNumbers = new int[St7.kMaxEntityTotals - 1]; err = St7.St7GetTotalProperties(uID, propCount, propLastNumbers); if (St7Error(err)) { index = propLastNumbers[St7.ipPlatePropTotal] + 1; } } m_indexDict[objectType] = index; return(index); }