private DimensionStyles() { this.General = new netDxf.Tables.DimensionStyle("General"); this.General.TextHeight = 3.6; this.General.TextOffset = 1.8; this.General.ArrowSize = 2.4; this.General.LengthPrecision = 0; this.General.DimArrow1 = netDxf.Entities.DimensionArrowhead.ArchitecturalTick; this.General.DimArrow2 = netDxf.Entities.DimensionArrowhead.ArchitecturalTick; this.General.ExtLineExtend = 1.2; this.General.ExtLineOffset = 5; this.Annotation = new netDxf.Tables.DimensionStyle("Annotation"); this.Annotation.TextHeight = 3.6; this.Annotation.ArrowSize = 0; this.Annotation.DimLineOff = true; this.Annotation.ExtLine1Off = true; this.Annotation.ExtLine2Off = true; this.Annotation.LengthPrecision = 0; this.Rbars = new netDxf.Tables.DimensionStyle("Rbars"); this.Rbars.TextHeight = 3.6; this.Rbars.ArrowSize = 0; this.Rbars.DimLineOff = true; this.Rbars.ExtLine1Off = true; this.Rbars.ExtLine2Off = true; this.Rbars.LengthPrecision = 0; }
public netDxf.DxfDocument ToDXFDocument() { PointD[] boundary = this.Boundary; PointD sizeP = boundary[1] - boundary[0]; double longLength = sizeP.ToArray().Max(); netDxf.DxfDocument doc = new netDxf.DxfDocument(netDxf.Header.DxfVersion.AutoCad2007); //標註設定 netDxf.Tables.DimensionStyle StandardDimStyle = doc.DimensionStyles["Standard"]; StandardDimStyle.DIMDEC = (short)3; StandardDimStyle.DIMATFIT = 3; StandardDimStyle.DIMASZ = longLength / 80; StandardDimStyle.DIMTXT = longLength / 120; //依圖層 List <Layer> allLayers = (from entity in this.Entities.Values where entity is Layer select(Layer) entity).ToList(); foreach (var layer in allLayers) { Tuple <netDxf.Tables.Layer, List <netDxf.Entities.EntityObject> > LayerAndEntities = layer.ToDxfEntitiesAndLayer(); netDxf.Tables.Layer dxfLayer = LayerAndEntities.Item1; List <netDxf.Entities.EntityObject> entities = LayerAndEntities.Item2; //doc.Layers.Add(dxfLayer); foreach (var item in entities) { if (item is netDxf.Entities.Dimension) { (item as netDxf.Entities.Dimension).Style = StandardDimStyle; } doc.AddEntity(item); } } //依元素 netDxf.Tables.Layer defualtLayer = new netDxf.Tables.Layer("defualt"); List <IToDXFEntity> Entities = (from entity in this.Entities.Values where entity is IToDXFEntity select(IToDXFEntity) entity).ToList(); foreach (var entity in Entities) { netDxf.Entities.EntityObject dxfEntity = entity.ToDXFEntity(); if (dxfEntity != null) { dxfEntity.Layer = defualtLayer; doc.AddEntity(dxfEntity); } } List <IToDXFEntities> MultEntities = (from entity in this.Entities.Values where entity is IToDXFEntities select(IToDXFEntities) entity).ToList(); foreach (var entity in MultEntities) { foreach (netDxf.Entities.EntityObject item in entity.ToDXFEntities()) { item.Layer = defualtLayer; doc.AddEntity(item); } } return(doc); }