?? dxfexport.cs
字號:
?using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
namespace DXFFile
{
public class DXFExport
{
// Fields
public static float accuracy = 1E-06f;
public static bool alternativeBlack = true;
public static AutoCADVersion autoCADVer = AutoCADVersion.R2000;
private ArrayList blkRecs = new ArrayList();
private string block;
private bool blockMode;
private ArrayList blocks = new ArrayList();
public ArrayList current = new ArrayList();
private DXFLayer currentLayer;
public static int[] DXFLineWeights = new int[] {
0, 5, 9, 13, 15, 0x12, 20, 0x19, 30, 0x23, 40, 50, 0x35, 60, 70, 80,
90, 100, 0x6a, 120, 140, 0x9e, 200, 0xd3
};
public int ellipses;
private ArrayList entities = new ArrayList();
private ArrayList figuresList;
public float fOffset;
private int handle;
public static bool isParseWhite = false;
private ArrayList layers;
private DXFPoint limMax = new DXFPoint();
private DXFPoint limMin = new DXFPoint();
private ArrayList lTypes = new ArrayList();
private string nameCurrentLayer;
public static float offsetX = 0f;
public static float offsetY = 0f;
public float penWidthRatio;
public static bool use01MM = false;
// Methods
public DXFExport()
{
this.current = this.entities;
this.figuresList = new ArrayList();
this.handle = 0x20;
this.layers = new ArrayList();
this.layers.Add(new DXFLayer("0"));
this.SetCurrentLayer((DXFLayer)this.layers[0]);
this.fOffset = 300f;
this.penWidthRatio = -1f;
}
public void Add3DPoint(int code, DXFPoint p)
{
this.AddPoint(code, p);
if (p.Z != 0f)
{
this.AddFloat(code + 20, p.Z);
}
}
public void AddArc(DXFData Data)
{
DXFArc arc = new DXFArc(Data);
arc.Layer = this.nameCurrentLayer;
if (this.blockMode)
{
arc.ExportAsDXF(this);
}
else
{
this.figuresList.Add(arc);
}
}
public void AddCircle(DXFData Data)
{
DXFEllipse ellipse = new DXFEllipse(Data, false);
ellipse.Layer = this.nameCurrentLayer;
if (this.blockMode)
{
ellipse.ExportAsDXF(this);
}
else
{
this.figuresList.Add(ellipse);
}
}
public void AddColor(DXFData Data)
{
if ((Data.color != 0x100) && (Data.color != 0))
{
this.AddInt(0x3e, Data.color);
}
}
public void AddEllipse(DXFData Data)
{
DXFEllipse ellipse = new DXFEllipse(Data, true);
ellipse.Layer = this.nameCurrentLayer;
if (this.blockMode)
{
ellipse.ExportAsDXF(this);
}
else
{
this.figuresList.Add(ellipse);
}
}
public void AddFloat(int code, float Value)
{
string str = this.SpecialFormat(code);
this.current.Add(str);
str = "" + Value;
this.current.Add(str.Replace(',', '.'));
}
public void AddHandle()
{
string str = string.Format("{0:X}", this.handle);
this.AddString(5, str);
this.handle++;
}
public void AddHatch(DXFData Data)
{
DXFHatch hatch = new DXFHatch(Data);
hatch.Layer = this.nameCurrentLayer;
if (this.blockMode)
{
hatch.ExportAsDXF(this);
}
else
{
this.figuresList.Add(hatch);
}
}
public void AddInt(int code, int Value)
{
string str = this.SpecialFormat(code);
this.current.Add(str);
this.current.Add("" + Value);
}
public void AddLine(DXFData Data)
{
DXFLine line = new DXFLine(Data);
line.Layer = this.nameCurrentLayer;
if (this.blockMode)
{
line.ExportAsDXF(this);
}
else
{
this.figuresList.Add(line);
}
}
public void AddLType(string aName, float[] aParts)
{
int num;
float num2 = 0f;
ArrayList current = new ArrayList();
for (num = 0; num < aParts.Length; num++)
{
num2 += Math.Abs(aParts[num]);
}
current = this.current;
this.current = this.lTypes;
try
{
this.AddName("LTYPE", "AcDbLinetypeTableRecord");
this.lTypes.Add(" 2");
this.lTypes.Add(aName);
this.lTypes.Add(" 3");
this.lTypes.Add("");
this.lTypes.Add(" 70");
this.lTypes.Add("0");
this.lTypes.Add(" 72");
this.lTypes.Add("65");
this.lTypes.Add(" 73");
this.lTypes.Add("" + aParts.Length);
this.lTypes.Add(" 40");
this.lTypes.Add("" + num2);
for (num = 0; num < aParts.Length; num++)
{
this.lTypes.Add(" 49");
this.lTypes.Add("" + aParts[num]);
this.lTypes.Add(" 74");
this.lTypes.Add("0");
}
}
finally
{
this.current = current;
}
}
public void AddMText(DXFData Data)
{
DXFMText text = new DXFMText(Data);
text.Layer = this.nameCurrentLayer;
if (this.blockMode)
{
text.ExportAsDXF(this);
}
else
{
this.figuresList.Add(text);
}
}
public void AddName(string aName, string aSub)
{
this.current.Add(" 0");
this.current.Add(aName);
this.AddHandle();
if (aName == DXFTables.sHatchEntity)
{
this.current.Add("330");
this.current.Add("1F");
}
this.current.Add("100");
if ((this.current == this.lTypes) || (this.current == this.blkRecs))
{
this.current.Add("AcDbSymbolTableRecord");
}
else
{
this.current.Add("AcDbEntity");
this.current.Add(" 8");
this.current.Add(this.nameCurrentLayer);
}
this.current.Add("100");
this.current.Add(aSub);
}
public void AddPixel(DXFData Data)
{
DXFPixel pixel = new DXFPixel(Data);
pixel.Layer = this.nameCurrentLayer;
if (this.blockMode)
{
pixel.ExportAsDXF(this);
}
else
{
this.figuresList.Add(pixel);
}
}
public void AddPoint(int code, DXFPoint P)
{
this.AddFloat(code, this.MM(P.X));
this.AddFloat(code + 10, this.MM(P.Y));
if (this.current == this.entities)
{
if (this.limMin.X > P.X)
{
this.limMin.X = P.X;
}
if (this.limMin.Y > P.Y)
{
this.limMin.Y = P.Y;
}
if (this.limMax.X < P.X)
{
this.limMax.X = P.X;
}
if (this.limMax.Y < P.Y)
{
this.limMax.Y = P.Y;
}
}
}
public void AddPolyBezier(DXFData Data, int aIndex)
{
DXFPolyBezier bezier = new DXFPolyBezier(Data, aIndex);
bezier.Layer = this.nameCurrentLayer;
if (this.blockMode)
{
bezier.ExportAsDXF(this);
}
else
{
this.figuresList.Add(bezier);
}
}
public void AddPolyLine(DXFData Data, int aIndex)
{
DXFPolyline polyline = new DXFPolyline(Data, aIndex);
polyline.Layer = this.nameCurrentLayer;
if (this.blockMode)
{
polyline.ExportAsDXF(this);
}
else
{
this.figuresList.Add(polyline);
}
}
public void AddRectangle(DXFData Data)
{
DXFRectangle rectangle = new DXFRectangle(Data);
rectangle.Layer = this.nameCurrentLayer;
if (this.blockMode)
{
rectangle.ExportAsDXF(this);
}
else
{
this.figuresList.Add(rectangle);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -