public void Edit_AddLoadCase() { // Launch SAP2000v16 and Open a blank model string filePath = @"C:\Users\eertugrul\Documents\GitHub\DynamoSAP\packages\DynamoSAP\extra\2a_Dome.sdb"; //Create SAP2000 Object SapObject mySapObject = new SAP2000v16.SapObject(); //Start Application mySapObject.ApplicationStart(); //Create SapModel object cSapModel mySapModel = mySapObject.SapModel; mySapModel.InitializeNewModel(); mySapModel.File.OpenFile(filePath); //Open and Run the sample file OpenAndRunDynamoDefinition(@".\Sample_4b_Read_Edit_AddLoadCase.dyn"); // Test Logic is here ---> //check for errors and assert accordingly string failreport = CompileErrorsIntoString(); // Set SAP instances to null; mySapObject.ApplicationExit(false); mySapObject = null; mySapModel = null; if (string.IsNullOrEmpty(failreport)) { Assert.Pass(); } else { Assert.Fail(failreport); } }
public static void InitializeSapModel(ref SapObject mySAPObject, ref cSapModel mySapModel, string units) { long ret = 0; //TO DO: Grab open Instance if already open!!! //Create SAP2000 Object mySAPObject = new SAP2000v16.SapObject(); // get enum from Units eUnits Units = (eUnits)Enum.Parse(typeof(eUnits), units); //Start Application mySAPObject.ApplicationStart(Units, true); //Create SapModel object mySapModel = mySAPObject.SapModel; //initialize the model ret = mySapModel.InitializeNewModel(Units); //create new blank model ret = mySapModel.File.NewBlank(); //SET UP ... SET UP ... SET UP ... SET UP DefineMaterials(ref mySapModel); }
public void ReadStructure_Frame() { // Launch SAP2000v16 and Open a blank model string filePath = @"C:\Users\eertugrul\Documents\GitHub\DynamoSAP\packages\DynamoSAP\extra\2a_Dome.sdb"; //Create SAP2000 Object SapObject mySapObject = new SAP2000v16.SapObject(); //Start Application mySapObject.ApplicationStart(); //Create SapModel object cSapModel mySapModel = mySapObject.SapModel; mySapModel.InitializeNewModel(); mySapModel.File.OpenFile(filePath); //Open and Run the sample file OpenAndRunDynamoDefinition(@".\Sample_2a_Read_Dome+DecomposeSapModel.dyn"); // Test Logic is here ---> string failreport = string.Empty; // Check Node Read SAp Model if (IsNodeInErrorOrWarningState("966718c2-c618-46b8-b631-c43a54c669ff")) { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Read.SAPModel" + "' failed or threw a warning."); } // Check Node Structural Model Decompose if (IsNodeInErrorOrWarningState("36b32253-13f6-47ab-9bef-69b45c688c5b")) { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "StructuralModel.Decompose" + "' failed or threw a warning."); } // Check Node Frame Decompose if (IsNodeInErrorOrWarningState("b5e32685-6c44-443b-bc6c-c91a051cc541")) { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Frame.Decompose" + "' failed or threw a warning."); } // Check Node SectionProp.Decompose if (IsNodeInErrorOrWarningState("6bdba7f9-4de1-475e-8868-815d93b99bf6")) { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "SectionProp.Decompose" + "' failed or threw a warning."); } // Set SAP instances to null; mySapObject.ApplicationExit(false); mySapObject = null; mySapModel = null; if (!string.IsNullOrEmpty(failreport)) { Assert.Fail(failreport); } //if we got here, nothing failed. Assert.Pass(); }
public void ReadStructure_Shell() { // Launch SAP2000v16 and Open a blank model string filePath = @"C:\Users\eertugrul\Documents\GitHub\DynamoSAP\packages\DynamoSAP\extra\2b_SimpleShellStructure.sdb"; //Create SAP2000 Object SapObject mySapObject = new SAP2000v16.SapObject(); //Start Application mySapObject.ApplicationStart(); //Create SapModel object cSapModel mySapModel = mySapObject.SapModel; mySapModel.InitializeNewModel(); mySapModel.File.OpenFile(filePath); //Open and Run the sample file OpenAndRunDynamoDefinition(@".\Sample_2b_Read_Shell+DecomposeSapModel.dyn"); // Test Logic is here ---> string failreport = string.Empty; // Check Node Read SAp Model if (IsNodeInErrorOrWarningState("966718c2-c618-46b8-b631-c43a54c669ff")) { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Read.SAPModel" + "' failed or threw a warning."); } // Check Node Structural Model Decompose if (IsNodeInErrorOrWarningState("36b32253-13f6-47ab-9bef-69b45c688c5b")) { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "StructuralModel.Decompose" + "' failed or threw a warning."); } // Check Node Shell Decompose if (IsNodeInErrorOrWarningState("c6ec73e3-9413-4464-b827-a4195d68c727")) { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Frame.Decompose" + "' failed or threw a warning."); } // Check Node ShellProp.Decompose if (IsNodeInErrorOrWarningState("398af6ae-6adc-4f34-83f0-ef85184f37bb")) { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "ShellProp.Decompose" + "' failed or threw a warning."); } // Set SAP instances to null; mySapObject.ApplicationExit(false); mySapObject = null; mySapModel = null; if (!string.IsNullOrEmpty(failreport)) { Assert.Fail(failreport); } //if we got here, nothing failed. Assert.Pass(); }
public static void OpenSAPModel(string filePath, ref cSapModel mySapModel, ref string units) { long ret = 0; //Create SAP2000 Object SapObject mySAPObject = new SAP2000v16.SapObject(); //Start Application mySAPObject.ApplicationStart(); //Create SapModel object mySapModel = mySAPObject.SapModel; ret = mySapModel.InitializeNewModel(); ret = mySapModel.File.OpenFile(filePath); units = mySapModel.GetPresentUnits().ToString(); }
/// <summary> /// Initializes a new instance of the <see cref="CSiApiSeed"/> class. /// </summary> /// <param name="sapObject">The sap object.</param> /// <param name="sapModel">The sap model.</param> public CSiApiBaseSeed(SapObject sapObject, cSapModel sapModel) { SapObject = sapObject; SapModel = sapModel; }
// Create or Update Sap Model from a Dynamo Model private static void CreateorUpdateSAPModel(ref StructuralModel StructuralModel, string Units, double SF, bool delete) { string error = string.Empty; //1. INSTANTIATE NEW OR GRAB OPEN SAPMODEL // check if any SAP file is open, grab SAP2000v16.SapObject mySapObject = null; string ModelUnits = string.Empty; // Open & instantiate SAP file Initialize.GrabOpenSAP(ref mySapModel, ref ModelUnits, Units); if (mySapModel == null) { // Open a blank SAP Model try { SAPConnection.Initialize.InitializeSapModel(ref mySapObject, ref mySapModel, Units); } catch (Exception) { SAPConnection.Initialize.Release(ref mySapObject, ref mySapModel); }; } //2. Create or Update Frames (Sets Releases) // 2.a. Harvest the elements from SAP Model SAPConnection.StructureMapper.GetSAPFrameList(ref mySapModel, ref SAPFrmList); // frms SAPConnection.StructureMapper.GetSAPAreaList(ref mySapModel, ref SAPAreaList); // areas SAPConnection.StructureMapper.GetSAPJointList(ref mySapModel, ref SAPJointList); // joints // 2a. DELETE if (delete) { //Delete Frms from SAP not in Structural elements foreach (var sapfrm in SAPFrmList) { Element el = null; try { el = (from f in StructuralModel.StructuralElements where f.Label == sapfrm && f.Type == Structure.Type.Frame select f).First(); } catch (Exception) { } if (el == null) // not in Dynamo Structure so delete from SAP Model { SAPConnection.StructureMapper.DeleteFrm(ref mySapModel, sapfrm); } } // Delete Areas from SAP not in Structural elements foreach (var sapArea in SAPAreaList) { //Element el = null; //try //{ // el = (from f in StructuralModel.StructuralElements // where f.Label == sapArea // select f).First(); //} //catch (Exception) { } //if (el == null) //{ SAPConnection.StructureMapper.DeleteArea(ref mySapModel, sapArea, ref error); if (error != string.Empty) { report.Add(error); error = string.Empty; } //} } // Delete Joints from SAP not in Structural elements foreach (var sapJoint in SAPJointList) { Element el = null; try { el = (from f in StructuralModel.StructuralElements where f.Label == sapJoint && f.Type == Structure.Type.Joint select f).First(); } catch (Exception) { } if (el == null && sapJoint.StartsWith("dyn")) // not in Dynamo Structure so delete from SAP Model { SAPConnection.StructureMapper.DeleteJoint(ref mySapModel, sapJoint, ref error); if (error != string.Empty) { report.Add(error); error = string.Empty; } } } } //2. CREATE OR UPDATE SIMULTENOUSLY //2.b. Create or Update foreach (var el in StructuralModel.StructuralElements) { if (el.Type == Structure.Type.Frame) { bool isupdate = SAPFrmList.Contains(el.Label); CreateorUpdateFrame(el as Frame, ref mySapModel, SF, isupdate); Frame frm = el as Frame; // Set Releases if (frm.Releases != null) { SetReleases(el as Frame, ref mySapModel); // Set releases } } else if (el.Type == Structure.Type.Shell) { bool isupdate = SAPAreaList.Contains(el.Label); CreateorUpdateArea(el as Shell, ref mySapModel, SF, false); } else if (el.Type == Structure.Type.Joint) { bool isupdate = SAPJointList.Contains(el.Label); CreateorUpdateJoint(el as Joint, ref mySapModel, SF, isupdate); } } // LinqInquiry List <Definition> LPatterns = new List <Definition>(); try { LPatterns = (from def in StructuralModel.ModelDefinitions where def.Type == Definitions.Type.LoadPattern select def).ToList(); } catch (Exception) { } // Add Load Patterns to the SAP Model if (LPatterns.Count > 0) { foreach (LoadPattern lp in LPatterns) { //Call the AddLoadPattern method SAPConnection.LoadMapper.AddLoadPattern(ref mySapModel, lp.name, lp.type, lp.multiplier); } } List <Definition> LCases = new List <Definition>(); try { LCases = (from def in StructuralModel.ModelDefinitions where def.Type == Definitions.Type.LoadCase select def).ToList(); } catch { } if (LCases.Count > 0) { foreach (LoadCase lc in LCases) { List <string> types = new List <string>(); List <string> names = new List <string>(); List <double> SFs = new List <double>(); for (int i = 0; i < lc.loadPatterns.Count; i++) { types.Add("Load"); names.Add(lc.loadPatterns[i].name); SFs.Add(lc.sFs[i]); } string[] Dtypes = types.ToArray(); string[] Dnames = names.ToArray(); double[] DSFs = SFs.ToArray(); SAPConnection.LoadMapper.AddLoadCase(ref mySapModel, lc.name, types.Count(), ref Dtypes, ref Dnames, ref DSFs, lc.type); } } List <Definition> LCombo = new List <Definition>(); try { LCombo = (from def in StructuralModel.ModelDefinitions where def.Type == Definitions.Type.LoadCombo select def).ToList(); } catch { } if (LCombo.Count > 0) { foreach (LoadCombo lc in LCombo) { List <string> types = new List <string>(); List <string> names = new List <string>(); List <double> SFs = new List <double>(); for (int i = 0; i < lc.loadDefinitions.Count; i++) { if (lc.loadDefinitions[i].Type == Definitions.Type.LoadCase) { types.Add("LoadCase"); names.Add(((LoadCase)lc.loadDefinitions[i]).name); } else if (lc.loadDefinitions[i].Type == Definitions.Type.LoadCombo) { types.Add("LoadCombo"); names.Add(((LoadCombo)lc.loadDefinitions[i]).name); } SFs.Add(lc.sFs[i]); } string[] Dtypes = types.ToArray(); string[] Dnames = names.ToArray(); double[] DSFs = SFs.ToArray(); SAPConnection.LoadMapper.AddLoadCombo(ref mySapModel, lc.name, Dtypes, Dnames, DSFs, lc.type); } } // Set Loads foreach (var el in StructuralModel.StructuralElements) { if (el.Type == Structure.Type.Frame) { Frame frm = el as Frame; // Set Loads if (frm.Loads != null) { SetLoads(el as Frame, ref mySapModel); } } } // Create or Update Groups // Harvest the names of the groups// delete the ones not in the SAP Model SAPConnection.GroupMapper.GetSAPGroupList(ref mySapModel, ref SAPGroupList); List <Definition> Groups = new List <Definition>(); try { Groups = (from def in StructuralModel.ModelDefinitions where def.Type == Definitions.Type.Group select def).ToList(); } catch (Exception) { } // Update or Create new one and set assignments List <string> tempNames = new List <string>(); if (Groups.Count > 0) { foreach (Group g in Groups) { tempNames.Add(g.Name); bool update = false; if (SAPGroupList.Contains(g.Name)) { update = true; } CreateorUpdateGroup(g, ref mySapModel, update); } } if (delete) { foreach (var g in SAPGroupList) { // Delete from SAP Model if (!tempNames.Contains(g)) { SAPConnection.GroupMapper.Delete(ref mySapModel, g); } } } // refresh View //SAPConnection.StructureMapper.RefreshView(ref mySapModel); // Delete unconnected points at the SAP SAPConnection.StructureMapper.DeleteUnconnectedPts(ref mySapModel); // refresh View SAPConnection.StructureMapper.RefreshView(ref mySapModel); //if can't set to null, will be a hanging process mySapModel = null; mySapObject = null; }
/// <summary> /// Initializes a new instance of the <see cref="CSiApiBase" /> class. /// </summary> /// <param name="seed">The seed.</param> public CSiApiBase(CSiApiSeed seed) { _sapObject = seed.SapObject; _sapModel = seed.SapModel; }
/// <summary> /// Initializes a new instance of the <see cref="CSiApiBase" /> class. /// </summary> /// <param name="sapObject">The sap object.</param> /// <param name="sapModel">The sap model.</param> public CSiApiBase(cOAPI sapObject, cSapModel sapModel) { _sapObject = sapObject; _sapModel = sapModel; }
/// <summary> /// Initializes a new instance of the <see cref="CSiApiBase"/> class. /// </summary> /// <param name="sapObject">The sap object.</param> /// <param name="sapModel">The sap model.</param> public CSiApiBase(SAP2000v16.SapObject sapObject, cSapModel sapModel) { _sapObject = sapObject; _sapModel = sapModel; }
public void RunAnalysis() { // Launch SAP2000v16 and Open a blank model string filePath = @"C:\Users\eertugrul\Documents\GitHub\DynamoSAP\packages\DynamoSAP\extra\3a_RunAnalysis.sdb"; //Create SAP2000 Object SapObject mySapObject = new SAP2000v16.SapObject(); //Start Application mySapObject.ApplicationStart(); //Create SapModel object cSapModel mySapModel = mySapObject.SapModel; mySapModel.InitializeNewModel(); mySapModel.File.OpenFile(filePath); //Open and Run the sample file OpenAndRunDynamoDefinition(@".\Sample_3a_RunAnalysis_ReadResults.dyn"); // Test Logic is here ---> string failreport = string.Empty; // Check Node Run Analysis if (IsNodeInErrorOrWarningState("b24e8e64-0cc1-43a1-a98c-3bfcf4f9099e")) { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Analysis.Run" + "' failed or threw a warning."); } // Check Node StructuralModel.Decompose if (IsNodeInErrorOrWarningState("79d1b8d0-0bb8-498b-b40b-cc5de1b168b7")) { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "StructuralModel.Decompose" + "' failed or threw a warning."); } // Check Node Frame.DisplayLoads if (IsNodeInErrorOrWarningState("6ba73349-8d06-4f1f-ba4f-d3d23f59bba4")) { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Frame.DisplayLoads" + "' failed or threw a warning."); } // Check Node Analysis.GetResults if (IsNodeInErrorOrWarningState("39d253c0-b3fc-4e82-9c74-5e645578bab3")) { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Analysis.GetResults" + "' failed or threw a warning."); } // Check dropdown Force Type var forceType = (string)GetPreviewValue("a1a18410-1bf5-4492-8bad-40faee974fe9"); if (forceType != "Axial") failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Force Type Dropdown" + "' returns wrong value !"); // Check Node Analysis.Decomposeresults if (IsNodeInErrorOrWarningState("80e7a42a-1418-471f-b368-551fd3752e8d")) { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Analysis.DecomposeResults" + "' failed or threw a warning."); } // Check Node Analysis.VisualizeResults if (IsNodeInErrorOrWarningState("982cd2d8-aa2a-473b-9d6b-ed6f11ed29c4")) { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Analysis.VisualizeResults" + "' failed or threw a warning."); } // Set SAP instances to null; mySapObject.ApplicationExit(false); mySapObject = null; mySapModel = null; if (!string.IsNullOrEmpty(failreport)) { Assert.Fail(failreport); } //if we got here, nothing failed. Assert.Pass(); }
public void RunAnalysis() { // Launch SAP2000v16 and Open a blank model string filePath = @"C:\Users\eertugrul\Documents\GitHub\DynamoSAP\packages\DynamoSAP\extra\3a_RunAnalysis.sdb"; //Create SAP2000 Object SapObject mySapObject = new SAP2000v16.SapObject(); //Start Application mySapObject.ApplicationStart(); //Create SapModel object cSapModel mySapModel = mySapObject.SapModel; mySapModel.InitializeNewModel(); mySapModel.File.OpenFile(filePath); //Open and Run the sample file OpenAndRunDynamoDefinition(@".\Sample_3a_RunAnalysis_ReadResults.dyn"); // Test Logic is here ---> string failreport = string.Empty; // Check Node Run Analysis if (IsNodeInErrorOrWarningState("b24e8e64-0cc1-43a1-a98c-3bfcf4f9099e")) { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Analysis.Run" + "' failed or threw a warning."); } // Check Node StructuralModel.Decompose if (IsNodeInErrorOrWarningState("79d1b8d0-0bb8-498b-b40b-cc5de1b168b7")) { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "StructuralModel.Decompose" + "' failed or threw a warning."); } // Check Node Frame.DisplayLoads if (IsNodeInErrorOrWarningState("6ba73349-8d06-4f1f-ba4f-d3d23f59bba4")) { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Frame.DisplayLoads" + "' failed or threw a warning."); } // Check Node Analysis.GetResults if (IsNodeInErrorOrWarningState("39d253c0-b3fc-4e82-9c74-5e645578bab3")) { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Analysis.GetResults" + "' failed or threw a warning."); } // Check dropdown Force Type var forceType = (string)GetPreviewValue("a1a18410-1bf5-4492-8bad-40faee974fe9"); if (forceType != "Axial") { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Force Type Dropdown" + "' returns wrong value !"); } // Check Node Analysis.Decomposeresults if (IsNodeInErrorOrWarningState("80e7a42a-1418-471f-b368-551fd3752e8d")) { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Analysis.DecomposeResults" + "' failed or threw a warning."); } // Check Node Analysis.VisualizeResults if (IsNodeInErrorOrWarningState("982cd2d8-aa2a-473b-9d6b-ed6f11ed29c4")) { failreport = string.Format(failreport + "{0}{1}", Environment.NewLine, "The node called '" + "Analysis.VisualizeResults" + "' failed or threw a warning."); } // Set SAP instances to null; mySapObject.ApplicationExit(false); mySapObject = null; mySapModel = null; if (!string.IsNullOrEmpty(failreport)) { Assert.Fail(failreport); } //if we got here, nothing failed. Assert.Pass(); }