public void ExportEntity(ExpBlock block, PicEntity entity) { PicTypedDrawable drawable = entity as PicTypedDrawable; ExpLayer layer = null; ExpPen pen = null; if (null != drawable) { pen = _exporter.GetPenByAttribute(LineTypeToExpPen(drawable.LineType)); layer = _exporter.GetLayerByName(string.Format("Layer {0}", drawable.Layer)); } PicSegment seg = entity as PicSegment; if (null != seg) { _exporter.AddSegment(block, layer, pen, seg.Pt0.X, seg.Pt0.Y, seg.Pt1.X, seg.Pt1.Y); } PicArc arc = entity as PicArc; if (null != arc) { // using dxf conversions double ang = arc.AngleEnd - arc.AngleBeg, angd = arc.AngleBeg, ango = arc.AngleEnd - arc.AngleBeg; if (ang < 0.0) { angd += ang; ango = -ang; } else { ango = ang; } _exporter.AddArc(block, layer, pen, arc.Center.X, arc.Center.Y, arc.Radius, angd, angd + ango); } }
public override byte[] GetResultByteArray() { // if no blockref were created, create one from default block if (0 == _exporter._blockRefs.Count) { ExpBlock defblock = _exporter.GetBlockOrCreate("default"); _exporter.CreateBlockRef(defblock); } // generate and return file content return(_exporter.GetResultByteArray()); }
public void ExportEntity(ExpBlock block, PicEntity entity) { PicTypedDrawable drawable = entity as PicTypedDrawable; ExpLayer layer = null; ExpPen pen = null; if (null != drawable) { pen = _exporter.GetPenByAttribute(LineTypeToExpPen(drawable.LineType)); layer = _exporter.GetLayerByName(string.Format("Layer {0}", drawable.Layer)); } PicSegment seg = entity as PicSegment; if (null != seg) { _exporter.AddSegment(block, layer, pen, seg.Pt0.X, seg.Pt0.Y, seg.Pt1.X, seg.Pt1.Y); } PicArc arc = entity as PicArc; if (null != arc) { // using dxf conversions double ang = arc.AngleEnd - arc.AngleBeg, angd = arc.AngleBeg, ango = arc.AngleEnd - arc.AngleBeg; if (ang < 0.0) { angd += ang; ango = -ang; } else { ango = ang; } _exporter.AddArc(block, layer, pen, arc.Center.X, arc.Center.Y, arc.Radius, angd, angd + ango); } PicCotationDistance cotation = drawable as PicCotationDistance; if (null != cotation) { List <Segment> segments = new List <Segment>(); Vector2D textPt = Vector2D.Zero; double textSize = 0.0; cotation.DrawSeg(ref segments, ref textPt, ref textSize); foreach (Segment cotSeg in segments) { _exporter.AddSegment(block, layer, pen, cotSeg.P0.X, cotSeg.P0.Y, cotSeg.P1.X, cotSeg.P1.Y); } _exporter.AddText(block, layer, pen, textPt.X, textPt.Y, cotation.Text); } }
public void ExportEntity(ExpBlock block, PicEntity entity) { PicTypedDrawable drawable = entity as PicTypedDrawable; ExpLayer layer = null; ExpPen pen = null; if (null != drawable) { pen = _exporter.GetPenByAttribute(LineTypeToExpPen(drawable.LineType)); layer = _exporter.GetLayerByName(string.Format("Layer {0}", drawable.Layer)); } PicSegment seg = entity as PicSegment; if (null != seg) _exporter.AddSegment(block, layer, pen, seg.Pt0.X, seg.Pt0.Y, seg.Pt1.X, seg.Pt1.Y); PicArc arc = entity as PicArc; if (null != arc) { // using dxf conversions double ang = arc.AngleEnd - arc.AngleBeg, angd = arc.AngleBeg, ango = arc.AngleEnd - arc.AngleBeg; if (ang < 0.0) { angd += ang; ango = -ang; } else ango = ang; _exporter.AddArc(block, layer, pen, arc.Center.X, arc.Center.Y, arc.Radius, angd, angd+ango); } }
public override void ProcessEntity(PicEntity entity) { PicTypedDrawable drawable = entity as PicTypedDrawable; if (entity is PicSegment || entity is PicArc) { ExpBlock defblock = _exporter.GetBlockOrCreate("default"); ExportEntity(defblock, entity); } PicBlock block = entity as PicBlock; if (null != block) { // create block ExpBlock expBlock = _exporter.CreateBlock(string.Format("Block_{0}", block.Id)); // create _x=0.0 _y=0.0 ExpBlockRef expBlockRef = _exporter.CreateBlockRef(expBlock); // create entities foreach (PicEntity blockEntity in block.Entities) { ExportEntity(expBlock, blockEntity); } } PicBlockRef blockRef = entity as PicBlockRef; if (null != blockRef) { // retrieve previously created block ExpBlock expBlock = _exporter.GetBlock(string.Format("Block_{0}", blockRef.Block.Id)); ExpBlockRef expBlockRef = _exporter.CreateBlockRef(expBlock); expBlockRef._x = blockRef.Position.X; expBlockRef._y = blockRef.Position.Y; expBlockRef._dir = blockRef.Angle; expBlockRef._scaleX = 1.0; expBlockRef._scaleY = 1.0; } }