Exemple #1
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 #2
0
        private static List <List <int> > getBoundaryLinesOfSplitSurfaces(IModelData modelData, List <int> boundaryLinesList, int splitLineNo)
        {
            //get start and end nodes of the splitting line
            Node newLineStartNode = RFEMobjectOps.getLineEndNode(splitLineNo, modelData, RFEMobjectOps.NodePostion.Start);
            Node newLineEndNode   = RFEMobjectOps.getLineEndNode(splitLineNo, modelData, RFEMobjectOps.NodePostion.End);

            // Lists for storing the data of new boundary lines
            List <int> newSplitSurface1BoundLines = new List <int>();
            List <int> newSplitSurface2BoundLines = new List <int>();


            //variables needed for loop
            bool surfaceSwitch = true; //use true for lines in newSurface1 and false for newSurface2

            bool previousLineConnectsToSplitLine = false;
            bool currentLineConnectsToSplitLine  = false;

            //looping through existing boundary lines
            foreach (int srfBoundLine in boundaryLinesList)
            {
                //get start and end node numbers of current boundary line
                Node currentLineStartNode = RFEMobjectOps.getLineEndNode(srfBoundLine, modelData, RFEMobjectOps.NodePostion.Start);
                Node currentLineEndNode   = RFEMobjectOps.getLineEndNode(srfBoundLine, modelData, RFEMobjectOps.NodePostion.End);

                //check if any of endpoints are in the same locaiton as split line star/end points.
                if (
                    currentLineStartNode.No == newLineStartNode.No ||
                    currentLineEndNode.No == newLineStartNode.No ||
                    currentLineStartNode.No == newLineEndNode.No ||
                    currentLineEndNode.No == newLineEndNode.No
                    )
                {
                    currentLineConnectsToSplitLine = true;
                }
                else
                {
                    currentLineConnectsToSplitLine = false;
                }

                //if both this line and previous lines points connects with split line - then start separating the two lists of lines
                if (currentLineConnectsToSplitLine && previousLineConnectsToSplitLine)
                {
                    if (surfaceSwitch == true)
                    {
                        newSplitSurface1BoundLines.Add(splitLineNo);
                    }
                    if (surfaceSwitch == false)
                    {
                        newSplitSurface2BoundLines.Add(splitLineNo);
                    }
                    surfaceSwitch = !surfaceSwitch;
                }


                if (surfaceSwitch == true)
                {
                    newSplitSurface1BoundLines.Add(srfBoundLine);
                }
                if (surfaceSwitch == false)
                {
                    newSplitSurface2BoundLines.Add(srfBoundLine);
                }


                previousLineConnectsToSplitLine = currentLineConnectsToSplitLine;
            }

            //if split line was not picked up in the loop above, it is at the start of the lines list.
            // in such case, just add the split line to the list
            if (!newSplitSurface1BoundLines.Contains(splitLineNo))
            {
                newSplitSurface1BoundLines.Add(splitLineNo);
            }
            if (!newSplitSurface2BoundLines.Contains(splitLineNo))
            {
                newSplitSurface2BoundLines.Add(splitLineNo);
            }

            List <List <int> > splitSurfaceBoundLines = new List <List <int> >();

            splitSurfaceBoundLines.Add(newSplitSurface1BoundLines);
            splitSurfaceBoundLines.Add(newSplitSurface2BoundLines);

            return(splitSurfaceBoundLines);
        }
Exemple #3
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 #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);
            }
        }