Пример #1
0
        private void okButton_Click(object sender, RoutedEventArgs e)
        {
            // Get the lat and long domain
            latMin = Convert.ToDouble(minLatTextBox.Text);
            latMax = Convert.ToDouble(maxLatTextBox.Text);
            lonMin = Convert.ToDouble(minLonTextBox.Text);
            lonMax = Convert.ToDouble(maxLonTextBox.Text);

            LINE.Geometry.Interval2d topoDomain = new LINE.Geometry.Interval2d(lonMin, lonMax, latMin, latMax);

            // output parameters

            string filePath = fileTextBox.Text;


            if (filePath != null && System.IO.File.Exists(filePath))
            {
                List <List <LINE.Geometry.Point3d> > pts = ElkLib.ProcessTopoFile(filePath, unitScale, topoDomain);

                List <XYZ> points = new List <XYZ>();
                for (int i = 0; i < pts.Count; i++)
                {
                    List <LINE.Geometry.Point3d> rowPoints = pts[i];

                    for (int j = 0; j < rowPoints.Count; j++)
                    {
                        XYZ revPoint = new XYZ(rowPoints[j].X, rowPoints[j].Y, rowPoints[j].Z);
                        points.Add(revPoint);
                    }
                }
                using (Transaction trans = new Transaction(doc, "Elk Create Topography"))
                {
                    trans.Start();

                    if (points.Count > 2)
                    {
                        TopographySurface topo = TopographySurface.Create(doc, points);
                    }
                    trans.Commit();
                }
            }
            Close();
        }
Пример #2
0
        public static Dictionary <string, object> CreateTopo(string filePath, LINE.Geometry.Interval2d location = null)
        {
            // Get the file information
            List <string> fileInfo = Elk.Common.ElkLib.TopoFileInfo(filePath);

            // output parameters
            List <List <Point> > topoPoints = null;
            List <NurbsCurve>    curves     = null;
            NurbsSurface         ns         = null;

            // try to get the scale
            double scale = 1.0;

            try
            {
                scale = Elk.DynamoCommon.GetRevitUnitScale();
            }
            catch { }



            if (filePath != null && System.IO.File.Exists(filePath) && location != null)
            {
                List <List <LINE.Geometry.Point3d> > pts = ElkLib.ProcessTopoFile(filePath, scale, location);

                Point[][] surfPoints = new Point[pts.Count][];
                topoPoints = new List <List <Point> >();
                curves     = new List <NurbsCurve>();
                for (int i = 0; i < pts.Count; i++)
                {
                    List <LINE.Geometry.Point3d> rowPoints = pts[i];
                    List <Point> crvPts = new List <Point>();

                    for (int j = 0; j < rowPoints.Count; j++)
                    {
                        Point dynPoint = Point.ByCoordinates(rowPoints[j].X, rowPoints[j].Y, rowPoints[j].Z);
                        crvPts.Add(dynPoint);
                    }
                    surfPoints[i] = crvPts.ToArray();
                    topoPoints.Add(crvPts);
                    NurbsCurve nc = NurbsCurve.ByPoints(crvPts, 3);

                    //PolyCurve pc = PolyCurve.ByPoints(crvPts, false);
                    curves.Add(nc);
                }
                try
                {
                    ns = NurbsSurface.ByPoints(surfPoints, 3, 3);
                }
                catch
                {
                    ns = null;
                }
                return(new Dictionary <string, object>
                {
                    { "Info", fileInfo },
                    { "Points", topoPoints },
                    { "Curves", curves },
                    { "Surface", ns }
                });
            }
            else
            {
                return(new Dictionary <string, object>
                {
                    { "Info", fileInfo },
                    { "Points", null },
                    { "Curves", null },
                    { "Surface", null }
                });
            }
        }