Giter VIP home page Giter VIP logo

netdxf's Introduction

netDxf

netDxf Copyright(C) 2009-2023 Daniel Carvajal, licensed under MIT License

Description

netDxf is a .net library programmed in C# to read and write AutoCAD DXF files. It supports AutoCad2000, AutoCad2004, AutoCad2007, AutoCad2010, AutoCad2013, and AutoCad2018 DXF database versions, in both text and binary format.

The library is easy to use and I tried to keep the procedures as straightforward as possible, for example you will not need to fill up the table section with layers, styles or line type definitions. The DxfDocument will take care of that every time a new item is added.

If you need more information, you can find the official DXF documentation here.

Code example:

public static void Main()
{
	// your DXF file name
	string file = "sample.dxf";

	// create a new document, by default it will create an AutoCad2000 DXF version
	DxfDocument doc = new DxfDocument();
	// an entity
	Line entity = new Line(new Vector2(5, 5), new Vector2(10, 5));
	// add your entities here
	doc.Entities.Add(entity);
	// save to file
	doc.Save(file);

	// this check is optional but recommended before loading a DXF file
	DxfVersion dxfVersion = DxfDocument.CheckDxfFileVersion(file);
	// netDxf is only compatible with AutoCad2000 and higher DXF versions
	if (dxfVersion < DxfVersion.AutoCad2000) return;
	// load file
	DxfDocument loaded = DxfDocument.Load(file);
}

Samples and Demos

Are contained in the source code. Well, at the moment they are just tests for the work in progress.

Dependencies and distribution

Multitarget project, predefined frameworks for Net Framework 4.8 and NET 6.0.

Compiling

Visual Studio 2022. The solution file is still usable by Visual Studio 2019 but it does not support NET 6.0. netDxf is compatible with any net version from Net Framework 4.0. If your desired version is not listed among the predefined frameworks manually edit the netdxf.csproj file and set the TargetFrameworks accordingly. When compiling for any of the Net Framework 4 family make sure that the constant NET4X is defined for your selected framework.

Development Status

See changelog.txt or the wiki page for information on the latest changes.

Supported DXF entities

  • 3dFace
  • Arc
  • Circle
  • Dimensions (aligned, linear, radial, diametric, 3 point angular, 2 line angular, arc length, and ordinate)
  • Ellipse
  • Hatch (including Gradient patterns)
  • Image
  • Insert (block references and attributes, dynamic blocks are not supported)
  • Leader
  • Line
  • LwPolyline (light weight polyline)
  • Mesh
  • MLine
  • MText
  • Point
  • Polyline (Polyline2D, Polyline3D, PolyfaceMesh, and PolygonMesh)
  • Ray
  • Shape
  • Solid
  • Spline
  • Text
  • Tolerance
  • Trace
  • Underlay (DGN, DWF, and PDF underlays)
  • Wipeout
  • XLine (aka construction line)

All entities can be grouped. All DXF objects may contain extended data information. AutoCad Table entities will be imported as Inserts (block references). Both simple and complex line types are supported. The library will never be able to read some entities like REGIONs, SURFACEs, and 3DSOLIDs, since they depend on undocumented proprietary data.

netdxf's People

Contributors

chr-schubert avatar dayi-wang avatar djgosnell avatar dyama avatar haplokuon avatar igor-smi avatar ricklove avatar stuyarrow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

netdxf's Issues

Feature request : Add $EXTMIN and $EXTMAX into Header

Thank you very much for this wonderful library firstly.

Recently, I used this library in my project. It seems that the current version doesn't support the DXF header variables of $EXTMIN and $EXTMAX in Header section.
Can you add them in Header section?
And I attached the explanation of these two variables (Autocad 2012) for your reference as follows.

image

Thanks in advance.

VertexFlags information gets lost

Please refer to the following sample-file: mp1.txt

The file contains a single Polyline. The line's vertices have either the SplineVertexFromSplineFitting or the SplineFrameControlPoint flag. When opening my sample file, the DxfReader will eventually convert the Polyline to an LwPolyline object. The problem here is that the flags for each vertex get lost. In my application, I cannot differ between vertex types anymore.

Tested with 2.0.3

Minimum vertex spacing?

I have an array of XY coordinates that I'm attempting to export to dxf. The resulting shape is that of a rough circle with a circumferential resolution of about 0.003" and 4800 points.

If I reduce the resolution by about 20x I am able to create a nice dxf image (image on left). However, any higher resolution results in garbage (image on right). I have tried using lines, polylines, lwpolylines, and a spline with similar results.

dxf issue

What can I do to allow the full resolution? Any advice you can provide would be greatly appreciated!

Thank you,
Jaret

Support for complex linetypes

Hi,

Just a feature request to support complex line types, if it's possible.

In particular I use text in line types to represent contour lines in an export. At the moment I've hacked something in, but it would be really useful for me if netDxf supported line types which contained text.

Thanks,

Quickly make dxf from autocad entities?

At first I saw the front page example and thought, cool, just add acad entities to the dxf doc. Then I realized you add netdxf EntityObjects, not acad entities.
I then thought the clone method would make it easy but realized netdxf has nothing to do with reading dwg items. There are no autocad references, which is half the whole point of the library (you don't need acad to use it).
So now I do want to use it to convert a dwg to dxf. Do I have to make code to fill in netdxf entitiyobjects with acad entity info for each type? Surely someone has already done this at least for testing.
I don't see it though, must I write my own?
thanks

Dxf to Pdf

May I ask if you can suggest me any dxf to pdf converter for printing tonns of drawings?
I'm not sure, you don't have it in netDxf?
Thank you in advance

UCS applied incorrectly?

Hello,

it looks like the new feature "Added the header DrawingVariables UcsOrg, UcsXDir, and UcsYDir." is applied incorrectly.

I have a DXF File here that shows all elements in the XY Plane when I open it in AutoDesk DWG TrueView. When I open it in my Program (using a copy of todays netDxf) all elements show up on the YZ Plane.

DXF Files that are not making use of the UCS Header variables are displayed correctly in my Program.

Autodesk:
image

Me:
image

Regards
Thomas

[Question] How can I extract the ASCII string for a DxfObject (Group code 1000)

How can I extract the ASCII string for a DxfObject (Group code 1000)?

I have a dxf file containing a number of Traces, and am able to extract and manipulate these fine, but each Trace also has some extra meta-data stored in the objects ASCII string (Dxf group code: 1000).

If I open the dxf file with a text editor I can see each trace, and under each trace I can see the contents of the ASCII string (Group code 1000), but I an unable to figure out how to get that ASCII text from within the netDxf library.

Is there a way to do this with netDxf, or do I need to implement it myself?

Discussion here rather than on CodePlex?

Hello,

first of all, Happy New Aear and Thank you for the excellent library. Since the CodePlex is read only -> Is this where discussions on usage may take place or questions may be asked ?

BR

M

Update nuget package

Please, update nuget package. I have a some bug (in reader DXF-files) in your library from nuget (last updated 2 months ago), but if i build project from source code and add this as reference - this bug is fixed.
I think nuget package wasnt updated since a c202cf9 commit.

The LinetypeShepeSegment scale must be greater than zero.

Hello daniel,
can you please have a look at this file.
test2.zip

Net dxf 2.2 throws exception when loading this file. It says that scale of segment can not be 0. I opened that file using bricscad but I do not see what is wrong there. Also both BricsCAD an AutoCAD can open this file.

thank you
Petr

Is it possible to create associated dimensions?

Is it possible to create dimensions that follow changes to the model? Right now I am manually creating dimensions in paperspace, and then overriding the measurement value so that it matches the model length. This doesn't seem quite "right" so I was wondering if I am missing anything.

Code error: font name does not copy from style

MTextFormatingOptions file line 269:

        if (this.fontName != null)
        {
            if (this.bold && this.italic)
                formattedText = string.Format("\\f{0}|b1|i1;{1}", this.fontName, formattedText);
            else if (this.bold && !this.italic)
                formattedText = string.Format("\\f{0}|b1|i0;{1}", this.fontName, formattedText);
            else if (!this.bold && this.italic)
                formattedText = string.Format("\\f{0}|i1|b0;{1}", this.fontName, formattedText);
            else
                formattedText = string.Format("\\F{0};{1}", this.fontName, formattedText);
        }
        else
        {
            if (this.bold && this.italic)
                formattedText = string.Format("\\f{0}|b1|i1;{1}", this.style.FontFamilyName, formattedText);
            if (this.bold && !this.italic)
                formattedText = string.Format("\\f{0}|b1|i0;{1}", this.style.FontFamilyName, formattedText);
            if (!this.bold && this.italic)
                formattedText = string.Format("\\f{0}|i1|b0;{1}", this.style.FontFamilyName, formattedText);
        }

If I don't set the font in MTextFormatingOptions and it isn't italic or bold it will never copy from TextStyle

Point style

Is it possible to apply a point style (let say a cross) when writing a point in a document?

Getting Error in few types of files of hatches, while creating autocad files, in vb.net

I am using this this for writing dfx file using VB.NET
Error: Object reference not set to an instance of an object

Dim boundary As List(Of HatchBoundaryPath) = New List(Of HatchBoundaryPath)() From {New HatchBoundaryPath(New List(Of EntityObject)() From {poly})} Dim hatch As Hatch = New Hatch(HatchPattern.FromFile(Application.StartupPath & "\hatches.pat", project.Layers(i).PolyLine(k).HatchPatName), boundary) hatch.Pattern.Angle = project.Layers(i).PolyLine(k).HatchAngle hatch.Pattern.Scale = project.Layers(i).PolyLine(k).HatchScale

Throwing exception in Dim hatch As Hatch. Some hatches name are shown but few are not like
"ISO11W100"
"ISO12W100"
"ISO09W100"
"ISO13W100"

a new cad/cam app for cabinet doors

Hi Daniel, here what we discussed previously, thnak you for your answer.
-----------------------------------------------------
Here goes a few tips. From your images it seems that you only need to work in 2D with very basic entities like lines, arcs, and polylines; splines perhaps?. I will not recommend you to build your own CAD application too much effort, it is not an easy task, when there is something that can suit your needs, like QCAD, it even has a version focused on CAM to generate G-Code files. The software is very basic but it is cheap too. You can also try the free version of DraftSight.

What I would do is build an application to generate parametrically the drawings, netDxf can help you with that generating DXF files that you can open later in QCAD, kinda like the dynamic blocks in AutoCAD. I am assuming that you might work with a set of designs that can be parameterized for door sizes, margins, arc radius,...; for other designs is no problem drawing them directly with QCAD.
------------------------------
Now my question is ,I am still undcided which CAD app to use to draw kitchen cabinet doors for CNC machining? I am leaning towards CMS IntelliCAD because it is based on IntelliCAD which is a very good CAD app after AutoCAD itself. I can save the line, spline paths separately from dwg, stl etc. as my own data.
Then use this data to construct a toolpath for GCode. I need to check QCAD as you said but CMS IntelliCAD is hard to beat as an AutoCAD clone. What do you think? thnak you

(edited the markdown formatting)

Invalid dxf

I have a dxf file which can be opened with acad, but the netDxf complains about invalid format at MLINESTYLE entry which seems valid according to dxf documentation.

MLINESTYLE
5
9
330
8
100
AcDbMlineStyle
2

70
0
3

62
256
51
90.0
52
90.0
71
0
0

I tried to provide the name at group code 2 but it did not make any difference. What could be the problem?

[Question] Is it possible to link netDxf COM dll to Excel/VBA?

Hello,

For a personal project I'm working on a module that heavily relies on I/O operations with dxf files in a rather simple Excel VBA module. I tried to link a compiled netDXF DLL with COM visibility support and registering in my personal machine following this procedure using Visual Studio Community 2017.

EXCEL is able to identify and reference the DLL and TLB appropriately but I can't manage to call a single function nor parameter from the netDXF , and I somehow feel uneasy that VBA Tooltips (a.k.a intellisense) are not displaying anything for netDxf's functions.

Is it possible to load and work with netDXF as a COM dll in Excel/VBA at all? I'm sure I'm missing some steps along the way and maybe this is not the intended used of the library...

P.S.
I'm not related to the .NET programming env. but I do feel confortable with EXCEL/VBA so I decided to give this a shot, any help in this matter is greatly appreciated.

Cheers,

José D.

Any plans to port this to .net core?

.Net Core is starting to really heat up lately. Really was hoping to use this in a new project but its returning a null when trying to load a file.

Curious if you have any plans to port it?

Page setup data not preserved (PLOTSETTINGS?)

Page setup of template file before saving with netDXF:

image

Page setup after saving with .netDxf:
image

In the zip file there are two files:

  • test.dxf - This is the template file after my program has used .netDxf to generate the model. The plotting information seems gone.
  • testWithPageSetup.dxf - This is the file after I have gone back and added the page setup again (Plot extents, fit to page.)

Output Drawings.zip

dxf Load Exception

Hello

i get an exception on loading a dxf file, because the WidthFactor is set to 300. it's possible to ignore such errors on loading?

rgds

public double WidthFactor
{
get { return this.widthFactor; }
set
{
if (value < 0.01 || value > 100.0)
throw new ArgumentOutOfRangeException(nameof(value), value, "The Text width factor valid values range from 0.01 to 100.");
this.widthFactor = value;
}
}

or

if (degree < 1 || degree > 10)
throw new ArgumentOutOfRangeException(nameof(degree), degree, "The spline degree valid values range from 1 to 10.");

License

Do you mind if you release netDxf under a license such as MPL-2.0 rather than LGPL-2.1, so that it will be easier to use?

DXF-Reader

Hello,

I would like to process DXF-Drawings created in SolidWorks.

I found out that a drawing apart from the header potentially consists of inserts, blocks and geometries (circles,...).
I parsed geometries in my drawing -> I found circles with centers that seem to be in paper coordinates since the numbers change when I move the view before exporting to dxf :
Console.WriteLine(circ.ToString() + "(.Owner= " + circ.Owner + ") CX=" + circ.Center.X + " CY=" +
circ.Center.Y);
Circle(.Owner= *Model_Space) CX=196,0103171922 CY=84,4324113898
Circle(.Owner= *Model_Space) CX=198,7291570945 CY=92,8001401971
Circle(.Owner= *Model_Space) CX=200,377803623 CY=101,44264796

I wanted to see the coordinates not in paper coordinates but in "view" or "part" coordinates.
The circles are owned by a block called Model_Space which seems to have its origin at (0,0).
Console.WriteLine("
************************************");
Console.WriteLine("blocks");
foreach (netDxf.Blocks.Block block in dxfLoad.Blocks)
{
Console.WriteLine("Name=" + block.ToString());
{
Console.WriteLine(block.ToString() + ".Origin.X=" + block.Origin.X);
Console.WriteLine(block.ToString() + ".Origin.Y=" + block.Origin.Y);
Console.WriteLine(block.ToString() + ".Origin.Z=" + block.Origin.Z);
}
}


blocks
Name=*Model_Space
*Model_Space.Origin.X=0
*Model_Space.Origin.Y=0
*Model_Space.Origin.Z=0
Name=*Paper_Space
*Paper_Space.Origin.X=0
*Paper_Space.Origin.Y=0
*Paper_Space.Origin.Z=0
Name=*Paper_Space0
*Paper_Space0.Origin.X=0
*Paper_Space0.Origin.Y=0
*Paper_Space0.Origin.Z=0
Name=SW_CENTERMARKSYMBOL_0
SW_CENTERMARKSYMBOL_0.Origin.X=0
SW_CENTERMARKSYMBOL_0.Origin.Y=0
SW_CENTERMARKSYMBOL_0.Origin.Z=0


If I subtract the Origin of the one and only Insert in the drawing I don't get correct values either.

A workaround could be a cirlcle with another linetype denoting the origin of the "view" or the part.

Is there a better alternative ?

best regards

M

Dimension Style Dataloss

Steps to reproduce:

  • Create and save blank dxf file with netDxf
  • Open with autocad LT or draft sight
  • Add a new Dimension Style - set Dimension text placement to centered for both vertical and horizontal
  • Set linear dimension precision to four decimal places
  • Save as dxf
  • Reopen and save using netDxf
  • Open file in autocad lt / draftsight
  • Check you Dimension style - the name will be the same but the centering and precision values are lost and defaulted.

Interest in supporting older DXF versions

I have project which needs to work with DXF files, however, we cannot always ensure that the DXF is in 2000 or newer format. Is it possible to extend the library to handle older versions of DXF in ASCII format?Is that a long-range plan for the library at all?

PolygonalVertexes question

I think all classes that implement PolygonalVertexes function need refactoring

for instance, Arc entity:
public IEnumerable PolygonalVertexes(int precision)
{
if (precision < 2)
throw new ArgumentOutOfRangeException(nameof(precision), precision, "The arc precision must be greater or equal to three");

        List<Vector2> ocsVertexes = new List<Vector2>();
        double start = this.startAngle*MathHelper.DegToRad;
        double end = this.endAngle*MathHelper.DegToRad;
        if (end < start) end += MathHelper.TwoPI;
        double delta = (end - start)/precision;
        for (int i = 0; i <= precision; i++)
        {
            double angle = start + delta*i;
            double sine = this.radius*Math.Sin(angle);
            double cosine = this.radius*Math.Cos(angle);
            ocsVertexes.Add(new Vector2(cosine, sine));
        }

        return ocsVertexes;
    }

should be

public IEnumerable PolygonalVertexes(int precision)
{
if (precision < 2)
throw new ArgumentOutOfRangeException(nameof(precision), precision, "The arc precision must be greater or equal to three");

        double start = this.startAngle*MathHelper.DegToRad;
        double end = this.endAngle*MathHelper.DegToRad;
        if (end < start) end += MathHelper.TwoPI;
        double delta = (end - start)/precision;
        for (int i = 0; i <= precision; i++)
        {
            double angle = start + delta*i;
            double sine = this.radius*Math.Sin(angle);
            double cosine = this.radius*Math.Cos(angle);
            yield return new Vector2(cosine, sine); //<=== no List<Vector2> needed
        }
    }

circle entity:

public List PolygonalVertexes(int precision) // why List
{
if (precision < 3)
throw new ArgumentOutOfRangeException(nameof(precision), precision, "The circle precision must be greater or equal to three");

        List<Vector2> ocsVertexes = new List<Vector2>();

        double delta = MathHelper.TwoPI/precision;

        for (int i = 0; i < precision; i++)
        {
            double angle = delta*i;
            double sine = this.radius*Math.Sin(angle);
            double cosine = this.radius*Math.Cos(angle);
            ocsVertexes.Add(new Vector2(cosine, sine));
        }
        return ocsVertexes;
    }

should be

public IEnumerable PolygonalVertexes(int precision)
{
if (precision < 3)
throw new ArgumentOutOfRangeException(nameof(precision), precision, "The circle precision must be greater or equal to three");

       // List<Vector2> ocsVertexes = new List<Vector2>();
        double delta = MathHelper.TwoPI/precision;

        for (int i = 0; i < precision; i++)
        {
            double angle = delta*i;
            double sine = this.radius*Math.Sin(angle);
            double cosine = this.radius*Math.Cos(angle);
            yield return new Vector2(cosine, sine);
        }
    }

sorry for code formatting, it is broken) parser ate IEnumerable "< " Vector2 " >"

Question : block rotation

Hi there,

I'v been searching all over but did not find something to help me out.

i load a block and place that on specific points, something like this :
var newBLock =(netDxf.Blocks.Block) block.Clone(); Insert nestedInsert = new Insert(newBLock) { Position = position, Normal = normal, Rotation = rotation }; nestedInsert.TransformAttributes(); document.AddEntity(nestedInsert);

This way i specify an normal and a rotation value.
However i would like to rotate the inserted block over another axis, how can this be done?
i can only rotate an block one axis right ?

Also why is the rotation not a property (like position and scale) ?

Best regards,

How to use UCS custom perspective to draw a circle

I created a UCS, how to draw an entity, such as a circle, in this custom coordinate system
I drew a box and wanted to draw a circle on the side of the box, like a window on the side.

` DxfDocument dxf = new DxfDocument();
UCS ucs1 = UCS.FromXAxisAndPointOnXYplane("USER1", new Vector3(box.length, 0, 0)
, new Vector3(box.length, 0, box.deep)
, new Vector3(box.length, box.width, 0));
dxf.UCSs.Add(ucs1);

        //Draw a Circle in the ucs1`

Operating on the IsFrozen Property of layers in Viewport

I have created a viewport in a layout and use it to see the objects from the model-space. But I didn't find a way to get the layers of the viewport, and because of this I can't control the IsFrozen property of the layers. So is there a way to freeze a layer in the viewport? Thank you!

Using the library in Unity2017

I have an issue for using the library in Unity2017,when I new DxfDocument have an error "Failure has occurred while loading a type".I thought the Unity probably use .net framework3.5 and netdxf use 4.5,so I convert netdxf to .net framework 3.5, but it does not work.
Has any one have a way to do this?
here is the error report:

TypeLoadException: Failure has occurred while loading a type.
netDxf.DxfDocument.AddDefaultObjects () (at <703e308ee7344ce798f3d765ee824ef9>:0)
netDxf.DxfDocument..ctor (netDxf.Header.HeaderVariables drawingVariables, System.Boolean createDefaultObjects) (at <703e308ee7344ce798f3d765ee824ef9>:0)
netDxf.DxfDocument..ctor (netDxf.Header.HeaderVariables drawingVariables) (at <703e308ee7344ce798f3d765ee824ef9>:0)
netDxf.DxfDocument..ctor () (at <703e308ee7344ce798f3d765ee824ef9>:0)
cadTest.LinearDimensionTest () (at Assets/Scripts/cadTest.cs:497)
cadTest.Update () (at Assets/Scripts/cadTest.cs:34)

Error in netDxf.Entities.line

I have a project creating a dxf and writing something in it. In my computer, where I have installed visual studio, the project runs Ok, even running the installed .exe. But when I try to run the EXE in other computers it hangs giving my an error in "For each line as netDxf.Entities.Line in dxf.Lines" . Any clue what I´m doing wrong?

This is part of my code...

Dim dxf as New netdxf.dxfdocument Dim n as integer=0 Dxf= DxfDocument.Load(Me.OutfileDXF) For each line as netDxf.Entities.Line in dxf.Lines …..

Error in UserText property

Hi,

When I to suppress the text of a Dimension (one blank space) sends an error.

This code line sends an error:

dim.UserText = " ";

I had to correct it in the following way:

List<string> texts = FormatDimensionText(measure, dim.DimensionType, dim.UserText, style, dim.Owner);

if (texts.Count == 0) texts.Add(dim.UserText); <- I added this line of code

MText mText = DimensionText(Vector2.Polar(midDim, style.TextOffset*style.DimScaleOverall, textRot + MathHelper.HalfPI), MTextAttachmentPoint.BottomCenter, textRot, texts[0], style);

With this it works well, but, is there any other solution?

Regards

Insert Exploding

I see where the code was planned on being included but when uncommented and used, the results are incorrect.
Is there any method implemented that will allow for the exploding of inserts?
Or any idea of an equation that would properly position each item in the insert?

The outputstream.Position does not exist

stream.Position = 0;

e.g. dxfDoc.write(context.Response.OutputStream) will raise this error

EDIT: I add a parameter public void Write(Stream stream, DxfDocument document, bool binary, bool isRewind = true) and if (isRewind) stream.Position = 0;

no rewind need for outputstream dxfDoc.write(context.Response.OutputStream, false, false)

How to set default ZOOM EXTENT?

Hi, I've successfully created a dxf file.
But the question is I can't find a way to set view extent, here is what I'm trying:

var dxf = new DxfDocument();
var layout = dxf.Layouts.First();
layout.MinExtents = new Vector3(minX, minY, 0);
layout.MaxExtents = new Vector3(maxX, maxY, 0);
layout.MinLimit = new Vector2(minX, minY);
layout.MaxLimit = new Vector2(maxX, maxY);
dxf.Save(savePath);

However, nothing changes. Any help is appreciated.


PS: I'm viewing dxf file on AutoCAD 2017.

when dxf code ($DWGCODEPAGE )is gb2312,load dxf doc will get exception

location:DxfReader.cs
if (isUnicode)
encoding = Encoding.UTF8;
else
{
// if the file is not UTF-8 use the code page provided by the dxf file
if (string.IsNullOrEmpty(dwgcodepage))
encoding = Encoding.GetEncoding(Encoding.Default.WindowsCodePage); // use the default windows code page, if unable to read the code page header variable.
else
{
int codepage;
//encoding = Encoding.GetEncoding(!int.TryParse(dwgcodepage.Split('_')[1], out codepage) ? Encoding.Default.WindowsCodePage : codepage);
encoding = Encoding.GetEncoding("GB2312");// my code
//这里出错 索引超出了数组边界
}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.