Example #1
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public RRConverter()
 {
     this.obj = new RRObject();
     SetErr();
 }
Example #2
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="a">Rhino object</param>
 public RRConverter(RRObject a)
 {
     this.obj = a;
     SetErr();
 }
Example #3
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);
            }
        }