Example #1
0
 void Save2DSurface(string filename)
 {
     try
     {
         List <DwgEntity> entityList = new List <DwgEntity>();
         var surface = model2D.GetSurface();
         for (int i = 0; i < surface.Values.GetUpperBound(0) - 1; i++)
         {
             for (int j = 0; j < surface.Values.GetUpperBound(1) - 1; j++)
             {
                 double  x1   = meshSize * i;
                 double  y1   = meshSize * j;
                 double  z1   = surface.Values[i, j].Depth;
                 double  x2   = meshSize * i + 1;
                 double  y2   = meshSize * j;
                 double  z2   = surface.Values[i + 1, j].Depth;
                 DXFLine line = new DXFLine(x1, y1, z1, x2, y2, z2);
                 entityList.Add(line);
             }
         }
         DxfFileBuilder.Save(entityList, filename);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #2
0
        public void stlFileParser_openAscii_createPointgrid()
        {
            string  filename  = "RECT-TEST-1.STL";
            StlFile file      = StlFileParser.Open(filename);
            var     pointList = new List <DwgEntity>();

            foreach (Triangle tri in file)
            {
                pointList.AddRange(tri.AsPointGrid(.1));
            }
            DxfFileBuilder.Save(pointList, "dxffromStl.dxf");
            Assert.AreEqual(1397, pointList.Count, 100);
        }
        static public void SaveDXF(CartData strip, string fileName, IProgress <int> progress)
        {
            try
            {
                var outputFilename = BuildFileName(fileName, "", ".dxf");
                List <GeometryLib.DwgEntity> entityList = new List <GeometryLib.DwgEntity>();
                List <string> DwgConverterLibList       = new List <string>();

                for (int i = 1; i < strip.Count - 1; i++)
                {
                    entityList.Add(new DXFLine(strip[i], strip[i + 1]));
                }

                DxfFileBuilder.Save(entityList, outputFilename, progress);
            }
            catch (Exception)
            {
                throw;
            }
        }
        private void saveFootprint(List <AbmachPoint> ptlist, int runNumber)
        {
            var entityList = new List <DwgEntity>();

            foreach (AbmachPoint v in ptlist)
            {
                DXFPoint pt = new DXFPoint(v.Position);
                if (v.JetHit)
                {
                    pt.DxfColor = DxfColor.Cyan;
                    entityList.Add(pt);
                }
                else
                {
                    pt.DxfColor = DxfColor.Grey;
                    entityList.Add(pt);
                }
            }
            string fileName = "footprintRun." + runNumber.ToString() + ".dxf";

            DxfFileBuilder.Save(entityList, fileName);
        }
Example #5
0
        void save3DSurface(string dxfFilename, string txtFileName)
        {
            try
            {
                ISurface <AbmachPoint> surfOut = model3D.GetSurface();

                List <AbmachPoint> ptlist     = surfOut.GetAllPoints();
                List <DwgEntity>   entityList = new List <DwgEntity>();
                var pointList = new List <string>();
                foreach (AbmachPoint v in ptlist)
                {
                    pointList.Add(v.Position.X.ToString("f4") + " " + v.Position.Y.ToString("f4") + " " + v.Position.Z.ToString("f4"));
                    DXFPoint pt = new DXFPoint(v.Position);
                    if (v.JetHit)
                    {
                        if (v.Normal.Length != 0.0)
                        {
                            double  scaleF = meshSize / v.Normal.Length;
                            DXFLine line   = new DXFLine(v.Position.X, v.Position.Y, v.Position.Z, scaleF * v.Normal.X + v.Position.X, scaleF * v.Normal.Y + v.Position.Y, scaleF * v.Normal.Z + v.Position.Z);
                            entityList.Add(line);
                        }
                        pt.DxfColor = DxfColor.Green;
                        entityList.Add(pt);
                    }
                    else
                    {
                        pt.DxfColor = DxfColor.Red;
                        entityList.Add(pt);
                    }
                }
                FileIO.Save(pointList, txtFileName);
                DxfFileBuilder.Save(entityList, dxfFilename);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }