private RFEMgeomOps.AlignmentSettings proceessAlignmentProps() { RFEMgeomOps.AlignmentSettings alignSettings = new RFEMgeomOps.AlignmentSettings(); if (xSnap.Checked == true) { alignSettings.X = true; } else { alignSettings.X = false; } if (ySnap.Checked == true) { alignSettings.Y = true; } else { alignSettings.Y = false; } if (zSnap.Checked == true) { alignSettings.Z = true; } else { alignSettings.Z = false; } return(alignSettings); }
private void button6_Click(object sender, EventArgs e) { double tolerance; if (!double.TryParse(alignTolerance.Text, out tolerance)) { IO.Log("Tolerance value must be postive number."); return; } tolerance = Math.Abs(tolerance); RFEMgeomOps.AlignmentSettings alignSettings = proceessAlignmentProps(); alignSettings.AlignmentType = RFEMgeomOps.AlignmentPlaneType.MultipleFloors; AlignNodes.AlignNodesToPlane(tolerance, alignSettings); }
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); } }