-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DxfLwPolyline not correctly saved and loaded #87
Comments
The short answer to your problem is this: DxfFile dxfFile = new DxfFile();
dxfFile.Header.Version = DxfAcadVersion.R14; // <-- add this line As a longer-term problem, others have suggested that |
What if unsupported entities cause exceptions in debug build, while be simply skipped in release build? // I have no idea if nuget allows developers to release packages more than one configurations |
As far as I know NuGet doesn't allow the Debug/Release distinction. I also don't want to break anybody by changing Change this: public void Save(Stream stream) to this: public IEnumerable<DxfWarning> Save(Stream stream) where That way existing users aren't getting exceptions, but they can optionally check the diagnostics if they like? I'm also going to tag @nzain on this as he's given me great feedback in the past. |
Maybe in some cases, a save operation needs to be aborted or rolled back when warnings/errors occur. Personally, I have come up with an idea just now that, adding events for A sample may like: public enum OperationContinuation
{
Continue,
Throw,
RollBack,
}
public delegate OperationContinuation SavingWarningHandler(IEnumerable<DxfWarning> warnings);
public delegate Task<OperationContinuation> SavingWarningAsyncHandler(IEnumerable<DxfWarning> warnings);
public void Save(Stream stream);
public void Save(Stream stream, SavingErrorHandler handler);
public Task SaveAsync(Stream stream, SavingWarningAsyncHandler handler); |
I guess this depends on the use case. In my scenario, I would use the very same fraction of the API (add polylines in different colors/layers) for 99% of my tasks with little/zero user interaction. Once I've learned how to If end-users have a deeper interface into the library to possibly create invalid objects that would throw on Something like this public void Save(Stream stream, Action<DxfWarning> warningCallback); would give developers a lot of flexibility. I could be lazy and call like this dxfFile.Save(stream, w => { throw new Exception(w.ToString()); } ); or write to some log file and let the method continue. Or show a ok/cancel popup to the user, let him decide. |
Any callback could potentially throw (intentionally or not) on the consumers side. If the callback throws, this library should not have any resources (stream or similar) open - or close them via |
I like the idea of For the initial pass I think I'll just write to the stream and issue the callback whenever necessary and not worry about pre-checking the file; that will get expensive and I don't think there will be much benefit. I'll start working on this as soon as I get a chance. |
Issue was here: ixmilia/dxf#87 I needed to set a newer version in the header
I have codes like above.
By setting breakpoints, there is 1 entity in
dxfFile.Entities
whendxfFile.Save
is called.However, when the file gets read by calling
DxfFile.Load
, there is nothing in the entity set.I have tested that entities of type
DxfLine
,DxfCircle
,DxfArc
, and evenDxfPolyline
can be correctly exported, but entities of typeDxfLwPolyline
are always missing when load from file streams.The text was updated successfully, but these errors were encountered: