static void doDXF(List<PolylineVertex> vertexes, double[] x) { // create a dxf for those who want to "see" the calibration netDxf.DxfDocument dxf = new netDxf.DxfDocument(); Polyline polyline = new Polyline(vertexes, true); polyline.Layer = new Layer("polyline"); polyline.Layer.Color.Index = 24; dxf.AddEntity(polyline); var pnt = new Point(new netDxf.Vector3(-(float) x[0], -(float) x[1], -(float) x[2])); pnt.Layer = new Layer("new offset"); pnt.Layer.Color.Index = 21; dxf.AddEntity(pnt); dxf.Save(Settings.GetUserDataDirectory() + "magoffset.dxf"); log.Info("dxf Done " + DateTime.Now); }
public void ToDxf() { netDxf.DxfDocument dxf = new netDxf.DxfDocument(); SaveFileDialog fdlg = new SaveFileDialog { DefaultExt = "DXF", Title = "Save As", Filter = "DXF(*.DXF)|.DXF", FilterIndex = 1, FileName = "Untitled", AddExtension = true, }; bool?result = fdlg.ShowDialog(); if (result.HasValue && result.Value) { foreach (IFigure f in Figures) { if (f is FigureBase) { var figure = f as FigureBase; //var boxculvert = (Shopdrawing.Structures.Culvert.BoxCulvertSection)f; figure.ToDxf(dxf); } } } dxf.Save(fdlg.FileName); }
/// <summary> /// Renders the model in dxf to the returned stream. /// </summary> /// <param name="model">The model to render</param> public Stream Render(Model model) { var doc = new netDxf.DxfDocument(netDxf.Header.DxfVersion.AutoCad2018); var context = new DxfRenderContext(); context.Model = model; foreach (var element in model.Elements.Values) { if (!_dxfCreators.TryGetValue(element.GetType(), out var converter)) { continue; } if (converter.TryToCreateDxfEntity(element, context, out var entity)) { doc.AddEntity(entity); } } var stream = new MemoryStream(); doc.Save(stream); return(stream); }
static void Main(string[] args) { var tol = 1e-8; var R = 100; var dxf = new netDxf.DxfDocument(); var ang = 0d; var angStep = 10d.ToRad(); var angElev = 20d.ToRad(); var o = Vector3D.Zero; var p = new Vector3D(R, 0, 0); Circle3D circ = null; while (ang < 2 * PI) { var l = new Line3D(o, p.RotateAboutZAxis(ang)); var l_ent = l.DxfEntity; l_ent.Color = netDxf.AciColor.Cyan; dxf.AddEntity(l_ent); var arcCS = new CoordinateSystem3D(o, l.V, Vector3D.ZAxis); var arc = new Arc3D(tol, arcCS, R, 0, angElev); var arc_ent = arc.DxfEntity; arc_ent.Color = netDxf.AciColor.Yellow; dxf.AddEntity(arc_ent); var arc2CS = new CoordinateSystem3D(l.To - R * Vector3D.ZAxis, Vector3D.ZAxis, Vector3D.Zero - l.To); var arc2 = new Arc3D(tol, arc2CS, R, 0, PI / 2); var arc2_ent = arc2.DxfEntity; arc2_ent.Color = netDxf.AciColor.Green; dxf.AddEntity(arc2_ent); if (circ == null) { circ = new Circle3D(tol, CoordinateSystem3D.WCS.Move(Vector3D.ZAxis * arc.To.Z), arc.To.Distance2D(Vector3D.Zero)); var circ_ent = circ.DxfEntity; circ_ent.Color = netDxf.AciColor.Yellow; dxf.AddEntity(circ_ent); } ang += angStep; } dxf.Viewport.ShowGrid = false; dxf.Save("output.dxf", isBinary: true); }
public virtual void ExportDXF_netDxf(Part DXF2Export, string filename, bool openFolder, bool openFile) { netDxf.DxfDocument dxf = DXF2Export.ToDXFDocument(); dxf.Save(filename); if (openFolder) { string path = System.IO.Path.GetDirectoryName(filename); System.Diagnostics.Process.Start(path); } if (openFile) { System.Diagnostics.Process.Start(filename); } }