/// <summary> /// Run linear structural analysis. /// WIP - Work In Progress /// </summary> /// <param name="AxModel">Model to analyse.</param> /// <param name = "b" > Analysis starts if true. Set this to false while changing geometry, if the structural model is large, since analysis might take a long time.</param> /// <returns>AxModel if successful</returns> /// <search>axisvm, analysis</search> public static AxModel LinearAnalysis(AxModel AxModel, Boolean b = true) { if (b == true) { //todo: turn off results //AXM.AxApp.Visible = ELongBoolean.lbFalse; AxModel.AxModel_.BeginUpdate(); AxModel.AxCalc.LinearAnalysis(ECalculationUserInteraction.cuiNoUserInteractionWithAutoCorrect); AxModel.AxModel_.EndUpdate(); AxModel.AxApp.Visible = ELongBoolean.lbTrue; AxModel.AxApp.BringToFront(); //todo: turn on results return(AxModel); } return(AxModel); }
public static IDictionary PointLoad(AxModel AxModel, List <int> ptID, string lcName = "ST1", double Fx = 0, double Fy = 0, double Fz = -1) { AxModel.AxModel_.BeginUpdate(); // Define Load case int lc = -1; bool exists = false; //load case defined earlier? for (int i = 1; i <= AxModel.AxLoadCases.Count; i++) { if (AxModel.AxLoadCases.Name[i].Equals(lcName)) { exists = true; lc = i; break; } } if (exists == false) { lc = AxModel.AxLoadCases.Add(lcName, ELoadCaseType.lctStandard); } // Add nodal loads RLoadNodalForce ptLoad = new RLoadNodalForce { LoadCaseId = lc }; int prevlcCOunt = AxModel.nodeloadIDs.Count; List <int[]> newNodeloadIDs = new List <int[]>(); // load case and loaded node for (int i = 0; i < ptID.Count; i++) { bool notyet = true; for (int j = 0; j < prevlcCOunt; j++) { if (AxModel.nodeloadIDs[j][0] == lc && AxModel.nodeloadIDs[j][1] == ptID[i]) { notyet = false; break; } } if (notyet) { ptLoad.NodeId = ptID[i]; ptLoad.Fx = Fx; ptLoad.Fy = Fy; ptLoad.Fz = Fz; ptLoad.Mx = 0; ptLoad.My = 0; ptLoad.Mz = 0; ptLoad.ReferenceId = 0; AxModel.AxLoads.AddNodalForce(ptLoad); AxModel.nodeloadIDs.Add(new int[] { lc, ptID[i] }); newNodeloadIDs.Add(new int[] { lc, ptID[i] }); } } AxModel.AxModel_.EndUpdate(); return(new Dictionary <object, object>() { { "AxModel", AxModel }, { "new", newNodeloadIDs }, { "all", AxModel.nodeloadIDs }, }); }
public static IDictionary SendMembers(AxModel AxModel, Boolean b, List <AxMember> axm) { bool propChanged = false; if (b == true) { AxModel.AxModel_.BeginUpdate(); //Create material int[] MatID = new int[axm.Count]; //material ID for each structural member StringComparison sc = StringComparison.CurrentCultureIgnoreCase; for (int i = 0; i < axm.Count; i++) { string Mstr = axm[i].mat; //chcek if this material has already been defined or not bool alreadyDefined = false; for (int j = 0; j < AxModel.Mstrs.Count; j++) { if (AxModel.Mstrs[j].Equals(Mstr, sc)) { MatID[i] = AxModel.MIDs[j]; alreadyDefined = true; } } if (!alreadyDefined) { MatID[i] = AxModel.AxMaterials.AddFromCatalog(AxModel.code, Mstr); AxModel.Mstrs.Add(Mstr); AxModel.MIDs.Add(MatID[i]); AxModel.AxMaterial = AxModel.AxMaterials.Item[MatID[i]]; } } //Add cross sections int[] SectID = new int[axm.Count]; //section ID for each structural member for (int i = 0; i < axm.Count; i++) { string CSstr = axm[i].cs; //chcek if this cross-section has already been defined or not bool alreadyDefined = false; for (int j = 0; j < AxModel.CSstrs.Count; j++) { if (AxModel.CSstrs[j].Equals(CSstr, sc)) { SectID[i] = AxModel.CSIDs[j]; alreadyDefined = true; } } if (!alreadyDefined) { SectID[i] = Extra.GetCrossSection(CSstr, sc, AxModel.AxCrossSections); //currently limited to pipe, I, Box AxModel.CSstrs.Add(CSstr); AxModel.CSIDs.Add(SectID[i]); AxModel.AxCrossSection = AxModel.AxCrossSections.Item[SectID[i]]; } } //Geometry Point newPt = Point.ByCoordinates(0, 0, 0); int ptId = -1; RPoint3d exc = new RPoint3d { x = 0, y = 0, z = 0 }; int notValidLineCount = 0; Boolean bModify = false; if (AxModel.lns.Count > 0) { bModify = true; } for (int i = 0; i < axm.Count; i++) { if (axm[i].ln.Length > 0) { if (bModify) { // modify existing line newPt = axm[i].ln.StartPoint; ptId = AxModel.sIDs[i]; if (ptId != -1) { RPoint3d aPt = new RPoint3d { x = newPt.X, y = newPt.Y, z = newPt.Z }; AxModel.AxNodes.SetNodeCoord(ptId, aPt); AxModel.pts[ptId - 1] = newPt; AxModel.lns[i] = axm[i].ln; } newPt = axm[i].ln.EndPoint; ptId = AxModel.eIDs[i]; if (ptId != -1) { RPoint3d aPt = new RPoint3d { x = newPt.X, y = newPt.Y, z = newPt.Z }; AxModel.AxNodes.SetNodeCoord(ptId, aPt); AxModel.pts[ptId - 1] = newPt; AxModel.lns[i] = axm[i].ln; } if (AxModel.membProps[i] != new int[] { SectID[i], MatID[i], 0 }) { AxModel.AxLine = AxModel.AxLines.Item[i + 1 - notValidLineCount]; string Tstr = axm[i].typ; if (Tstr.Equals("truss")) { AxModel.AxLine.DefineAsTruss(MatID[i], SectID[i], ELineNonLinearity.lnlTensionAndCompression, 0); } else if (Tstr.Equals("beam")) { AxModel.AxLine.DefineAsBeam(MatID[i], SectID[i], SectID[i], exc, exc); } else if (Tstr.Equals("rib")) { AxModel.AxLine.DefineAsRib(MatID[i], SectID[i], SectID[i], exc, exc); } } } else { //create new line newPt = axm[i].ln.StartPoint; if (Extra.GetPointID(AxModel.pts, newPt, 0.001) == -1) { AxModel.pts.Add(newPt); AxModel.AxNodes.Add(newPt.X, newPt.Y, newPt.Z); // add new points to Axis } newPt = axm[i].ln.EndPoint; if (Extra.GetPointID(AxModel.pts, newPt, 0.001) == -1) { AxModel.pts.Add(newPt); AxModel.AxNodes.Add(newPt.X, newPt.Y, newPt.Z); // add new points to Axis } AxModel.sIDs.Add(Extra.GetPointID(AxModel.pts, axm[i].ln.StartPoint, 0.001)); AxModel.eIDs.Add(Extra.GetPointID(AxModel.pts, axm[i].ln.EndPoint, 0.001)); if ((AxModel.sIDs[i] >= 0) && (AxModel.eIDs[i] >= 0)) { AxModel.AxLines.Add(AxModel.sIDs[i], AxModel.eIDs[i], AxModel.geomType, AxModel.geomData); AxModel.AxLine = AxModel.AxLines.Item[i + 1 - notValidLineCount]; string Tstr = axm[i].typ; if (Tstr.Equals("truss")) { AxModel.AxLine.DefineAsTruss(MatID[i], SectID[i], ELineNonLinearity.lnlTensionAndCompression, 0); AxModel.membProps.Add(new int[] { SectID[i], MatID[i], 0 }); } else if (Tstr.Equals("beam")) { AxModel.AxLine.DefineAsBeam(MatID[i], SectID[i], SectID[i], exc, exc); AxModel.membProps.Add(new int[] { SectID[i], MatID[i], 1 }); } else if (Tstr.Equals("rib")) { AxModel.AxLine.DefineAsRib(MatID[i], SectID[i], SectID[i], exc, exc); AxModel.membProps.Add(new int[] { SectID[i], MatID[i], 2 }); } ; AxModel.lns.Add(axm[i].ln); AxModel.sw.Add(false); } } } else { notValidLineCount++; } } //todo: endupdate only if no analysis AxModel.AxModel_.EndUpdate(); //RExtendedDisplayParameters dispextpar = new RExtendedDisplayParameters(); //long lcID = 0; //safearray secID = 0; //AxModel.AxWindows.GetStaticDisplayParameters(1, dispextpar, lcID, secIDs); //dispextpar AxModel.AxApp.Visible = ELongBoolean.lbTrue; AxModel.AxApp.BringToFront(); return(new Dictionary <object, object>() { { "AxModel", AxModel }, { "Points", AxModel.pts }, { "Lines", AxModel.lns }, }); } return(new Dictionary <object, object>() { { "AxModel", AxModel }, { "Points", AxModel.pts }, { "Lines", AxModel.lns }, }); }
public static IDictionary SendLines(AxModel AxModel, Boolean b, List <Line> ln) { if (b == true) { AxModel.AxModel_.BeginUpdate(); Point newPt = Point.ByCoordinates(0, 0, 0); int ptId = -1; RPoint3d exc = new RPoint3d { x = 0, y = 0, z = 0 }; int notValidLineCount = 0; Boolean bModify = false; if (AxModel.lns.Count > 0) { bModify = true; } for (int i = 0; i < ln.Count; i++) { if (ln[i].Length > 0) { if (bModify) { // modify existing line newPt = ln[i].StartPoint; ptId = AxModel.sIDs[i]; if (ptId != -1) { RPoint3d aPt = new RPoint3d { x = newPt.X, y = newPt.Y, z = newPt.Z }; AxModel.AxNodes.SetNodeCoord(ptId, aPt); AxModel.pts[ptId - 1] = newPt; AxModel.lns[i] = ln[i]; } newPt = ln[i].EndPoint; ptId = AxModel.eIDs[i]; if (ptId != -1) { RPoint3d aPt = new RPoint3d { x = newPt.X, y = newPt.Y, z = newPt.Z }; AxModel.AxNodes.SetNodeCoord(ptId, aPt); AxModel.pts[ptId - 1] = newPt; AxModel.lns[i] = ln[i]; } } else { //create new line newPt = ln[i].StartPoint; if (Extra.GetPointID(AxModel.pts, newPt, 0.001) == -1) { AxModel.pts.Add(newPt); AxModel.AxNodes.Add(newPt.X, newPt.Y, newPt.Z); // add new points to Axis } newPt = ln[i].EndPoint; if (Extra.GetPointID(AxModel.pts, newPt, 0.001) == -1) { AxModel.pts.Add(newPt); AxModel.AxNodes.Add(newPt.X, newPt.Y, newPt.Z); // add new points to Axis } AxModel.sIDs.Add(Extra.GetPointID(AxModel.pts, ln[i].StartPoint, 0.001)); AxModel.eIDs.Add(Extra.GetPointID(AxModel.pts, ln[i].EndPoint, 0.001)); if ((AxModel.sIDs[i] >= 0) && (AxModel.eIDs[i] >= 0)) { AxModel.AxLines.Add(AxModel.sIDs[i], AxModel.eIDs[i], AxModel.geomType, AxModel.geomData); AxModel.AxLine = AxModel.AxLines.Item[i + 1 - notValidLineCount]; AxModel.lns.Add(ln[i]); } } } else { notValidLineCount++; } } //todo: endupdate only if no analysis or if there is analysis results available, it should be deleted AxModel.AxModel_.EndUpdate(); AxModel.AxApp.Visible = ELongBoolean.lbTrue; AxModel.AxApp.BringToFront(); return(new Dictionary <object, object>() { { "AxModel", AxModel }, { "Points", AxModel.pts }, { "Lines", AxModel.lns }, }); } return(new Dictionary <object, object>() { { "AxModel", AxModel }, { "Points", AxModel.pts }, { "Lines", AxModel.lns }, }); }