Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        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);
            }
        }
Exemple #4
0
        /// <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);
            }
        }