コード例 #1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string  p   = "";
            Point3d sPt = Point3d.Unset;
            bool    b   = false;
            double  tol = 1.0;

            if (!DA.GetData(0, ref p))
            {
                return;
            }
            if (!DA.GetData(1, ref sPt))
            {
                return;
            }
            if (!DA.GetData(2, ref b))
            {
                return;
            }
            DA.GetData(3, ref tol);

            // Recalculate tolerance to be in correct (local) units
            tol *= RhinoUtilities.ScalingFactor();

            if (b)
            {
                // Get raw data
                List <string[, ]> data = ExcelTools.ExcelUtilities.GetAllData2(p);

                if (data.Count != 2)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Excel file containing " + data.Count + " worksheet(s) rather than the expected 2. File correct?");

                    if (data.Count < 2)
                    {
                        return;
                    }
                }

                // Get subsets
                string[,] xyProfileData = GetXYProfileData(data[0]);
                string[,] hProfileData  = GetHeightProfileData(data[1]);

                //Create plane curve
                TrackCurve xyTC   = CreateXYProfileTrackCurve(xyProfileData, tol);
                TrackCurve hTC    = CreateHeightProfileCurve(hProfileData);
                TrackCurve combTC = TrackCurveUtilities.JoinTrackCurves(xyTC, hTC, tol);

                xyTC.Translate((Vector3d)sPt);
                hTC.Translate((Vector3d)sPt);
                combTC.Translate((Vector3d)sPt);

                DA.SetData(0, xyTC);
                DA.SetData(1, hTC);
                DA.SetData(2, combTC);
                //DA.SetData(3, CurveDebug);
            }
        }
コード例 #2
0
        private bool CreateTrackSectionConnection(string trackSectionConnection, Point3d sPt, Curve currCrv, out TrackSection tsc)
        {
            double t;

            if (currCrv.ClosestPoint(sPt, out t, 1 / RhinoUtilities.ScalingFactor()))
            {
                tsc = CreateTrackSectionConnection(trackSectionConnection, sPt, currCrv);
                return(true);
            }
            else
            {
                tsc = null;
                return(false);
            }
        }
コード例 #3
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string  p   = "";
            Point3d sPt = Point3d.Unset;
            bool    b   = false;
            double  tol = 1.0;

            if (!DA.GetData(0, ref p))
            {
                return;
            }
            if (!DA.GetData(1, ref sPt))
            {
                return;
            }
            if (!DA.GetData(2, ref b))
            {
                return;
            }
            DA.GetData(3, ref tol);

            // Recalculate tolerance to be in correct (local) units
            tol *= RhinoUtilities.ScalingFactor();

            if (b)
            {
                string command;
                string arguments = "";

                try
                {
                    XmlDocument document = new XmlDocument();
                    document.Load(p);
                    XmlElement  rootElement = document.DocumentElement;
                    XmlNodeList nodes       = rootElement.ChildNodes;
                    foreach (XmlNode node in nodes)
                    {
                        if (node.Name.Equals("command"))
                        {
                            command = node.InnerText;
                        }
                        else
                        {
                            if (node.Name.Equals("arg"))
                            {
                                if (node.Attributes.Count == 1)
                                {
                                    if (node.Attributes.Item(0).Name.Equals("value"))
                                    {
                                        arguments = arguments + node.Attributes.Item(0).Value + " ";
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }