예제 #1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            bool bc = false;
            bool bs = false;
            bool bd = false;

            #region cheking input params
            if (!DA.GetData(0, ref bc))
            {
                return;
            }
            if (!bc)
            {
                return;
            }

            DA.GetData(1, ref bs);
            DA.GetData(2, ref bd);
            #endregion

            var w = Stopwatch.StartNew();

            RRConverter rrc = new RRConverter();
            rrc.RSTAB2Rhino(bs, bd);
            if (rrc.ErrorCode == 0)
            {
                DA.SetDataList(0, rrc.RRObject.RhinoNodes());
                DA.SetDataList(1, rrc.RRObject.RhinoNodesNo());
                DA.SetDataTree(2, rrc.RRObject.RhinoLinesTree());
                DA.SetDataList(3, rrc.RRObject.RhinoCrSec());
                DA.SetDataTree(4, rrc.RRObject.RhinoMembersTree());
                w.Stop();
                DA.SetData(5, "No Errors occured\nImport time " + (w.Elapsed.TotalMilliseconds / 1000).ToString("~0.00 sec"));
            }
            else
            {
                w.Stop();
                DA.SetDataList(0, null);
                DA.SetDataList(1, null);
                DA.SetDataList(2, null);
                DA.SetDataList(3, null);
                DA.SetDataList(4, null);
                DA.SetData(5, rrc.ErrorCode + " " + rrc.ErrorMessage);
            }
        }
예제 #2
0
        /// <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)
        {
            GH_Structure <GH_Curve> cr = new GH_Structure <GH_Curve>(); // curves tree
            List <Point3d>          ap = new List <Point3d>();          // anchor points
            List <string>           cl = new List <string>();           // cross section list
            double tl = new Double();                                   // tolerance
            bool   xm = false;                                          // export model into RSTAB
            bool   rm = true;                                           // remove structural data

            #region checking input params
            if (!DA.GetDataTree(0, out cr))
            {
                return;
            }
            if (!DA.GetData(1, ref tl))
            {
                tl = -1;
            }
            ;
            if (tl <= 0)
            {
                tl = Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance;
            }
            DA.GetDataList(2, ap);
            DA.GetDataList(3, cl);

            if (!DA.GetData(4, ref xm))
            {
                return;
            }
            if (xm == false)
            {
                return;
            }

            if (!DA.GetData(5, ref rm))
            {
                return;
            }
            #endregion

            var w = Stopwatch.StartNew();

            #region graph creation
            int      pid = 1, bid = 1;
            RRObject ro = new RRObject();
            RRMtrl   mt = new RRMtrl();
            ro.AddMtrl(mt);

            foreach (List <GH_Curve> lc in cr.Branches)
            {
                string dsc = "IPE 100";
                if (cl.Count >= bid)
                {
                    dsc = cl[bid - 1];
                }

                ro.AddCrCs(new RRCrSc {
                    ID = bid, Material = mt, Description = dsc
                });

                // check any curve and build the graph from the points
                foreach (GH_Curve curve in lc)
                {
                    RRNode p1, p2;
                    bool   b1, b2;

                    p1 = p2 = null;
                    b1 = b2 = true;

                    foreach (RRNode rn in ro.Nodes)
                    {
                        Point3d p = rn.GetPoint3d();

                        if (b1)
                        {
                            if (curve.Value.PointAtStart.DistanceTo(p) <= tl)
                            {
                                b1 = false;
                                p1 = rn;
                            }
                        }

                        if (b2)
                        {
                            if (curve.Value.PointAtEnd.DistanceTo(p) <= tl)
                            {
                                b2 = false;
                                p2 = rn;
                            }
                        }

                        if (!b1 && !b2)
                        {
                            break;
                        }
                    }

                    if (b1)
                    {
                        p1 = new RRNode(pid++, curve.Value.PointAtStart);
                        ro.AddNode(p1);
                    }

                    if (b2)
                    {
                        p2 = new RRNode(pid++, curve.Value.PointAtEnd);
                        ro.AddNode(p2);
                    }

                    RREdge re = new RREdge {
                        StartNode = p1, EndNode = p2, CrossSection = ro.CrCss[bid - 1]
                    };
                    ro.AddEdge(re, true);
                }

                bid++;
            }
            #endregion

            RRConverter rrc = new RRConverter(ro);
            rrc.Rhino2RSTAB(ap, tl, rm);

            w.Stop();

            if (rrc.ErrorCode == 0)
            {
                DA.SetData(1, "No Errors occured\nExport time " + (w.Elapsed.TotalMilliseconds / 1000).ToString("~0.00 sec"));
            }
            else
            {
                DA.SetData(1, rrc.ErrorCode + " " + rrc.ErrorMessage);
            }
        }