public static void CreateModel(Karamba.Models.Model kModel) { if (RModel != null) { Node[] rNodes = Nodes(kModel.nodes); NodalSupport[] rSupports = Supports(kModel.supports); Material[] rMaterials = Materials(kModel.materials); CrossSection[] rCrossSections = CrossSections(kModel.crosecs, kModel); Tuple <Member[], Dlubal.RFEM5.Line[]> vali = Members(kModel.elems); Member[] rMembers = vali.Item1; Dlubal.RFEM5.Line[] rLines = vali.Item2; LoadCase[] lCases = LoadCases(kModel); MemberLoad[] rMemberLoads = MemberLoads(kModel.eloads); NodalLoad[] rNodalLoads = NodalLoads(kModel.ploads); MemberHinge[] rMemberHinges = MemberHinges(kModel.joints); //Get active RFEM5 application try { IModelData rData = RModel.GetModelData(); ILoads rLoads = RModel.GetLoads(); //Cleans the model and load data data rData.PrepareModification(); rData.Clean(); rData.FinishModification(); rLoads.PrepareModification(); rLoads.Clean(); rLoads.FinishModification(); //Model elements rData.PrepareModification(); rData.SetNodes(rNodes); rData.SetNodalSupports(rSupports); rData.SetMaterials(rMaterials); rData.SetCrossSections(rCrossSections); rData.SetMemberHinges(rMemberHinges); rData.SetLines(rLines); rData.SetMembers(rMembers); rData.FinishModification(); //Load cases rLoads.PrepareModification(); rLoads.SetLoadCases(lCases); rLoads.FinishModification(); //Loads setRFEMmemberLoads(rLoads, rMemberLoads); setRFEMnodalLoads(rLoads, rNodalLoads); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA, EvaluationUnit unit) { var run = false; var ghNodes = new List <GH_RFEM>(); var ghLines = new List <GH_RFEM>(); var ghMembers = new List <GH_RFEM>(); var ghSfcs = new List <GH_RFEM>(); var ghOps = new List <GH_RFEM>(); var ghSupsP = new List <GH_RFEM>(); var ghSupsL = new List <GH_RFEM>(); var ghSupsS = new List <GH_RFEM>(); var ghMHs = new List <GH_RFEM>(); var ghLHs = new List <GH_RFEM>(); var ghCSs = new List <GH_RFEM>(); var ghMats = new List <GH_RFEM>(); var ghNodalLoads = new List <GH_RFEM>(); var ghLineLoads = new List <GH_RFEM>(); var ghMemberLoads = new List <GH_RFEM>(); var ghSurfaceLoads = new List <GH_RFEM>(); var ghPolyLoads = new List <GH_RFEM>(); var ghLoadCases = new List <GH_RFEM>(); var ghLoadCombos = new List <GH_RFEM>(); var ghResultCombos = new List <GH_RFEM>(); var modelName = ""; IModel model = null; IModelData data = null; ILoads loads = null; var errorMsg = new List <string>(); DA.GetData(0, ref run); if (run) { Component_SetData.ClearOutput(ref nodesNo, ref linesNo, ref membersNo, ref srfcNo, ref opNo, ref nodSupNo, ref lineSupNo, ref sfcSupNo, ref memberHingeNo, ref lineHingeNo, ref croSecNo, ref matNo, ref nodalLoadNo, ref lineLoadNo, ref memberLoadNo, ref surfaceLoadNo, ref polyLoadNo, ref loadcaseNo, ref loadcomboNo, ref resultcomboNo); if (!DA.GetData(modelDataCount3 + 1, ref modelName)) { Component_GetData.ConnectRFEM(ref model, ref data); } else { Component_GetData.ConnectRFEM(modelName, ref model, ref data); } try { // Set data data.PrepareModification(); if (DA.GetDataList(12, ghMats)) { data.SetRFMaterials(ghMats, ref matNo, ref errorMsg); } if (DA.GetDataList(11, ghCSs)) { data.SetRFCroSecs(ghCSs, ref croSecNo, ref errorMsg); } if (DA.GetDataList(9, ghMHs)) { data.SetRFMemberHinges(ghMHs, ref memberHingeNo, ref errorMsg); } if (DA.GetDataList(1, ghNodes)) { data.SetRFNodes(ghNodes, ref nodesNo, ref errorMsg); } if (DA.GetDataList(2, ghLines)) { data.SetRFLines(ghLines, ref linesNo, ref errorMsg); } if (DA.GetDataList(3, ghMembers)) { data.SetRFMembers(ghMembers, ref membersNo, ref errorMsg); } if (DA.GetDataList(4, ghSfcs)) { data.SetRFSurfaces(ghSfcs, ref srfcNo, ref errorMsg); } if (DA.GetDataList(5, ghOps)) { data.SetRFOpenings(ghOps, ref opNo, ref errorMsg); } if (DA.GetDataList(6, ghSupsP)) { data.SetRFSupportsP(ghSupsP, ref nodSupNo, ref errorMsg); } if (DA.GetDataList(7, ghSupsL)) { data.SetRFSupportsL(ghSupsL, ref lineSupNo, ref errorMsg); } if (DA.GetDataList(8, ghSupsS)) { data.SetRFSupportsS(ghSupsS, ref sfcSupNo, ref errorMsg); } if (DA.GetDataList(10, ghLHs)) { data.SetRFLineHinges(ghLHs, ref lineHingeNo, ref errorMsg); } data.FinishModification(); // Set Load Cases and Combos if (DA.GetDataList(modelDataCount2 + 1, ghLoadCases)) { if (loads == null) { Component_GetData.GetLoadsFromRFEM(model, ref loads); } data.SetRFLoadCases(loads, ghLoadCases, ref loadcaseNo, ref errorMsg); } if (DA.GetDataList(modelDataCount2 + 2, ghLoadCombos)) { if (loads == null) { Component_GetData.GetLoadsFromRFEM(model, ref loads); } data.SetRFLoadCombos(loads, ghLoadCombos, ref loadcomboNo, ref errorMsg); } if (DA.GetDataList(modelDataCount2 + 3, ghResultCombos)) { if (loads == null) { Component_GetData.GetLoadsFromRFEM(model, ref loads); } data.SetRFResultCombos(loads, ghResultCombos, ref resultcomboNo, ref errorMsg); } // Set Loads if (DA.GetDataList(modelDataCount + 1, ghNodalLoads)) { if (loads == null) { Component_GetData.GetLoadsFromRFEM(model, ref loads); } data.SetRFNodalLoads(loads, ghNodalLoads, ref nodalLoadNo, ref errorMsg); } if (DA.GetDataList(modelDataCount + 2, ghLineLoads)) { if (loads == null) { Component_GetData.GetLoadsFromRFEM(model, ref loads); } data.SetRFLineLoads(loads, ghLineLoads, ref lineLoadNo, ref errorMsg); } if (DA.GetDataList(modelDataCount + 3, ghMemberLoads)) { if (loads == null) { Component_GetData.GetLoadsFromRFEM(model, ref loads); } data.SetRFMemberLoads(loads, ghMemberLoads, ref memberLoadNo, ref errorMsg); } if (DA.GetDataList(modelDataCount + 4, ghSurfaceLoads)) { if (loads == null) { Component_GetData.GetLoadsFromRFEM(model, ref loads); } data.SetRFSurfaceLoads(loads, ghSurfaceLoads, ref surfaceLoadNo, ref errorMsg); } if (DA.GetDataList(modelDataCount + 5, ghPolyLoads)) { if (loads == null) { Component_GetData.GetLoadsFromRFEM(model, ref loads); } data.SetRFFreePolygonLoads(loads, ghPolyLoads, ref polyLoadNo, ref errorMsg); } } catch (Exception ex) { Component_SetData.ClearOutput(ref nodesNo, ref linesNo, ref membersNo, ref srfcNo, ref opNo, ref nodSupNo, ref lineSupNo, ref sfcSupNo, ref memberHingeNo, ref lineHingeNo, ref croSecNo, ref matNo, ref nodalLoadNo, ref lineLoadNo, ref memberLoadNo, ref surfaceLoadNo, ref polyLoadNo, ref loadcaseNo, ref loadcomboNo, ref resultcomboNo); Component_GetData.DisconnectRFEM(ref model, ref data); throw ex; } Component_GetData.DisconnectRFEM(ref model, ref data); } // Assign Output DA.SetDataList(0, nodesNo); DA.SetDataList(1, linesNo); DA.SetDataList(2, membersNo); DA.SetDataList(3, srfcNo); DA.SetDataList(4, opNo); DA.SetDataList(5, nodSupNo); DA.SetDataList(6, lineSupNo); DA.SetDataList(7, sfcSupNo); DA.SetDataList(8, memberHingeNo); DA.SetDataList(9, lineHingeNo); DA.SetDataList(10, croSecNo); DA.SetDataList(11, matNo); DA.SetDataList(12, nodalLoadNo); DA.SetDataList(13, lineLoadNo); DA.SetDataList(14, memberLoadNo); DA.SetDataList(15, surfaceLoadNo); DA.SetDataList(16, polyLoadNo); DA.SetDataList(17, loadcaseNo); DA.SetDataList(18, loadcomboNo); DA.SetDataList(19, resultcomboNo); if (errorMsg.Count != 0) { //errorMsg.Add("List item index may be one unit lower than object number"); AddRuntimeMessage(GH_RuntimeMessageLevel.Error, String.Join(System.Environment.NewLine, errorMsg.ToArray())); } }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA, EvaluationUnit unit) { var run = false; var ghNodes = new List <GH_RFEM>(); var ghLines = new List <GH_RFEM>(); var ghMembers = new List <GH_RFEM>(); var ghSfcs = new List <GH_RFEM>(); var ghOps = new List <GH_RFEM>(); var ghSupsP = new List <GH_RFEM>(); var ghSupsL = new List <GH_RFEM>(); var ghLHs = new List <GH_RFEM>(); var ghCSs = new List <GH_RFEM>(); var ghMats = new List <GH_RFEM>(); var ghNodalLoads = new List <GH_RFEM>(); var modelName = ""; IModel model = null; IModelData data = null; ILoads loads = null; DA.GetData(modelDataCount - 1, ref run); if (run) { Component_SetData.ClearOutput(ref nodesNo, ref linesNo, ref membersNo, ref srfcNo, ref opNo, ref nodSupNo, ref lineSupNo, ref lineHingeNo, ref croSecNo, ref matNo, ref nodalLoadNo); if (!DA.GetData(modelDataCount + modelDataCount2, ref modelName)) { Component_GetData.ConnectRFEM(ref model, ref data); } else { Component_GetData.ConnectRFEM(modelName, ref model, ref data); } try { // Set data data.PrepareModification(); if (DA.GetDataList(9, ghMats)) { data.SetRFMaterials(ghMats, ref matNo); } if (DA.GetDataList(8, ghCSs)) { data.SetRFCroSecs(ghCSs, ref croSecNo); } if (DA.GetDataList(0, ghNodes)) { data.SetRFNodes(ghNodes, ref nodesNo); } if (DA.GetDataList(1, ghLines)) { data.SetRFLines(ghLines, ref linesNo); } if (DA.GetDataList(2, ghMembers)) { data.SetRFMembers(ghMembers, ref membersNo); } if (DA.GetDataList(3, ghSfcs)) { data.SetRFSurfaces(ghSfcs, ref srfcNo); } if (DA.GetDataList(4, ghOps)) { data.SetRFOpenings(ghOps, ref opNo); } if (DA.GetDataList(5, ghSupsP)) { data.SetRFSupportsP(ghSupsP, ref nodSupNo); } if (DA.GetDataList(6, ghSupsL)) { data.SetRFSupportsL(ghSupsL, ref lineSupNo); } if (DA.GetDataList(7, ghLHs)) { data.SetRFLineHinges(ghLHs, ref lineHingeNo); } data.FinishModification(); // Set Loads if (DA.GetDataList(modelDataCount, ghNodalLoads)) { Component_GetData.GetLoadsFromRFEM(model, ref loads); data.SetRFNodalLoads(loads, ghNodalLoads, ref nodalLoadNo); } } catch (Exception ex) { Component_SetData.ClearOutput(ref nodesNo, ref linesNo, ref membersNo, ref srfcNo, ref opNo, ref nodSupNo, ref lineSupNo, ref lineHingeNo, ref croSecNo, ref matNo, ref nodalLoadNo); Component_GetData.DisconnectRFEM(ref model, ref data); throw ex; } Component_GetData.DisconnectRFEM(ref model, ref data); } // Assign Output DA.SetDataList(0, nodesNo); DA.SetDataList(1, linesNo); DA.SetDataList(2, membersNo); DA.SetDataList(3, srfcNo); DA.SetDataList(4, opNo); DA.SetDataList(5, nodSupNo); DA.SetDataList(6, lineSupNo); DA.SetDataList(7, lineHingeNo); DA.SetDataList(8, croSecNo); DA.SetDataList(9, matNo); DA.SetDataList(10, nodalLoadNo); }
private List <Dlubal.RFEM5.Node> CreateRfemNodes(List <Point3d> Rh_pt3d, Dlubal.RFEM5.NodalSupport rfemNodalSupportMethodIn, string commentsListMethodIn) { //---- Estabish connection with RFEM---- #region Creating connection with RFEM // Gets interface to running RFEM application. IApplication app = Marshal.GetActiveObject("RFEM5.Application") as IApplication; // Locks RFEM licence app.LockLicense(); // Gets interface to active RFEM model. IModel model = app.GetActiveModel(); // Gets interface to model data. IModelData data = model.GetModelData(); #endregion //---- Further lines gets information about available object numbers in model;---- #region Getting available element numbers // Gets Max node Number int currentNewNodeNo = data.GetLastObjectNo(ModelObjectType.NodeObject) + 1; // Gets Max nodal support number int currentNewNodalSupportNo = data.GetLastObjectNo(ModelObjectType.NodalSupportObject) + 1; #endregion //---- Creating new variables for use within this method---- List <Dlubal.RFEM5.Node> RfemNodeList = new List <Dlubal.RFEM5.Node>(); //Create new list for RFEM point objects string createdNodesList = ""; //Create a string for list with nodes //---- Assigning node propertiess---- #region Creating RFEM node elements for (int i = 0; i < Rh_pt3d.Count; i++) { Dlubal.RFEM5.Node tempCurrentNode = new Dlubal.RFEM5.Node(); tempCurrentNode.No = currentNewNodeNo; tempCurrentNode.CS = CoordinateSystemType.Cartesian; tempCurrentNode.Type = NodeType.Standard; tempCurrentNode.X = Rh_pt3d[i].X; tempCurrentNode.Y = Rh_pt3d[i].Y; tempCurrentNode.Z = Rh_pt3d[i].Z; tempCurrentNode.Comment = commentsListMethodIn; RfemNodeList.Add(tempCurrentNode); if (i == Rh_pt3d.Count - 1) { createdNodesList = createdNodesList + currentNewNodeNo.ToString(); } else { createdNodesList = createdNodesList + currentNewNodeNo.ToString() + ","; } currentNewNodeNo++; } //create an array of nodes; Dlubal.RFEM5.Node[] RfemNodeArray = new Dlubal.RFEM5.Node[RfemNodeList.Count]; RfemNodeArray = RfemNodeList.ToArray(); #endregion //---- Writing nodes---- #region Writing RFEM nodes and supports try { // modification - set model in modification mode, new information can be written data.PrepareModification(); ///This version writes nodes one-by-one, because the API method data.SetNodes() for ///array appears not to be working //data.SetNodes(RfemNodeList.ToArray()); foreach (Node currentRfemNode in RfemNodeList) { data.SetNode(currentRfemNode); } //addition of nodal supports rfemNodalSupportMethodIn.No = currentNewNodalSupportNo; rfemNodalSupportMethodIn.NodeList = createdNodesList; data.SetNodalSupport(ref rfemNodalSupportMethodIn); // finish modification - RFEM regenerates the data (this operation takes some time) data.FinishModification(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error - Writing nodes", MessageBoxButtons.OK, MessageBoxIcon.Error); } #endregion //---- Releasing RFEM model---- #region Releasing RFEM model // Releases interface to RFEM model. model = null; // Unlocks licence and releases interface to RFEM application. if (app != null) { app.UnlockLicense(); app = null; } // Cleans Garbage Collector and releases all cached COM interfaces. System.GC.Collect(); System.GC.WaitForPendingFinalizers(); #endregion ///the lines below outputs created RFEM nodes in output parameter //output 'success' as true writeSuccess = true; return(RfemNodeList); }
public static void AlignNodesToPlane(double tolerance, RFEMgeomOps.AlignmentSettings alignSettings) { //get the connection IModel model = RFEMconnection.getRFEMconnection(); IModelData modelData = model.GetModelData(); //get the alignment plane List <Plane> alignmentPlanes = new List <Plane>(); if (alignSettings.AlignmentType == RFEMgeomOps.AlignmentPlaneType.By3Points) { alignmentPlanes.Add(RFEMselectOps.GetPlaneFrom3Points(model)); } if (alignSettings.AlignmentType == RFEMgeomOps.AlignmentPlaneType.VerticalBy2Points) { alignmentPlanes.Add(RFEMselectOps.GetVerticalPlaneFrom2Points(model)); } if (alignSettings.AlignmentType == RFEMgeomOps.AlignmentPlaneType.MultipleFloors) { alignmentPlanes = RFEMselectOps.GetHorizontalPlanesFromMultiplePoints(model); } //get all the nodes in the model int nodeCount = modelData.GetNodeCount(); Node[] nodes = new Node[nodeCount]; nodes = modelData.GetNodes(); List <Node> nodesList = nodes.ToList(); //define variable for modified nodes List <Node> projectedNodes = new List <Node>(); //cycle thrugh each alignment plane foreach (Plane alignmentPlane in alignmentPlanes) { //if the alignment plane is not valid, stop process if (alignmentPlane.Normal.X == 0 && alignmentPlane.Normal.Y == 0 && alignmentPlane.Normal.Z == 0) { RFEMconnection.closeRFEMconnection(model); return; } //project the nodes to the plane foreach (Node node in nodes) { double dist = RFEMgeomOps.DistanceNodeToPlane(node, alignmentPlane); if (dist > tolerance) { continue; } if (dist < minTolerance) { continue; } Node projectedNode = RFEMgeomOps.ProjectNodeToPlane(node, alignmentPlane, alignSettings); projectedNodes.Add(projectedNode); } } //write the nodes try { //prepares model for modification and writes data modelData.PrepareModification(); foreach (Node nodeToWrite in projectedNodes) { modelData.SetNode(nodeToWrite); } //finishes modifications - regenerates numbering etc. modelData.FinishModification(); Common.IO.Log("Nodes have been aligned to the plane"); } catch (Exception ex) { Common.IO.Log("Error in aligning the nodes"); MessageBox.Show(ex.Message, "Error - Nodes alignment", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { //closing the connection with RFEM RFEMconnection.closeRFEMconnection(model); } }
public static void MatchMemberProps(RFEMobjectOps.MatchMemberPropertiesSettings matchPropSettings) { IModel model = RFEMconnection.getRFEMconnection(); IModelData modelData = model.GetModelData(); IView view = model.GetActiveView(); //select Source member Common.IO.Log("Select one source member!"); List <Member> sourceMembers = RFEMselectOps.selectMembers(model); if (sourceMembers.Count == 0) { Common.IO.Log(""); return; } Member sourceMember = sourceMembers[0]; //select Destination members Common.IO.Log("Select one or multiple destination members!"); List <Member> destinationMembers = RFEMselectOps.selectMembers(model); if (destinationMembers.Count == 0) { Common.IO.Log(""); return; } List <Member> membersToWrite = new List <Member>(); foreach (Member member in destinationMembers) { Member targetMember = member; RFEMobjectOps.MatchMemberProperties(sourceMember, ref targetMember, matchPropSettings); membersToWrite.Add(targetMember); } try { //prepares model for modification and writes data modelData.PrepareModification(); foreach (Member memberToWrite in membersToWrite) { modelData.SetMember(memberToWrite); } //finishes modifications - regenerates numbering etc. modelData.FinishModification(); Common.IO.Log("Member properties have been matched!"); } catch (Exception ex) { Common.IO.Log("Error in matching the member properties!"); MessageBox.Show(ex.Message, "Error - Member Write", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { //closing the connection with RFEM RFEMconnection.closeRFEMconnection(model); } }
private List <Dlubal.RFEM5.Surface> CreateRfemSurfaces(List <Rhino.Geometry.Brep> Rh_Srf, double srfThicknessInMethod, string srfMaterialTextDescription, string srfCommentMethodIn) { //cycling through all Surfaces and creating RFEM objects; int nodeCount = 1; int lineCount = 1; int surfaceCount = 1; //list for curves describing surface edges List <Rhino.Geometry.Curve> RhSimpleLines = new List <Rhino.Geometry.Curve>(); //lists for nodes, lines and surfaces to be created List <Dlubal.RFEM5.Node> RfemNodeList = new List <Dlubal.RFEM5.Node>(); List <Dlubal.RFEM5.Line> RfemLineList = new List <Dlubal.RFEM5.Line>(); List <Dlubal.RFEM5.Surface> RfemSurfaceList = new List <Dlubal.RFEM5.Surface>(); //---- Interface with RFEM, getting available element numbers ---- #region Interface with RFEM, getting available element numbers // Gets interface to running RFEM application. IApplication app = Marshal.GetActiveObject("RFEM5.Application") as IApplication; // Locks RFEM licence app.LockLicense(); // Gets interface to active RFEM model. IModel model = app.GetActiveModel(); // Gets interface to model data. IModelData data = model.GetModelData(); // Gets Max node, line , surface support numbers int currentNewNodeNo = data.GetLastObjectNo(ModelObjectType.NodeObject) + 1; int currentNewLineNo = data.GetLastObjectNo(ModelObjectType.LineObject) + 1; int currentNewSurfaceNo = data.GetLastObjectNo(ModelObjectType.SurfaceObject) + 1; int currentNewMaterialNo = data.GetLastObjectNo(ModelObjectType.MaterialObject) + 1; #endregion // Defines material used for all surfaces Dlubal.RFEM5.Material material = new Dlubal.RFEM5.Material(); material.No = currentNewMaterialNo; material.TextID = srfMaterialTextDescription; material.ModelType = MaterialModelType.IsotropicLinearElasticType; //start cycling through all surfaces foreach (Rhino.Geometry.Brep RhSingleSurface in Rh_Srf) { #region simplification of perimeter edges // clearing previous surface data before starting to work on new surface: RhSimpleLines.Clear(); //simplifying edges - adding to array; Rhino.Geometry.Curve[] curves = RhSingleSurface.DuplicateEdgeCurves(true); curves = Rhino.Geometry.Curve.JoinCurves(curves); foreach (Rhino.Geometry.Curve RhSingleCurve in curves) { if (RhSingleCurve.IsPolyline()) { if (RhSingleCurve.SpanCount == 1) { //if this is simple linear line RhSimpleLines.Add(RhSingleCurve); } else { foreach (Rhino.Geometry.Curve explodedSurface in RhSingleCurve.DuplicateSegments()) { //if this is polyline RhSimpleLines.Add(explodedSurface); } } } else { foreach (Rhino.Geometry.Curve explodedLine in RhSingleCurve.ToPolyline(0, 0, 3.14, 1, 0, 0, 0, segmentLength, true).DuplicateSegments()) { //if this is curved lines RhSimpleLines.Add(explodedLine); } } #endregion int surfaceNodeCounter = 0; //counts nodes witin one surface. nodeCount counts overall nodes in model int surfaceLineCounter = 0; // counts lines (edges) for one surface, lineCount counts overall lines in model //cycling through perimeter of the surface and defining lines surface #region Defining nodes and lines for one surface for (int i = 0; i < RhSimpleLines.Count; i++) { //defining variables needed to store geometry and RFEM info Rhino.Geometry.Point3d startPoint = RhSimpleLines[i].PointAtStart; Rhino.Geometry.Point3d endPoint = RhSimpleLines[i].PointAtEnd; //if this is the first line for the surface if (i == 0) { // defining start and end nodes of the line Dlubal.RFEM5.Node tempCurrentStartNode = new Dlubal.RFEM5.Node(); Dlubal.RFEM5.Node tempCurrentEndNode = new Dlubal.RFEM5.Node(); tempCurrentStartNode.No = currentNewNodeNo; tempCurrentStartNode.X = Math.Round(startPoint.X, 5); tempCurrentStartNode.Y = Math.Round(startPoint.Y, 5); tempCurrentStartNode.Z = Math.Round(startPoint.Z, 5); tempCurrentEndNode.No = currentNewNodeNo + 1; tempCurrentEndNode.X = Math.Round(endPoint.X, 5); tempCurrentEndNode.Y = Math.Round(endPoint.Y, 5); tempCurrentEndNode.Z = Math.Round(endPoint.Z, 5); RfemNodeList.Add(tempCurrentStartNode); RfemNodeList.Add(tempCurrentEndNode); // defining line Dlubal.RFEM5.Line tempCurrentLine = new Dlubal.RFEM5.Line(); tempCurrentLine.No = currentNewLineNo; tempCurrentLine.Type = LineType.PolylineType; tempCurrentLine.NodeList = $"{tempCurrentStartNode.No}, {tempCurrentEndNode.No}"; RfemLineList.Add(tempCurrentLine); nodeCount = nodeCount + 2; surfaceNodeCounter = surfaceNodeCounter + 2; lineCount++; surfaceLineCounter++; currentNewNodeNo = currentNewNodeNo + 2; currentNewLineNo++; } //if this is the last node for the surface else if (i == RhSimpleLines.Count - 1) { //no need to define new node as these are both already defined //create line connecting previous node with first node for surface // defining start and end nodes of the line Dlubal.RFEM5.Line tempCurrentLine = new Dlubal.RFEM5.Line(); tempCurrentLine.No = currentNewLineNo; tempCurrentLine.Type = LineType.PolylineType; tempCurrentLine.NodeList = $"{RfemNodeList[RfemNodeList.Count - 1].No}, {RfemNodeList[RfemNodeList.Count - surfaceNodeCounter].No}"; RfemLineList.Add(tempCurrentLine); lineCount++; surfaceLineCounter++; currentNewLineNo++; } else { //if this is just a node somewhere on edges //defining end node of line Dlubal.RFEM5.Node tempCurrentEndNode = new Dlubal.RFEM5.Node(); // defining start and end nodes of the line Dlubal.RFEM5.Line tempCurrentLine = new Dlubal.RFEM5.Line(); tempCurrentEndNode.No = currentNewNodeNo; tempCurrentEndNode.X = Math.Round(endPoint.X, 5); tempCurrentEndNode.Y = Math.Round(endPoint.Y, 5); tempCurrentEndNode.Z = Math.Round(endPoint.Z, 5); RfemNodeList.Add(tempCurrentEndNode); tempCurrentLine.No = currentNewLineNo; tempCurrentLine.Type = LineType.PolylineType; tempCurrentLine.NodeList = $"{RfemNodeList[RfemNodeList.Count - 2].No}, {RfemNodeList[RfemNodeList.Count - 1].No}"; RfemLineList.Add(tempCurrentLine); nodeCount++; surfaceNodeCounter++; lineCount++; surfaceLineCounter++; currentNewNodeNo++; currentNewLineNo++; } } #endregion //defines surface data #region Defining data of the surface to be written // start with making a string with "list" of lines forming the surface int surfaceFirstLine = currentNewLineNo - RhSimpleLines.Count; int surfaceLastLine = surfaceFirstLine + RhSimpleLines.Count - 1; string surfaceLineList = ""; for (int i = surfaceFirstLine; i < surfaceLastLine; i++) { surfaceLineList = surfaceLineList + i.ToString() + ","; } surfaceLineList = surfaceLineList + surfaceLastLine.ToString(); // defining RFEM parameter of surface Dlubal.RFEM5.Surface surfaceData = new Dlubal.RFEM5.Surface(); surfaceData.No = currentNewSurfaceNo; surfaceData.MaterialNo = material.No; surfaceData.GeometryType = SurfaceGeometryType.PlaneSurfaceType; surfaceData.BoundaryLineList = surfaceLineList; surfaceData.Comment = srfCommentMethodIn; // if -1 is input as thickness, surface is created as rigid, otherwise it is "standard" if (srfThicknessInMethod == -1) { surfaceData.StiffnessType = SurfaceStiffnessType.RigidStiffnessType; } else if (srfThicknessInMethod == 0) { surfaceData.StiffnessType = SurfaceStiffnessType.NullStiffnessType; } else { surfaceData.StiffnessType = SurfaceStiffnessType.StandardStiffnessType; surfaceData.Thickness.Constant = srfThicknessInMethod; } //adding surface to elements to be written RfemSurfaceList.Add(surfaceData); surfaceCount++; currentNewSurfaceNo++; #endregion } } //try writing the surface; #region Writing the surface and releasing RFEM model try { //prepares model for modification. data.PrepareModification(); data.SetMaterial(material); //This version writes nodes one-by-one because the data.SetNodes() for array appears not to be working foreach (Node currentRfemNode in RfemNodeList) { data.SetNode(currentRfemNode); } //This version writes lines one-by-one because the data.SetLines() for array appears not to be working foreach (Dlubal.RFEM5.Line currentRfemLine in RfemLineList) { data.SetLine(currentRfemLine); } //This version writes lines one-by-one because the data.SetLines() for array appears not to be working foreach (Dlubal.RFEM5.Surface currentRfemSurface in RfemSurfaceList) { data.SetSurface(currentRfemSurface); } //finishes modifications - regenerates numbering etc. data.FinishModification(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error - Surface Write", MessageBoxButtons.OK, MessageBoxIcon.Error); } //resetting counters; nodeCount = 1; lineCount = 1; surfaceCount = 1; // Releases interface to RFEM model. model = null; // Unlocks licence and releases interface to RFEM application. if (app != null) { app.UnlockLicense(); app = null; } // Cleans Garbage Collector and releases all cached COM interfaces. System.GC.Collect(); System.GC.WaitForPendingFinalizers(); #endregion //output 'success' as true writeSuccess = true; ///the Surfaces below outputs created RFEM surfaces in output parameter ///current funcionality does not use this return(RfemSurfaceList); }
public static void MatchSurfaceProps(RFEMobjectOps.MatchSurfacePropertiesSettings matchPropSettings) { IModel model = RFEMconnection.getRFEMconnection(); IModelData modelData = model.GetModelData(); IView view = model.GetActiveView(); //select Source surface // Common.IO.Log("Select one source surface!"); List <Surface> sourceSurfaces = RFEMselectOps.selectSurfaces(model); if (sourceSurfaces.Count == 0) { Common.IO.Log(""); return; } Surface sourceSurface = sourceSurfaces[0]; //select Destination surfaces Common.IO.Log("Select one or multiple destination surfaces!"); List <Surface> destinationSurfaces = RFEMselectOps.selectSurfaces(model); if (destinationSurfaces.Count == 0) { Common.IO.Log(""); return; } List <Surface> surfacesToWrite = new List <Surface>(); foreach (Surface surface in destinationSurfaces) { Surface targetSurface = new Surface(); RFEMobjectOps.MatchSurfaceProperties(sourceSurface, ref targetSurface, matchPropSettings); targetSurface.No = surface.No; targetSurface.BoundaryLineList = surface.BoundaryLineList; surfacesToWrite.Add(targetSurface); } try { //prepares model for modification and writes data modelData.PrepareModification(); foreach (Surface surfaceToWrite in surfacesToWrite) { modelData.SetSurface(surfaceToWrite); } //finishes modifications - regenerates numbering etc. modelData.FinishModification(); Common.IO.Log("Surface properties have been matched"); } catch (Exception ex) { Common.IO.Log("Error in matching the surface properties"); MessageBox.Show(ex.Message, "Error - Surface Write", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { //closing the connection with RFEM RFEMconnection.closeRFEMconnection(model); } }
private List <Dlubal.RFEM5.Line> CreateRfemLines(List <Rhino.Geometry.Curve> Rh_Crv, Dlubal.RFEM5.LineSupport rfemLineSupportMethodIn, string commentsListMethodIn) { //defining variables needed to store geometry and RFEM info Rhino.Geometry.Point3d startPoint; Rhino.Geometry.Point3d endPoint; List <Dlubal.RFEM5.Node> RfemNodeList = new List <Dlubal.RFEM5.Node>(); List <Dlubal.RFEM5.Line> RfemLineList = new List <Dlubal.RFEM5.Line>(); string createdLinesList = ""; //---- Rhino geometry simplification and creating a list of simple straight lines ---- #region Rhino geometry processing //start by reducing the input curves to simple lines with start/end points List <Rhino.Geometry.Curve> RhSimpleLines = new List <Rhino.Geometry.Curve>(); foreach (Rhino.Geometry.Curve RhSingleCurve in Rh_Crv) { if (RhSingleCurve.IsPolyline()) { if (RhSingleCurve.SpanCount == 1) { // if line is a simple straight line RhSimpleLines.Add(RhSingleCurve); } else { foreach (Rhino.Geometry.Curve explodedLine in RhSingleCurve.DuplicateSegments()) { // if line is polyline, then it gets exploded RhSimpleLines.Add(explodedLine); } } } else { foreach (Rhino.Geometry.Curve explodedLine in RhSingleCurve.ToPolyline(0, 0, 3.14, 1, 0, 0, 0, segmentLengthInput, true).DuplicateSegments()) { // if line is a an arc or nurbs or have any curvature, it gets simplified RhSimpleLines.Add(explodedLine); } } } #endregion //---- Interface with RFEM, getting available element numbers ---- #region Gets interface with RFEM and currently available element numbers // Gets interface to running RFEM application. IApplication app = Marshal.GetActiveObject("RFEM5.Application") as IApplication; // Locks RFEM licence app.LockLicense(); // Gets interface to active RFEM model. IModel model = app.GetActiveModel(); // Gets interface to model data. IModelData data = model.GetModelData(); // Gets Max node, line , line support numbers int currentNewNodeNo = data.GetLastObjectNo(ModelObjectType.NodeObject) + 1; int currentNewLineNo = data.GetLastObjectNo(ModelObjectType.LineObject) + 1; int currentNewLineSupportNo = data.GetLastObjectNo(ModelObjectType.LineSupportObject) + 1; #endregion //----- cycling through all lines and creating RFEM objects ---- #region Creates RFEM node and line elements for (int i = 0; i < RhSimpleLines.Count; i++) { // defining start and end nodes of the line Dlubal.RFEM5.Node tempCurrentStartNode = new Dlubal.RFEM5.Node(); Dlubal.RFEM5.Node tempCurrentEndNode = new Dlubal.RFEM5.Node(); startPoint = RhSimpleLines[i].PointAtStart; endPoint = RhSimpleLines[i].PointAtEnd; tempCurrentStartNode.No = currentNewNodeNo; tempCurrentStartNode.X = startPoint.X; tempCurrentStartNode.Y = startPoint.Y; tempCurrentStartNode.Z = startPoint.Z; tempCurrentEndNode.No = currentNewNodeNo + 1; tempCurrentEndNode.X = endPoint.X; tempCurrentEndNode.Y = endPoint.Y; tempCurrentEndNode.Z = endPoint.Z; RfemNodeList.Add(tempCurrentStartNode); RfemNodeList.Add(tempCurrentEndNode); // defining line Dlubal.RFEM5.Line tempCurrentLine = new Dlubal.RFEM5.Line(); tempCurrentLine.No = currentNewLineNo; tempCurrentLine.Type = LineType.PolylineType; tempCurrentLine.Comment = commentsListMethodIn; tempCurrentLine.NodeList = $"{tempCurrentStartNode.No}, {tempCurrentEndNode.No}"; RfemLineList.Add(tempCurrentLine); // adding line numbers to list with all lines if (i == RhSimpleLines.Count) { createdLinesList = createdLinesList + currentNewLineNo.ToString(); } else { createdLinesList = createdLinesList + currentNewLineNo.ToString() + ","; } // increasing counters for numbering currentNewLineNo++; currentNewNodeNo = currentNewNodeNo + 2; } #endregion //----- Writing nodes and lines to RFEM ---- #region Write nodes, lines and supports to RFEM try { // modification - set model in modification mode, new information can be written data.PrepareModification(); //This version writes lines one-by-one because the data.SetNodes() for array appears not to be working //data.SetNodes(RfemNodeArray); foreach (Node currentRfemNode in RfemNodeList) { data.SetNode(currentRfemNode); } //This version writes lines one-by-one because the data.SetLines() for array appears not to be working foreach (Dlubal.RFEM5.Line currentRfemLine in RfemLineList) { data.SetLine(currentRfemLine); } //Definition of line supports - only is there is input for support: if (rfemLineSupportInput.No != -1) { rfemLineSupportMethodIn.No = currentNewLineSupportNo; rfemLineSupportMethodIn.LineList = createdLinesList; data.SetLineSupport(ref rfemLineSupportMethodIn); } // finish modification - RFEM regenerates the data data.FinishModification(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error - Line Write", MessageBoxButtons.OK, MessageBoxIcon.Error); } #endregion // Releases interface to RFEM model. #region Releases interface to RFEM model = null; // Unlocks licence and releases interface to RFEM application. if (app != null) { app.UnlockLicense(); app = null; } // Cleans Garbage Collector and releases all cached COM interfaces. System.GC.Collect(); System.GC.WaitForPendingFinalizers(); #endregion //output 'success' as true and return the list of the lines; writeSuccess = true; return(RfemLineList); }
/// <summary> /// Method for spliting surfaces with line /// Takes no arguments, because surface and line is selected in RFEM surface /// </summary> public static void splitSurfaces() { IModel model = RFEMconnection.getRFEMconnection(); IModelData modelData = model.GetModelData(); IView view = model.GetActiveView(); //select surface - cast to be used because selectObjects returns generic "object" Common.IO.Log("Select one surface to split!"); List <Surface> selectedSurfaces = RFEMselectOps.selectSurfaces(model); if (selectedSurfaces.Count == 0) { Common.IO.Log(""); return; } Surface selectedSurface = selectedSurfaces[0]; int selectedSurfaceNo = selectedSurface.No; //select line - cast to be used because selectObjects returns generic "object" Common.IO.Log("Select one line to split with!"); List <Line> selectedLines = RFEMselectOps.selectLines(model); if (selectedLines.Count == 0) { Common.IO.Log(""); return; } int splitLineNo = selectedLines[0].No; //get boundary lines of existing surface string boundaryLinesListString = selectedSurface.BoundaryLineList; List <int> boundaryLinesList = ListOperations.objectNumbersToList(boundaryLinesListString); //get boundary lines of split surfaces List <List <int> > newSurfacesBoundLines = getBoundaryLinesOfSplitSurfaces(modelData, boundaryLinesList, splitLineNo); //Define new surfaces using existing surface data as a template Surface newSplitSurface1 = new Surface(); Surface newSplitSurface2 = new Surface(); //first surface will keep the number or original surface RFEMobjectOps.MatchSurfacePropertiesSettings surfMatchPropsSurf1 = new RFEMobjectOps.MatchSurfacePropertiesSettings(); surfMatchPropsSurf1.No = true; //for second one, new number will be assigned RFEMobjectOps.MatchSurfacePropertiesSettings surfMatchPropsSurf2 = new RFEMobjectOps.MatchSurfacePropertiesSettings(); int nextAvailableSurfaceNo = modelData.GetLastObjectNo(ModelObjectType.SurfaceObject) + 1; newSplitSurface2.No = nextAvailableSurfaceNo; //match properties RFEMobjectOps.MatchSurfaceProperties(selectedSurface, ref newSplitSurface1, surfMatchPropsSurf1); RFEMobjectOps.MatchSurfaceProperties(selectedSurface, ref newSplitSurface2, surfMatchPropsSurf2); //convert list of integers to RFEM text, assign these to newly created surfaces newSplitSurface1.BoundaryLineList = ListOperations.objectNumbersToSting(newSurfacesBoundLines[0]); newSplitSurface2.BoundaryLineList = ListOperations.objectNumbersToSting(newSurfacesBoundLines[1]); try { //prepares model for modification and writes data modelData.PrepareModification(); modelData.SetSurface(newSplitSurface1); modelData.SetSurface(newSplitSurface2); //finishes modifications - regenerates numbering etc. modelData.FinishModification(); Common.IO.Log("Surface has been split in two"); } catch (Exception ex) { Common.IO.Log("Error in splitting the surface"); MessageBox.Show(ex.Message, "Error - Surface Write", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { //closing the connection with RFEM RFEMconnection.closeRFEMconnection(model); } }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA, EvaluationUnit unit) { var run = false; var combos = new List <int>(); var mass = 0.0; var modelName = ""; IModel model = null; IModelData data = null; var errorMsg = new List <string>(); DA.GetData(1, ref run); if (run) { if (!DA.GetData(2 + 1, ref modelName)) { Component_GetData.ConnectRFEM(ref model, ref data); } else { Component_GetData.ConnectRFEM(modelName, ref model, ref data); } try { //Calculate Load Combos DA.GetDataList(0, combos); var myCalculation = model.GetCalculation(); myCalculation.Clean(); foreach (var no in combos) { ErrorInfo[] errormsg = myCalculation.Calculate(LoadingType.LoadCombinationType, 1); } // Get EC3 LoadCase var myEC3 = (Dlubal.STEEL_EC3.Module)model.GetModule("STEEL_EC3"); Dlubal.STEEL_EC3.ICase myCaseEC3 = myEC3.moGetCase(1, ITEM_AT.AT_NO); // Get Cross Sections // Select cross sections? var countCS = myCaseEC3.moGetCrossSectionsCount(); for (int i = 0; i < countCS; i++) { Dlubal.STEEL_EC3.CROSS_SECTION myCSEC3 = myCaseEC3.moGetCrossSection(i + 1, ITEM_AT.AT_NO); myCSEC3.Optimization = 1; myCaseEC3.moSetCrossSection(myCSEC3.No, ITEM_AT.AT_NO, myCSEC3); } // Berechnung durchführen var error = myCaseEC3.moCalculate(); //Querschnitt an RFEM übergeben. var myCSECRFEM = new List <CrossSection>(); for (int i = 0; i < countCS; i++) { Dlubal.STEEL_EC3.CROSS_SECTION myCSEC3 = myCaseEC3.moGetCrossSection(i + 1, ITEM_AT.AT_NO); var myCS = data.GetCrossSection(i + 1, ItemAt.AtNo).GetData(); myCS.TextID = myCSEC3.Description; myCS.Description = myCSEC3.Description; myCSECRFEM.Add(myCS); } // Set Data data.PrepareModification(); foreach (var crosec in myCSECRFEM) { data.SetCrossSection(crosec); } data.FinishModification(); // Get steel mass var members = data.GetMembers(); mass = members.Sum(item => item.Weight); } catch (Exception ex) { Component_GetData.DisconnectRFEM(ref model, ref data); throw ex; } Component_GetData.DisconnectRFEM(ref model, ref data); } // Assign Output DA.SetData(0, mass); if (errorMsg.Count != 0) { //errorMsg.Add("List item index may be one unit lower than object number"); AddRuntimeMessage(GH_RuntimeMessageLevel.Error, String.Join(System.Environment.NewLine, errorMsg.ToArray())); } }
private String WriteRfemData(List <Grasshopper.Kernel.Types.GH_ObjectWrapper> RfemNodes) { String StatusMsg = "Status Not set."; // List<Dlubal.RFEM5.Node> RfemNodes = new List<Dlubal.RFEM5.Node>(); // foreach (RfemNodeType rfemNode in RFEMNodesWrapper) // { // Dlubal.RFEM5.Node rfemNode = rfemNode.; // //RfemNodeType rfemNodeWrapper = new RfemNodeType(rfemNode); // RfemNodes.Add(rfemNode); // } // Gets interface to running RFEM application. app = Marshal.GetActiveObject("RFEM5.Application") as IApplication; // Locks RFEM licence app.LockLicense(); // Gets interface to active RFEM model. model = app.GetActiveModel(); // Gets interface to model data. IModelData data = model.GetModelData(); //List<Dlubal.RFEM5.Node> RfemNodeList = new List<Dlubal.RFEM5.Node>(); //Dlubal.RFEM5.Node[] RfemNodeArray = new Dlubal.RFEM5.Node[Rh_pt3d.Count]; try { // Sets all objects to model data. data.PrepareModification(); for (int index = 0; index < RfemNodes.Count; index++) { //Write Nodes Dlubal.RFEM5.Node RfemNodeDlubal; // RfemNodeDlubal.X = RfemNodes[index].x RfemNodeDlubal = (Dlubal.RFEM5.Node)RfemNodes[index].Value; //Dlubal.RFEM5.Node RfemNodeDlubal = RfemNodes[index].; data.SetNode(RfemNodeDlubal); } data.FinishModification(); StatusMsg = "OK"; } catch (Exception ex) { StatusMsg = ex.Message; MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } // Releases interface to RFEM model. model = null; // Unlocks licence and releases interface to RFEM application. if (app != null) { app.UnlockLicense(); app = null; } // Cleans Garbage Collector and releases all cached COM interfaces. System.GC.Collect(); System.GC.WaitForPendingFinalizers(); return(StatusMsg); }
private List <Dlubal.RFEM5.Member> CreateRfemMembers(List <Dlubal.RFEM5.Line> rfemLineMethodIn, string sectionIdMethodIn, string materialIdMethodIn, Dlubal.RFEM5.MemberHinge rfemHingeStartMethodIn, Dlubal.RFEM5.MemberHinge rfemHingeEndMethodIn, double rotationMethodIn, string commentsListMethodIn) { //---- Interface with RFEM, getting available element numbers ---- #region Estabilishing connection with RFEM, getting available element numbers // Gets interface to running RFEM application. IApplication app = Marshal.GetActiveObject("RFEM5.Application") as IApplication; // Locks RFEM licence app.LockLicense(); // Gets interface to active RFEM model. IModel model = app.GetActiveModel(); // Gets interface to model data. IModelData data = model.GetModelData(); // Gets Max node, line , line support numbers int currentNewMemberNo = data.GetLastObjectNo(ModelObjectType.MemberObject) + 1; int currentNewSectionNo = data.GetLastObjectNo(ModelObjectType.CrossSectionObject) + 1; int currentNewMaterialNo = data.GetLastObjectNo(ModelObjectType.MaterialObject) + 1; int currentNewHingeNo = data.GetLastObjectNo(ModelObjectType.MemberHingeObject) + 1; #endregion //---- Defining material, cross section and releases ---- #region Defining material, cross section and releases //define material Dlubal.RFEM5.Material material = new Dlubal.RFEM5.Material(); material.No = currentNewMaterialNo; material.TextID = materialIdMethodIn; material.ModelType = MaterialModelType.IsotropicLinearElasticType; //define cross section CrossSection tempCrossSection = new CrossSection(); tempCrossSection.No = currentNewSectionNo; tempCrossSection.TextID = sectionIdMethodIn; tempCrossSection.MaterialNo = currentNewMaterialNo; //define member hinge numbers if (rfemHingeStartInput.No != -1) { rfemHingeStartInput.No = currentNewHingeNo; } if (rfemHingeEndInput.No != -1) { rfemHingeEndMethodIn.No = currentNewHingeNo + 1; } #endregion //---- Process all lines and create members on those ---- #region Processing all lines, creating RFEM member objects for (int i = 0; i < rfemLineMethodIn.Count; i++) { //test if line exists try { data.GetLine(rfemLineMethodIn[i].No, ItemAt.AtNo); } catch { continue; } //assign member properties Dlubal.RFEM5.Member tempMember = new Dlubal.RFEM5.Member(); tempMember.No = currentNewMemberNo; tempMember.LineNo = rfemLineMethodIn[i].No; tempMember.EndCrossSectionNo = currentNewSectionNo; tempMember.StartCrossSectionNo = currentNewSectionNo; tempMember.TaperShape = TaperShapeType.Linear; tempMember.Rotation.Type = RotationType.Angle; tempMember.Rotation.Angle = rotationMethodIn * (Math.PI / 180); if (rfemHingeStartInput.No != -1) { tempMember.StartHingeNo = currentNewHingeNo; } if (rfemHingeEndInput.No != -1) { tempMember.EndHingeNo = currentNewHingeNo + 1; } tempMember.Comment = commentsListMethodIn; // if -1 is input as section, member is created as rigid, otherwise it is "standard" if (sectionIdInput == "-1") { tempMember.Type = MemberType.Rigid; } else if (sectionIdInput == "0") { tempMember.Type = MemberType.NullMember; } else { tempMember.Type = MemberType.Beam; } RfemMemberList.Add(tempMember); currentNewMemberNo++; } #endregion //---- Writing information in RFEM ---- #region Writing info to RFEM try { // modification - set model in modification mode, new information can be written data.PrepareModification(); //set material, cross section and start&end hinges if (sectionIdInput != "-1") { data.SetMaterial(material); data.SetCrossSection(tempCrossSection); } if (rfemHingeStartInput.No != -1) { data.SetMemberHinge(rfemHingeStartInput); } if (rfemHingeEndInput.No != -1) { data.SetMemberHinge(rfemHingeEndMethodIn); } //This version writes members one-by-one because the data.SetNodes() for array appears not to be working //data.SetMembers(RfemMembers); foreach (Member currentRfemMember in RfemMemberList) { data.SetMember(currentRfemMember); } // finish modification - RFEM regenerates the data data.FinishModification(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error - Member Write", MessageBoxButtons.OK, MessageBoxIcon.Error); } #endregion //---- Releases interface to RFEM model ----- #region Releasing interface to RFEM model = null; // Unlocks licence and releases interface to RFEM application. if (app != null) { app.UnlockLicense(); app = null; } // Cleans Garbage Collector and releases all cached COM interfaces. System.GC.Collect(); System.GC.WaitForPendingFinalizers(); #endregion //output 'success' as true and return member list writeSuccess = true; return(RfemMemberList); }