Giter Site home page Giter Site logo

sofagh / cadability Goto Github PK

View Code? Open in Web Editor NEW
77.0 11.0 25.0 20.79 MB

CADability is a pure .net class library for modeling and analyzing 3d data, both with your code and interactively. It comes with an optional Windows.Forms user interface, which can be adopted to other environments. It does not refer to other 3d modeling libraries. For data exchange you can use STEP, STL or DXF files.

Home Page: https://sofagh.github.io/CADability/CADabilityDoc/articles/general.html

License: MIT License

C# 100.00%
3d 3d-engine csharp step cad dotnet dotnet-standard 3d-modeling cad-model geometrical-entities

cadability's Introduction

CADability

CADability is a .NET class library and a .NET application that implements a 3d CAD system. You can use this library with or without user interface.

Some of the features you might be interested in are:

  • Analyze all data (geometrical entities, attributes) of the CAD model.
  • Data exchange with many CAD databases or file formats (STEP, DWG, DXF, STL)
  • Extensible data model and user interface.
  • Simple Windows.Forms.Control to display the CAD model and integrate it in your application.
  • User interface to interact with the geometric data, select objects, show and modify their properties, do 3d modeling.
  • Parametrics to modify features of solids

The CADability solution is composed of two class libraries and an application:

  • CADability, a dll, which contains all the classes of the geometrical objects, the action classes, the geometrical calculations and algorithms (e.g. 3d modeling), the structure (but not the graphical implementation) of the user interface and some organizational classes.
  • CADability.Forms, a dll, which contains the graphical implementation of the user interface based on Windows.Forms and the connection to the windows platform.
  • CADability.App, an exe, which is a very thin container of CADability.Forms

For your first experience you can simply build and start the solution and try to draw or construct 3d objects. Typically you will replace the CADability.App by your own application or use only the CADability.dll to analyze or compose 3d models.

Here is a quick overview of the organizational classes.

This is an overview of the CAD database, the geometrical entities that make up a model.

And this is the complete table of contents.

License: CADability uses some open source code copied into it source code:

  • a quite old version of Wintellect.PowerCollections: Copyright (c) 2004-2005, Wintellect
  • netDxf library: Copyright (C) 2009-2016 Daniel Carvajal ([email protected])

CADability uses MathNet: http://github.com/mathnet/mathnet-numerics

CADability itself is provided under the MIT license

cadability's People

Contributors

a-dalton avatar davidebazzi avatar dsn27 avatar s-costa avatar sgrohr avatar sofagh avatar stefan-tb avatar syntaxrabbit 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cadability's Issues

BlockRef issue

  1. Create BlockRef via code
  2. Export project to DXF file
  3. Open DXF file again
  4. BlockRef is missing

Only line0 will be shown again.

Code to create a BlockRef

GeoObject.Line line0 = GeoObject.Line.Construct();
line0.StartPoint = new GeoPoint(0, 0);
line0.EndPoint = new GeoPoint(100, 0);
cadControl.CadFrame.Project.SetDefaults(line0);
cadControl.CadFrame.Project.GetActiveModel().Add(line0);

GeoObject.Line line1 = GeoObject.Line.Construct();
line1.StartPoint = new GeoPoint(0, 0);
line1.EndPoint = new GeoPoint(100, 100);
cadControl.CadFrame.Project.SetDefaults(line1);

GeoObject.Line line2 = GeoObject.Line.Construct();
line2.StartPoint = new GeoPoint(0, 100);
line2.EndPoint = new GeoPoint(100, 0);
cadControl.CadFrame.Project.SetDefaults(line2);

GeoObject.Block block = GeoObject.Block.Construct();
block.Add(line1);
block.Add(line2);
cadControl.CadFrame.Project.SetDefaults(block);

GeoObject.BlockRef blockRef = GeoObject.BlockRef.Construct(block);
cadControl.CadFrame.Project.SetDefaults(blockRef);

cadControl.CadFrame.Project.GetActiveModel().Add(blockRef);

grafik

DimensionStyleSelectionPropertyException occurs when creating a new Dimension

CADability.UserInterface.DimensionStyleSelectionPropertyException
  HResult=0x80131600
  Message=no appropriate DimensionStyle available
  Source=CADability
  StackTrace:
   at CADability.UserInterface.DimensionStyleSelectionProperty..ctor(String resourceId, DimensionStyleList list, IDimensionStyle dimensionStyle, EDimType dimType, Boolean includeUndefined) in C:\Development\Repos\SOFAgh\CADability\CADability\DimensionStyleSelectionProperty.cs:line 45
   at CADability.GeoObject.Dimension.GetAttributeProperties(IFrame Frame) in C:\Development\Repos\SOFAgh\CADability\CADability\Dimension.cs:line 2205
   at CADability.Actions.ConstructAction.OnSetAction() in C:\Development\Repos\SOFAgh\CADability\CADability\ConstructAction.cs:line 6424
   at CADability.Actions.ConstrDimensionPoints.OnSetAction() in C:\Development\Repos\SOFAgh\CADability\CADability\ConstrDimensionPoints.cs:line 238
   at CADability.ActionStack.SetAction(Action Action) in C:\Development\Repos\SOFAgh\CADability\CADability\ActionStack.cs:line 118
   at CADability.FrameImpl.SetAction(Action Action) in C:\Development\Repos\SOFAgh\CADability\CADability\Frame.cs:line 781
   at CADability.FrameImpl.OnCommand(String MenuId) in C:\Development\Repos\SOFAgh\CADability\CADability\Frame.cs:line 1318
   at CADability.Forms.CadFrame.OnCommand(String MenuId) in C:\Development\Repos\SOFAgh\CADability\CADability.Forms\CadFrame.cs:line 71
   at CADability.Forms.ToolBars.TagInfo.CADability.UserInterface.ICommandHandler.OnCommand(String MenuId) in C:\Development\Repos\SOFAgh\CADability\CADability.Forms\ToolBars.cs:line 43
   at CADability.Forms.MenuItemWithHandler.OnClick(EventArgs e) in C:\Development\Repos\SOFAgh\CADability\CADability.Forms\MenuManager.cs:line 173
   at System.Windows.Forms.MenuItem.MenuItemData.Execute()
   at System.Windows.Forms.Command.Invoke()
   at System.Windows.Forms.Command.DispatchID(Int32 id)
   at System.Windows.Forms.Control.WmCommand(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at CADability.App.Program.Main(String[] args) in C:\Development\Repos\SOFAgh\CADability\CADability.App\Program.cs:line 19

Action confirm button

When you click on the confirm button of the action it doesn't always work,
this because the click area is smaller than the check button (you see the mouse cursor changing into a hand when you are almost in the middle of the button).
Similar problem with the lock button, in this case the click area is to big.
The click areas are show in red in this image:
image

RecalcDisplayLists is not called

After working some time with Cadability the Display lists are not updated anymore.
In the screenshots you can see that holes become rectangular instead of round and the number 0 is missing from the yellow text.

Most of the time it helps to zoom in/out very far to trigger an update, but this doesn't seem to work here.
But it helps to add a new GeoObject to force an update.

After some digging I could find out that here

if (dirty || (!supressAutoRegeneration && model.displayListPrecision > paintTo3D.Precision))
{ // die Dictionaries Layer->Displaylist neu machen
model.RecalcDisplayLists(paintTo3D);
dirty = true;
}

the dirty flag is always false if this error occurs.
Only after adding a new GeoObject this flag is set to true and the model will update.

Any help would be appreciated.

Incorrect display:
grafik
Missing zero:
grafik
After adding a new line:
grafik

Faulty CADability.GlobalSettings.json

If the file CADability.GlobalSettings.json is faulty the application will hang in an endless loop until an error occurs:

System.IO.IOException
HResult=0x80070020
Message=The process cannot access the file C:\Users\SomeOne\AppData\Local\CADability.GlobalSettings.json' because it is being used by another process

CADability.GlobalSettings_faulty.zip

mscorlib.dll!System.IO.__Error.WinIOError(int errorCode, string maybeFullPath)	Unknown
mscorlib.dll!System.IO.FileStream.Init(string path, System.IO.FileMode mode, System.IO.FileAccess access, int rights, bool useRights, System.IO.FileShare share, int bufferSize, System.IO.FileOptions options, Microsoft.Win32.Win32Native.SECURITY_ATTRIBUTES secAttrs, string msgPath, bool bFromProxy, bool useLongPath, bool checkHost)	Unknown
mscorlib.dll!System.IO.FileStream.FileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share)	Unknown
mscorlib.dll!System.IO.File.Open(string path, System.IO.FileMode mode)	Unknown
CADability.dll!CADability.Settings.LoadGlobalSettings(string FileName) Line 218	C#
CADability.dll!CADability.Settings.Reload() Line 278	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.LoadGlobalSettings(string FileName) Line 222	C#
CADability.dll!CADability.Settings.Reload() Line 278	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.GlobalSettings.get() Line 192	C#
CADability.dll!CADability.Settings.Reload() Line 301	C#
CADability.dll!CADability.Settings.Settings() Line 271	C#
[Native to Managed Transition]	
[Managed to Native Transition]	
CADability.dll!CADability.UserInterface.MRUFiles.GetMRUFiles() Line 48	C#
CADability.dll!CADability.FrameImpl.FrameImpl() Line 304	C#
CADability.dll!CADability.FrameImpl.FrameImpl(CADability.UserInterface.IControlCenter cc, CADability.ICanvas canvas) Line 310	C#
CADability.Forms.dll!CADability.Forms.CadFrame.CadFrame(CADability.Forms.PropertiesExplorer propertiesExplorer, CADability.Forms.CadCanvas cadCanvas, CADability.UserInterface.ICommandHandler commandHandler) Line 51	C#
CADability.Forms.dll!CADability.Forms.CadControl.CadControl() Line 33	C#
CADability.MdiApp.exe!CADability.MdiApp.frmMdiForm.InitializeComponent() Line 32	C#
CADability.MdiApp.exe!CADability.MdiApp.frmMdiForm.frmMdiForm() Line 17	C#
CADability.MdiApp.exe!CADability.MdiApp.MainForm.btnAddMdiChild_Click(object sender, System.EventArgs e) Line 26	C#
System.Windows.Forms.dll!System.Windows.Forms.Control.OnClick(System.EventArgs e)	Unknown
System.Windows.Forms.dll!System.Windows.Forms.Button.OnClick(System.EventArgs e)	Unknown
System.Windows.Forms.dll!System.Windows.Forms.Button.OnMouseUp(System.Windows.Forms.MouseEventArgs mevent)	Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.WmMouseUp(ref System.Windows.Forms.Message m, System.Windows.Forms.MouseButtons button, int clicks)	Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m)	Unknown
System.Windows.Forms.dll!System.Windows.Forms.ButtonBase.WndProc(ref System.Windows.Forms.Message m)	Unknown
System.Windows.Forms.dll!System.Windows.Forms.Button.WndProc(ref System.Windows.Forms.Message m)	Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m)	Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m)	Unknown
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam)	Unknown
[Native to Managed Transition]	
[Managed to Native Transition]	
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData)	Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context)	Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context)	Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm)	Unknown
CADability.MdiApp.exe!CADability.MdiApp.Program.Main() Line 19	C#

GaussNewtonMinimizer 'cube' does not exist in Release mode

Line 2015 static private double cube(double x) { return x * x * x; }
is excluded in Release mode but it is needed by various functions

e.g. Line 415 double sc8 = cube(b) * sc11;

The program can not be compiled.
Error CS0103 The name 'cube' does not exist in the current context CADability C:\Development\Repos\SOFAgh\CADability\CADability\GaussNewtonMinimizer.cs 415

An Ellipse is not imported

File:
ellipse_broken.zip

If you import this DXF file the two ellipses are not added the Model.

The reason is that the Ellipse.HasValidData() returns false because the sweepParameter < Precision.epsa.

grafik

NotImplementedException in CylindricalSurface.OutwardOriented

Reading the property OutwardOriented from a CylindricalSurface fails because of an implicit implementation

        public bool OutwardOriented => toCylinder.Determinant > 0;

and an explicit implementation

        bool ICylinder.OutwardOriented => throw new NotImplementedException();

CADability.GeoVectorException

A GeoVectorException will occure if you select the upper right hole in the drawing and close the application.

DB0CEA9D-BDB3-401D-A69A-7154A05A475E

drawing1.zip

CADability.GeoVectorException
  HResult=0x80131600
  Message=Fehler in der Anwendung.
  Source=CADability
  StackTrace:
   at CADability.GeoVector2D.get_Normalized() in C:\Development\Repos\SOFAgh\CADability\CADability\GeoPoint.cs:line 1451
   at CADability.Curve2D.GeneralCurve2D.MakeTringulation() in C:\Development\Repos\SOFAgh\CADability\CADability\GeneralCurve2D.cs:line 1631
   at CADability.Curve2D.GeneralCurve2D.GetExtent() in C:\Development\Repos\SOFAgh\CADability\CADability\GeneralCurve2D.cs:line 3280
   at CADability.Curve2D.BSpline2D.GetExtent() in C:\Development\Repos\SOFAgh\CADability\CADability\BSpline2D.cs:line 3009
   at CADability.GeoObject.BSpline.GetExtent(Projection projection, ExtentPrecision extentPrecision) in C:\Development\Repos\SOFAgh\CADability\CADability\BSpline.cs:line 3971
   at CADability.Actions.SelectObjectsAction.GetDisplayExtent(Projection projection, IGeoObject geoObject) in C:\Development\Repos\SOFAgh\CADability\CADability\SelectObjectsAction.cs:line 386
   at CADability.Actions.SelectObjectsAction.GetDisplayExtent(Projection projection, GeoObjectList list) in C:\Development\Repos\SOFAgh\CADability\CADability\SelectObjectsAction.cs:line 393
   at CADability.Actions.SelectObjectsAction.RecalcFrameSize(IView vw, Int32& frameLeft, Int32& frameRight, Int32& frameBottom, Int32& frameTop) in C:\Development\Repos\SOFAgh\CADability\CADability\SelectObjectsAction.cs:line 407
   at CADability.Actions.SelectObjectsAction.GetFrameInvalidateRect(IView vw) in C:\Development\Repos\SOFAgh\CADability\CADability\SelectObjectsAction.cs:line 441
   at CADability.Actions.SelectObjectsAction.SetSelectedObjects(GeoObjectList selObj) in C:\Development\Repos\SOFAgh\CADability\CADability\SelectObjectsAction.cs:line 814
   at CADability.Actions.SelectObjectsAction.ClearSelectedObjects() in C:\Development\Repos\SOFAgh\CADability\CADability\SelectObjectsAction.cs:line 859
   at CADability.Actions.SelectObjectsAction.OnInactivate(Action NewActiveAction, Boolean RemovingAction) in C:\Development\Repos\SOFAgh\CADability\CADability\SelectObjectsAction.cs:line 946
   at CADability.ActionStack.RemoveActiveAction() in C:\Development\Repos\SOFAgh\CADability\CADability\ActionStack.cs:line 160
   at CADability.FrameImpl.RemoveActiveAction() in C:\Development\Repos\SOFAgh\CADability\CADability\Frame.cs:line 823
   at CADability.FrameImpl.Dispose() in C:\Development\Repos\SOFAgh\CADability\CADability\Frame.cs:line 797
   at CADability.Forms.CadControl.ParentForm_FormClosed(Object sender, FormClosedEventArgs e) in C:\Development\Repos\SOFAgh\CADability\CADability.Forms\CadControl.cs:line 193
   at System.Windows.Forms.Form.OnFormClosed(FormClosedEventArgs e)
   at System.Windows.Forms.Form.WmClose(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Problem mit Subtract wenn das zu verschneidene Bauteil komplett im Schneidkörper liegt

Ich habe das Problem, dass wenn das zu verschneidende Element komplett im Schneidkörper liegt, dass dann das Objekt nicht verschnitten wird.
Wie kann ich testen ob ein Bauteil komplett in einem anderen liegt?
Weil dann könnte ich das Problem lösen, indem ich diesen test einbaue und das Bauteil lösche, wenn es komplett im Schneidkörper liegt.

Kann mir dabei jemand weiterhelfen?
Vielen Dank
image

ExportStep Failure

The WriteAxis2Placement3d() and WriteAxis1Placement3d() methods call the WriteDefinition() method but place an extra semi-color in the string being passed to WriteDefinition(). This causes a ;; line ending in a STEP file and most programs (the ACIS kernel in particular) throws an error when there is an empty definition.

image

Issue loading projects from stream

There seems to be a bug in restoring projects from a stream in the latest version.

System.NullReferenceException
  HResult=0x80004003
  Message=Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
  Source=CADability
  StackTrace:
   at CADability.Attribute.LayerList.GetAllLayer(Dictionary`2 collect, IGeoObject go) in C:\Development\Repos\SOFAgh\CADability\CADability\LayerList.cs:line 553

go was null
>	CADability.dll!CADability.Attribute.LayerList.GetAllLayer(System.Collections.Generic.Dictionary<string, CADability.Attribute.Layer> collect, CADability.GeoObject.IGeoObject go) Line 553	C#
 	CADability.dll!CADability.Attribute.LayerList.OnUpdateFromProject() Line 509	C#
 	CADability.dll!CADability.Attribute.LayerList.CADability.Attribute.IAttributeList.Update(bool AddMissingToList) Line 406	C#
 	CADability.dll!CADability.Attribute.AttributeListContainer.UpdateLists(CADability.Attribute.IAttributeListContainer container, bool AddMissingToList) Line 122	C#
 	CADability.dll!CADability.Project.System.Runtime.Serialization.IDeserializationCallback.OnDeserialization(object sender) Line 2665	C#
 	mscorlib.dll!System.Runtime.Serialization.ObjectManager.RaiseDeserializationEvent() Line 1110	C#
 	mscorlib.dll!System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Runtime.Serialization.Formatters.Binary.__BinaryParser serParser, bool fCheck, bool isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) Line 208	C#
 	mscorlib.dll!System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, bool fCheck, bool isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) Line 199	C#
 	mscorlib.dll!System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(System.IO.Stream serializationStream) Line 113	C#
 	CADability.dll!CADability.Project.ReadFromStream(System.IO.Stream stream) Line 1444	C#
 	LogiCal.exe!LogiCal.CADModule.frmCAD.LoadSavedDrawing() Line 1285	C#
 	LogiCal.exe!LogiCal.CADModule.frmCAD.frmCAD(XpoLogiCal.Position Position, DevExpress.Xpo.XPCollection collection) Line 134	C#
 	LogiCal.exe!LogiCal.MainForms.Orders.frmAuftrag.riButtonCAD_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) Line 2897	C#
 	DevExpress.XtraEditors.v21.2.dll!DevExpress.XtraEditors.Repository.RepositoryItemButtonEdit.RaiseButtonClick(DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) Line 261	C#
 	DevExpress.XtraEditors.v21.2.dll!DevExpress.XtraEditors.ButtonEdit.OnMouseUp(System.Windows.Forms.MouseEventArgs e) Line 352	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.WmMouseUp(ref System.Windows.Forms.Message m, System.Windows.Forms.MouseButtons button, int clicks)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m)	Unknown
 	DevExpress.Utils.v21.2.dll!DevExpress.Utils.Controls.ControlBase.BaseWndProc(ref System.Windows.Forms.Message m) Line 220	C#
 	DevExpress.XtraEditors.v21.2.dll!DevExpress.XtraEditors.TextEdit.BaseEditWndProc(ref System.Windows.Forms.Message msg) Line 1707	C#
 	DevExpress.XtraEditors.v21.2.dll!DevExpress.XtraEditors.TextEdit.TextEditWorkingStrategy.WndProc(ref System.Windows.Forms.Message msg) Line 181	C#
 	System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam)	Unknown
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context)	Unknown
 	LogiCal.exe!LogiCal.Program.Main() Line 65	C#

NullReferenceException in ImportDxf.CreateHatch

A NRE occures while importing the attached DXF file.

The reason is the casting of the list to an ICollection<IGeoObject>.
If there is no IGeoObject inside the list (like a Hatch) the cast will return null.

What was the intention of this cast? To get rid of all non IGeoObjects?

if (list.Count > 1)
{
GeoObject.Block block = GeoObject.Block.Construct();
block.Set(new GeoObjectList(list as ICollection<IGeoObject>));
return block;
}

128-210.01_neu.zip

System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object
Source=CADability
StackTrace:
at CADability.GeoObject.GeoObjectList..ctor(ICollection`1 list) in C:\Development\Repos\SOFAgh\CADability\CADability\GeoObjectList.cs:line 50

CADability.dll!CADability.GeoObject.GeoObjectList.GeoObjectList(System.Collections.Generic.ICollection<CADability.GeoObject.IGeoObject> list) Line 50 C#
CADability.dll!CADability.DXF.Import.CreateHatch(netDxf.Entities.Hatch hatch) Line 737 C#
CADability.dll!CADability.DXF.Import.GeoObjectFromEntity(netDxf.Entities.EntityObject item) Line 136 C#
CADability.dll!CADability.DXF.Import.FindBlock(netDxf.Blocks.Block entity) Line 333 C#
CADability.dll!CADability.DXF.Import.CreateInsert(netDxf.Entities.Insert insert) Line 796 C#
CADability.dll!CADability.DXF.Import.GeoObjectFromEntity(netDxf.Entities.EntityObject item) Line 138 C#
CADability.dll!CADability.DXF.Import.FindBlock(netDxf.Blocks.Block entity) Line 333 C#
CADability.dll!CADability.DXF.Import.CreateInsert(netDxf.Entities.Insert insert) Line 796 C#
CADability.dll!CADability.DXF.Import.GeoObjectFromEntity(netDxf.Entities.EntityObject item) Line 138 C#
CADability.dll!CADability.DXF.Import.FindBlock(netDxf.Blocks.Block entity) Line 333 C#
CADability.dll!CADability.DXF.Import.CreateInsert(netDxf.Entities.Insert insert) Line 796 C#
CADability.dll!CADability.DXF.Import.GeoObjectFromEntity(netDxf.Entities.EntityObject item) Line 138 C#
CADability.dll!CADability.DXF.Import.FillModelSpace(CADability.Model model) Line 57 C#
CADability.dll!CADability.DXF.Import.CreateProject() Line 104 C#
CADability.dll!CADability.DXF.Import.Project.get() Line 75 C#
CADability.dll!CADability.Project.ImportDXF(string filename) Line 1778 C#
CADability.dll!CADability.Project.ReadFromFile(string FileName, string Format, bool useProgress, bool makeCompounds) Line 1807 C#
CADability.dll!CADability.Project.ReadFromFile(string FileName, string Format) Line 1838 C#
CADability.dll!CADability.FrameImpl.OnFileOpen(string fileName) Line 2335 C#
CADability.dll!CADability.FrameImpl.OnCommand(string MenuId) Line 997 C#
CADability.Forms.dll!CADability.Forms.CadFrame.OnCommand(string MenuId) Line 71 C#
CADability.Forms.dll!CADability.Forms.ToolBars.TagInfo.ButtonClicked(object sender, System.EventArgs e) Line 94 C#
System.Windows.Forms.dll!System.Windows.Forms.ToolStripItem.RaiseEvent(object key, System.EventArgs e) Unknown
System.Windows.Forms.dll!System.Windows.Forms.ToolStripButton.OnClick(System.EventArgs e) Unknown
System.Windows.Forms.dll!System.Windows.Forms.ToolStripItem.HandleClick(System.EventArgs e) Unknown
System.Windows.Forms.dll!System.Windows.Forms.ToolStripItem.HandleMouseUp(System.Windows.Forms.MouseEventArgs e) Unknown
System.Windows.Forms.dll!System.Windows.Forms.ToolStripItem.FireEventInteractive(System.EventArgs e, System.Windows.Forms.ToolStripItemEventType met) Unknown
System.Windows.Forms.dll!System.Windows.Forms.ToolStripItem.FireEvent(System.EventArgs e, System.Windows.Forms.ToolStripItemEventType met) Unknown
System.Windows.Forms.dll!System.Windows.Forms.ToolStrip.OnMouseUp(System.Windows.Forms.MouseEventArgs mea) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.WmMouseUp(ref System.Windows.Forms.Message m, System.Windows.Forms.MouseButtons button, int clicks) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.ScrollableControl.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.ToolStrip.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam) Unknown
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm) Unknown
CADability.App.exe!CADability.App.Program.Main(string[] args) Line 19 C#

SplitCyclical IndexOutOfRangeException

Customer reports this error that can occur sometimes.
No repro available yet.

Exception Source: CADability
Exception Type: System.IndexOutOfRangeException
Exception Message: Der Index war außerhalb des Arraybereichs.
Exception Target Site: SplitCyclical

---- Stack Trace ----
   CADability.Shapes.Border.SplitCyclical(positions As Double[])
       Border.cs: line 2081, col 21
   CADability.Shapes.Border.ConvexHull()
       Border.cs: line 4354, col 29
   CADability.Shapes.Border.GetSmallestEnclosingRectangle()
       Border.cs: line 4410, col 13
   LogiCal.CADModule.Calculation.CadHole.ProcessBorder(border As Border)
       CadHole.cs: line 0073, col 13
   LogiCal.CADModule.Calculation.CadItem.ProcessHoles(simple As SimpleShape)
       CadItem.cs: line 0543, col 17
   LogiCal.CADModule.Calculation.CadItem.ProcessSimpleShape(simple As SimpleShape)
       CadItem.cs: line 0403, col 13
   LogiCal.CADModule.Calculation.CadItemCollection.ProcessSingleMode(cshape As CompoundShape)
       CadItemCollection.cs: line 0342, col 17
   LogiCal.CADModule.Calculation.CadItemCollection.ProcessCompoundShape(totalCalcMode As Boolean, cshape As CompoundShape)
       CadItemCollection.cs: line 0143, col 13
   LogiCal.CADModule.Calculation.Calculator.ProcessGeoObjects(totalCalcMode As Boolean, geos As GeoObjectList, data As DefaultData, progress As IProgress`1, ct As CancellationToken)
       Calculator.cs: line 0325, col 13
   LogiCal.CADModule.Calculation.Calculator.ProcessFrame(totalCalcMode As Boolean, geoObjects As GeoObjectList, data As DefaultData, progress As IProgress`1, ct As CancellationToken)
       Calculator.cs: line 0026, col 13
   LogiCal.CADModule.<>c__DisplayClass430_0.<StartCalculation>b__0()
       frmCAD.cs: line 0965, col 54
   System.Threading.Tasks.Task`1.InnerInvoke()
       : N 00078
   System.Threading.Tasks.Task.Execute()
       : N 00071
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       : N 00032
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(task As Task)
       : N 00062
   LogiCal.CADModule.<StartCalculation>d__430.MoveNext()
       frmCAD.cs: line 0965, col 13
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       : N 00032
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(task As Task)
       : N 00062
   LogiCal.CADModule.<bbiStartCalc_ItemClick>d__375.MoveNext()
       frmCAD.cs: line 0501, col 13
   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       : N 00032

Export DXF files

I think, it is not necessary to export dxf files, or does anybody need it?

Finish action with right mouse click

In the earlier version of Cadability it was possible to finish/cancel an action (e.g. inserting a text) with a right click and choose "Finish" or "Cancel" from the context menu.

Now this is only possible via the ControlCenter.

Was this context menu removed intentionally?

Fix all compile warnings

Ideally, one should fix all the compile warnings. Especially all "obsolete" warnings in the CADabilty code base itself should be solved by shaping CADability legacy code into the desired patterns as a migration reference for other contributors.

ConstructAction: static lastStyle

private static Dictionary<Style.EDefaultFor, Style> lastStyle = new Dictionary<Style.EDefaultFor, Style>(); // hiermit gehts weiter...
internal static void ClearLastStyles()
{
lastStyle.Clear();
}

Why is lastStyle static? Couldn't it be used just for the instance?
I couldn't find any references outside ConstrucAction.

The problem with the static reference is, that it will keep a lot of objects. Even after closing the CadControl.
Here is the key retention path of one line. But there could be thousand of objects depending on the project you opened the last time.

Calling ClearLastStyles() before Disposing the CadControl solves the isssue. But this method is not public.

grafik

NullReferenceException in GeoPointProperty.InitFormat

A System.NullReferenceException is thrown after a Polyline is selected.

frame is null
numberFormatInfo.NumberDecimalDigits = frame.GetIntSetting("Formatting.Coordinate.Digits", 3);

System.NullReferenceException HResult=0x80004003 Message=Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt. Source=CADability StackTrace: at CADability.UserInterface.GeoPointProperty.InitFormat(IFrame frame) in C:\Development\Repos\SOFAgh\CADability\CADability\GeoPointProperty.cs:line 122

Full call stack:
CADability.dll!CADability.UserInterface.GeoPointProperty.InitFormat(CADability.IFrame frame) Line 122 C# CADability.dll!CADability.UserInterface.GeoPointProperty.GeoPointProperty(CADability.IFrame frame, string resourceId) Line 101 C# CADability.dll!CADability.UserInterface.GeoPointProperty.GeoPointProperty(string resourceId, CADability.IFrame frame, bool autoModifyWithMouse) Line 417 C# CADability.dll!CADability.UserInterface.MultiGeoPointProperty.SubItems.get() Line 227 C# CADability.dll!CADability.UserInterface.PropertyEntryImpl.SubEntries.get() Line 269 C# CADability.dll!CADability.UserInterface.ShowPropertyPolyline.OnVertexPropertyStateChanged(CADability.UserInterface.IPropertyEntry sender, CADability.UserInterface.StateChangedArgs args) Line 596 C# CADability.dll!CADability.UserInterface.PropertyEntryImpl.PropertyEntryChangedState(CADability.UserInterface.StateChangedArgs args) Line 33 C# CADability.dll!CADability.UserInterface.PropertyEntryImpl.Opened(bool isOpen) Line 180 C# CADability.dll!CADability.UserInterface.PropertyEntryImpl.IsOpen.set(bool value) Line 64 C# CADability.dll!CADability.UserInterface.PropertyEntryImpl.OpenOrCloseSubEntries() Line 205 C# CADability.Forms.dll!CADability.Forms.PropertyPage.OpenSubEntries(CADability.UserInterface.IPropertyEntry toOpenOrClose, bool open) Line 775 C# CADability.dll!CADability.UserInterface.ShowPropertyPolyline.Opened(bool IsOpen) Line 625 C# CADability.dll!CADability.UserInterface.IShowPropertyImpl.CADability.UserInterface.IPropertyEntry.IsOpen.set(bool value) Line 703 C# CADability.dll!CADability.UserInterface.IShowPropertyImpl.OpenOrCloseSubEntries() Line 756 C# CADability.Forms.dll!CADability.Forms.PropertyPage.OpenSubEntries(CADability.UserInterface.IPropertyEntry toOpenOrClose, bool open) Line 775 C# CADability.dll!CADability.UserInterface.SelectedObjectsProperty.OpenSubEntries() Line 521 C# CADability.dll!CADability.Actions.SelectObjectsAction.AddSelectedObjects(CADability.GeoObject.GeoObjectList selObj) Line 770 C# CADability.dll!CADability.Actions.SelectObjectsAction.SetSelectedObjects(CADability.GeoObject.GeoObjectList selObj) Line 813 C# CADability.dll!CADability.Actions.SelectObjectsAction.OnMouseUp(CADability.Substitutes.MouseEventArgs e, CADability.IView vw) Line 1489 C# CADability.dll!CADability.ActionStack.OnMouseUp(CADability.Substitutes.MouseEventArgs e, CADability.IView View) Line 328 C# CADability.dll!CADability.ModelView.CADability.IView.OnMouseUp(CADability.Substitutes.MouseEventArgs eIn) Line 1135 C# CADability.Forms.dll!CADability.Forms.CadCanvas.OnMouseUp(System.Windows.Forms.MouseEventArgs e) Line 244 C# [External Code] CADability.App.exe!CADability.App.Program.Main(string[] args) Line 19 C#

Reimplementation of PaintToOpenGL

If habe been working on a reimplementation of PaintToOpenGL is the last couple of weeks.
The first result can be seen in this Branch

Advantages

  1. Each instance has it's own OpenGL instance
  2. Each instance is Disposable on it's own
  3. Handle recreation is now possible
  4. Finalizer-Free implementation

Details
1. Each instance has it's own OpenGL instance
Each instance of the CadControl now uses a seperate instance of OpenGL. No resources are shared between different instances.

2. Each instance is Disposable on it's own
Each instance of CadControl can now be disposed seperatly. That means alle OpenGL resources of this instance are released we the Control is disposed.

3. Handle recreation is now possible
It's now possible to use the CadControl even when the Handle needs to be recreated. This can happen in a few scenarios.
See this Stackoverflow page on how to force this.

4. Finalizer-Free implementation
The new implemenation does not contain any Finalizers. One of the disadvantages of Finazlizers is the fact that they are run in a different thread by the GC. This can cause all kind of problems with OpenGL. All cleanup is now done in the Dispose methods.

Most of the work for handling OpenGL resources is now done by the OpenGLResourceManager class.

Open issues:

  1. The HandleDestroyed and HandleCreated event are raised multiple times.
    It is unkown why this happens.

  2. The gDEBugger will report Memory Leaks after recreating the handle. But it's uncertain wether this warning is because of wglShareLists or this is a real problem.

  3. Reinit is not supported yet. If you use the Tabbed View from DevExpress the Control Handle will be destroyed and created without setting RecreatingHandle to true.

Multithreading (Async) and Model get_Extent

CADability/CADability/Model.cs

Lines 1163 to 1173 in 8497ecf

public BoundingCube Extent
{
get
{
if (extent == null || !extent.HasValue || extent.Value.IsEmpty)
{
extent = CalculateExtent();
if (extent.Value.IsEmpty) extent = new BoundingCube(GeoPoint.Origin, 100); // damites auch bei leeren Modellen einen Wert gibt
}
return extent.Value;
}

Ocasionally I get this error in Cadability.

System.InvalidOperationException: Nullable object must have a value at line 1172

After taking a look at CalculateExtent() it seems very unlikely that this function will return a null value.

My guess is a concurrency problem. I have seen this error only when used on multithreading (async).
There are various lines of code that will set extent to null. Perhaps it is set to null between the first check on line 1167 and the return of the value on line 1175?

Full callstack

at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) in f:\dd\ndp\clr\src\BCL\system\throwhelper.cs:line 99
 at System.Nullable`1.get_Value() in f:\dd\ndp\clr\src\BCL\system\nullable.cs:line 50
 at CADability.Model.get_Extent() in C:\Development\Repos\SOFAgh\CADability\CADability\Model.cs:line 1172
 at CADability.ModelView.ShowGrid(IPaintTo3D PaintToBackground, Boolean displayGrid, Boolean displayDrawingPlane) in C:\Development\Repos\SOFAgh\CADability\CADability\ModelView.cs:line 2025
 at CADability.ModelView.PaintBackground(IPaintTo3D PaintToBackground) in C:\Development\Repos\SOFAgh\CADability\CADability\ModelView.cs:line 837
 at CADability.ModelView.CADability.IView.OnPaint(PaintEventArgs e) in C:\Development\Repos\SOFAgh\CADability\CADability\ModelView.cs:line 805
 at LogiCal.CADModule.CadControl2.CadCanvas.OnPaint(PaintEventArgs e) in C:\Development\LogiCalSharp\LogiCalMain\LogiCal\CADModule\CadControl2\CadCanvas.cs:line 321
 at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
 at System.Windows.Forms.Control.WmPaint(Message& m)
 at System.Windows.Forms.Control.WndProc(Message& m)
 at System.Windows.Forms.UserControl.WndProc(Message& m)
 at DevExpress.XtraEditors.XtraUserControl.BaseWndProc(Message& m) in DevExpress.Utils\WinControls.cs:line 569
 at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
 at DevExpress.Utils.Drawing.Helpers.NativeMethods.UnsafeNativeMethods.DefSubclassProc(IntPtr hWnd, IntPtr Msg, IntPtr wParam, IntPtr lParam)
 at DevExpress.Utils.Drawing.Helpers.Win32SubclasserFactory.Win32Subclasser.SubClassProcInner(IntPtr hWnd, IntPtr Msg, IntPtr wParam, IntPtr lParam, IntPtr uIdSubclass, IntPtr dwRefData) in DevExpress.Utils\ScrollableControl\NativeMethods.cs:line 3349

OpenGL issues

We are expierencing OpenGL issues like this:

  1. CreateContexts: Unable to create an OpenGL rendering context: 6 ERROR_INVALID_HANDLE
  2. CreateContexts: Unable to create an OpenGL rendering context: -1073281622 (0xC00705AA) Unkown error

The program works for some time. After that the OpenGL init fails and the program has to be restarted.
At the moment we haven't had the time to test this with the original CADability app.

Any suggestions what we can do about this?

Callstack 1:

Exception Source:      LogiCal
Exception Type:        LogiCal.CADModule.CadControl2.PaintToOpenGLException
Exception Message:     CreateContexts: Unable to create an OpenGL rendering context: 6
Exception Target Site: Init

---- Stack Trace ----
   LogiCal.CADModule.CadControl2.PaintToOpenGL.Init(deviceContext As IntPtr, width As Int32, height As Int32, toBitmap As Boolean)
       PaintToOpenGL.cs: line 0306, col 17
   LogiCal.CADModule.CadControl2.PaintToOpenGL.Init(ctrl As Control)
       PaintToOpenGL.cs: line 0544, col 13
   LogiCal.CADModule.CadControl2.CadCanvas.CADability.ICanvas.ShowView(toShow As IView)
       CadCanvas.cs: line 0221, col 25
   CADability.FrameImpl.set_ActiveView(value As IView)
       : N 00058
   CADability.ModelView.CADability.IView.OnMouseLeave(e As EventArgs)
       : N 00067
   LogiCal.CADModule.CadControl2.CadCanvas.OnMouseLeave(e As EventArgs)
       CadCanvas.cs: line 0389, col 13
   System.Windows.Forms.Control.WmMouseLeave(m As Message&)
       : N 00051
   System.Windows.Forms.Control.WndProc(m As Message&)
       : N 11002317
   System.Windows.Forms.ScrollableControl.WndProc(m As Message&)
       : N 00048
   System.Windows.Forms.ContainerControl.WndProc(m As Message&)
       : N 00018
   System.Windows.Forms.UserControl.WndProc(m As Message&)
       : N 00018
   DevExpress.XtraEditors.XtraUserControl.WndProc(m As Message&)
       : N 00165
   System.Windows.Forms.ControlNativeWindow.OnMessage(m As Message&)
       : N 00018
   System.Windows.Forms.ControlNativeWindow.WndProc(m As Message&)
       : N 00052
   System.Windows.Forms.NativeWindow.Callback(hWnd As IntPtr, msg As Int32, wparam As IntPtr, lparam As IntPtr)
       : N 00127

Callstack 2:

Exception Source:      LogiCal
Exception Type:        LogiCal.CADModule.CadControl2.PaintToOpenGLException
Exception Message:     CreateContexts: Unable to create an OpenGL rendering context: -1073281622
Exception Target Site: Init

---- Stack Trace ----
   LogiCal.CADModule.CadControl2.PaintToOpenGL.Init(deviceContext As IntPtr, width As Int32, height As Int32, toBitmap As Boolean)
       PaintToOpenGL.cs: line 0306, col 17
   LogiCal.CADModule.CadControl2.PaintToOpenGL.Init(ctrl As Control)
       PaintToOpenGL.cs: line 0544, col 13
   LogiCal.CADModule.CadControl2.CadCanvas.CADability.ICanvas.ShowView(toShow As IView)
       CadCanvas.cs: line 0221, col 25
   CADability.FrameImpl.set_ActiveView(value As IView)
       : N 00058
   CADability.ModelView.CADability.IView.OnMouseLeave(e As EventArgs)
       : N 00067
   LogiCal.CADModule.CadControl2.CadCanvas.OnMouseLeave(e As EventArgs)
       CadCanvas.cs: line 0389, col 13
   System.Windows.Forms.Control.WmMouseLeave(m As Message&)
       : N 00051
   System.Windows.Forms.Control.WndProc(m As Message&)
       : N 11002317
   System.Windows.Forms.ScrollableControl.WndProc(m As Message&)
       : N 00048
   System.Windows.Forms.ContainerControl.WndProc(m As Message&)
       : N 00018
   System.Windows.Forms.UserControl.WndProc(m As Message&)
       : N 00018
   DevExpress.XtraEditors.XtraUserControl.WndProc(m As Message&)
       : N 00165
   System.Windows.Forms.ControlNativeWindow.OnMessage(m As Message&)
       : N 00018
   System.Windows.Forms.ControlNativeWindow.WndProc(m As Message&)
       : N 00052
   System.Windows.Forms.NativeWindow.Callback(hWnd As IntPtr, msg As Int32, wparam As IntPtr, lparam As IntPtr)
       : N 00127

ConvexHull calculation fails with GeoVectorException

The calculation of a convex hull will fail with the attached DXF file.
ConvexHullError.zip

Code:

var m = cadControl1.CadFrame.Project.GetActiveModel();

List<ICurve> curves = new List<ICurve>(m.AllObjects.Count);
foreach (IGeoObject geo in m.AllObjects)
    if (geo is ICurve geoCurve)
        curves.Add(geoCurve);

if (!Curves.GetCommonPlane(curves, out Plane pln))
    return;

List<ICurve2D> curves2D = new List<ICurve2D>(curves.Count);

foreach (ICurve curve in curves)
    curves2D.Add(curve.GetProjectedCurve(pln));

var cs = CompoundShape.CreateFromList(curves2D.ToArray(), 0.01, true, out GeoObjectList deads);

Path2D ssOutlines = cs.SimpleShapes[0].Outline.AsPath();
for (int i = 1; i < cs.SimpleShapes.Length; i++)
    ssOutlines = SimpleShape.ConnectPaths(ssOutlines, cs.SimpleShapes[i].Outline.AsPath());

//Create Convex Hull
var outlineBorder = ssOutlines.MakeBorder();
var hull = outlineBorder.ConvexHull();
CADability.GeoVectorException
  HResult=0x80131600
  Message=Error in application.
  Source=CADability
  StackTrace:
   at CADability.GeoVector2D.get_Normalized() in C:\Development\Repos\SOFAgh\CADability\CADability\GeoPoint.cs:line 1451
   at CADability.Curve2D.GeneralCurve2D.GetTriangulationBasis(GeoPoint2D[]& points, GeoVector2D[]& directions, Double[]& parameters) in C:\Development\Repos\SOFAgh\CADability\CADability\GeneralCurve2D.cs:line 1591
   at CADability.Curve2D.GeneralCurve2D.MakeTringulation() in C:\Development\Repos\SOFAgh\CADability\CADability\GeneralCurve2D.cs:line 1609
   at CADability.Curve2D.GeneralCurve2D.GetInflectionPoints() in C:\Development\Repos\SOFAgh\CADability\CADability\GeneralCurve2D.cs:line 2867
   at CADability.Shapes.Border.ConvexHull() in C:\Development\Repos\SOFAgh\CADability\CADability\Border.cs:line 4182
   at CADability.App.ChildMdiForm.button2_Click(Object sender, EventArgs e) in C:\Development\Repos\SOFAgh\CADability\CADability.App\ChildMdiForm.cs:line 64
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at CADability.App.Program.Main(String[] args) in C:\Development\Repos\SOFAgh\CADability\CADability.App\Program.cs:line 21

Importing a DXF File fails with CADability.PlaneException

This DXF will cause an CADability.PlaneException
Bemassung.zip

CADability.PlaneException
  HResult=0x80131600
  Message=Fehler in der Anwendung.
  Source=CADability
  StackTrace:
   at CADability.Plane..ctor(GeoPoint Location, GeoPoint p1, GeoPoint p2) in C:\Development\Repos\SOFAgh\CADability\CADability\Plane.cs:line 146
   at CADability.DXF.Import.CreateMesh(Mesh mesh) in C:\Development\Repos\SOFAgh\CADability\CADability\ImportDxf.cs:line 1114
   at CADability.DXF.Import.GeoObjectFromEntity(EntityObject item) in C:\Development\Repos\SOFAgh\CADability\CADability\ImportDxf.cs:line 147
   at CADability.DXF.Import.FindBlock(Block entity) in C:\Development\Repos\SOFAgh\CADability\CADability\ImportDxf.cs:line 333
   at CADability.DXF.Import.CreateInsert(Insert insert) in C:\Development\Repos\SOFAgh\CADability\CADability\ImportDxf.cs:line 796
   at CADability.DXF.Import.GeoObjectFromEntity(EntityObject item) in C:\Development\Repos\SOFAgh\CADability\CADability\ImportDxf.cs:line 138
   at CADability.DXF.Import.FillModelSpace(Model model) in C:\Development\Repos\SOFAgh\CADability\CADability\ImportDxf.cs:line 57
   at CADability.DXF.Import.CreateProject() in C:\Development\Repos\SOFAgh\CADability\CADability\ImportDxf.cs:line 104
   at CADability.DXF.Import.get_Project() in C:\Development\Repos\SOFAgh\CADability\CADability\ImportDxf.cs:line 75
   at CADability.Project.ImportDXF(String filename) in C:\Development\Repos\SOFAgh\CADability\CADability\Project.cs:line 1794
   at CADability.Project.ReadFromFile(String FileName, String Format, Boolean useProgress, Boolean makeCompounds) in C:\Development\Repos\SOFAgh\CADability\CADability\Project.cs:line 1823
   at CADability.Project.ReadFromFile(String FileName, String Format) in C:\Development\Repos\SOFAgh\CADability\CADability\Project.cs:line 1854
   at CADability.FrameImpl.OnFileOpen(String fileName) in C:\Development\Repos\SOFAgh\CADability\CADability\Frame.cs:line 2335
   at CADability.FrameImpl.OnCommand(String MenuId) in C:\Development\Repos\SOFAgh\CADability\CADability\Frame.cs:line 997
   at CADability.Forms.CadFrame.OnCommand(String MenuId) in C:\Development\Repos\SOFAgh\CADability\CADability.Forms\CadFrame.cs:line 71
   at CADability.Forms.ToolBars.TagInfo.ButtonClicked(Object sender, EventArgs e) in C:\Development\Repos\SOFAgh\CADability\CADability.Forms\ToolBars.cs:line 94
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at CADability.App.Program.Main(String[] args) in C:\Development\Repos\SOFAgh\CADability\CADability.App\Program.cs:line 19

Incorrect drawing of Polyline when create a new one

While creating a new Polyline the lines drawn on the Canvas are one vertex behind.
You can see on the right side on the control center that a new point is created. But the canvas is updated only after the next point is clicked.

11-02-_2021_09-25-41

MainFrame NullReferenceException

After opening several STEP files and changing the Projection Direction the following error can sometimes occur.

Line 571: MainFrame is null

System.NullReferenceException
HResult=0x80004003
Message=Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
Source=CADability
StackTrace:
at CADability.ProjectedModel.RecalcAll(Boolean temporary) in C:\Development\Repos\SOFAgh\CADability\CADability\ProjectedModel.cs:line 571

CADability.dll!CADability.ProjectedModel.RecalcAll(bool temporary) Line 571	C#
CADability.dll!CADability.ProjectedModel.ForceRecalc() Line 249	C#
CADability.dll!CADability.ModelView.ForceInvalidateAll() Line 659	C#
CADability.dll!CADability.ModelView.SetViewDirection(CADability.ModOp project, CADability.GeoPoint fixPoint, bool mouseIsDown) Line 1854	C#
CADability.dll!CADability.Actions.ViewPointAction.OnMouseMove(CADability.Substitutes.MouseEventArgs e, CADability.IView vw) Line 107	C#
CADability.dll!CADability.ActionStack.OnMouseMove(CADability.Substitutes.MouseEventArgs e, CADability.IView View) Line 309	C#
CADability.dll!CADability.ModelView.CADability.IView.OnMouseMove(CADability.Substitutes.MouseEventArgs eIn) Line 1115	C#
CADability.Forms.dll!CADability.Forms.CadCanvas.OnMouseMove(System.Windows.Forms.MouseEventArgs e) Line 245	C#
System.Windows.Forms.dll!System.Windows.Forms.Control.WmMouseMove(ref System.Windows.Forms.Message m)	Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m)	Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m)	Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m)	Unknown
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam)	Unknown
[Native to Managed Transition]	
[Managed to Native Transition]	
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData)	Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context)	Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context)	Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm)	Unknown
CADability.App.exe!CADability.App.Program.Main(string[] args) Line 21	C#

Drawing vanishes

Steps to reproduce

  1. Open drawing (*.DXF)
  2. Select All (Ctrl + A) and delete (Del Key)
  3. Import (not open) a different drawing
  4. Zoom in and out until the drawing vanishes
Drawingdisappear.mp4

samples.zip

Editing a Rectangle with the mouse could lead to PolylineException

If the user is editing a rectangle with the mouse and would reach the point where the rectangle would have 0 height the follwing execption occurs.

This error should be handled gracefully and not stop the program from running.

11-02-_2021_09-00-23

CADability.GeoObject.PolylineException
  HResult=0x80131600
  Message=Attempt to get rectangle location on polyline that is no rectangle
  Source=CADability
  StackTrace:
   at CADability.GeoObject.Polyline.get_RectangleLocation() in C:\Development\Repos\SOFAgh\CADability\CADability\Polyline.cs:line 293
   at CADability.UserInterface.ShowPropertyPolyline.OnGetLocation(GeoPointProperty sender) in C:\Development\Repos\SOFAgh\CADability\CADability\ShowPropertyPolyline.cs:line 367
   at CADability.UserInterface.GeoPointProperty.<>c__DisplayClass56_0.<add_GetGeoPointEvent>b__0() in C:\Development\Repos\SOFAgh\CADability\CADability\GeoPointProperty.cs:line 448
   at CADability.UserInterface.EditableProperty`1.GetValue() in C:\Development\Repos\SOFAgh\CADability\CADability\EditableProperty.cs:line 198
   at CADability.UserInterface.GeoPointProperty.CADability.IHotSpot.GetHotspotPosition() in C:\Development\Repos\SOFAgh\CADability\CADability\GeoPointProperty.cs:line 512
   at CADability.Actions.SelectObjectsAction.OnRepaintSelect(Rectangle IsInvalid, IView View, IPaintTo3D PaintToSelect) in C:\Development\Repos\SOFAgh\CADability\CADability\SelectObjectsAction.cs:line 571
   at CADability.ModelView.CADability.IView.OnPaint(PaintEventArgs e) in C:\Development\Repos\SOFAgh\CADability\CADability\ModelView.cs:line 809
   at CADability.Forms.CadCanvas.OnPaint(PaintEventArgs e) in C:\Development\Repos\SOFAgh\CADability\CADability.Forms\CadCanvas.cs:line 205
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
   at System.Windows.Forms.Control.WmPaint(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Export step problem

Export step fail

After ruling the surface, the export step file failed at Serialize the Edge with cur3d is "Path". Because path not impl IExportStep interface.

Here's the testcase file.
test_ruled.cdb.json.zip

image

Parallel STEP import

STEP import is quite slow. Now many things during import can be done parallel. If the conditional compilation symbol "PARALLEL" is set, multiple threads are used when importing STEP files which makes it much faster. This is still experimental but I would appreciate to get some feedback. This is new in the ParallelStepImport branch which will be merged into the master branch later.

NullReferenceException in DxfReader.ReadLayerStateProperties

Some files cause a NullReferenceException because GetObjectByHandle returns null.

Example: linetype_issue.zip

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=CADability.Core
  StackTrace:
   at netDxf.IO.DxfReader.ReadLayerStateProperties(String name, IEnumerator`1 enumerator) in ...\CADability\netDxf\IO\DxfReader.cs:line 11105

PR to solve this will follow

BSpline deadlock

In rare conditions it seems to be possible that the BSpline is locking itself.
Each lock seems to be waiting for the other one.

private GeoPoint[] GetCashedApproximation(double precision)
{
lock (lockApproximationRecalc)
{
if (((precision > 0) && (approxPrecision > precision)) || approximation == null)

Plane ICurve.GetPlane()
{
lock (this)
{
if (plane.HasValue) return plane.Value;

[Waiting on lock owned by Thread 43304, double-click or press enter to switch to thread]	

CADability.dll!CADability.GeoObject.BSpline.CADability.GeoObject.ICurve.GetPlane() Line 2935 C#
CADability.dll!CADability.GeoObject.BSpline.CADability.GeoObject.ICurve.Approximate(bool linesOnly, double maxError) Line 3143 C#
CADability.dll!CADability.GeoObject.BSpline.GetCashedApproximation(double precision) Line 96 C#
CADability.dll!CADability.GeoObject.BSpline.PaintTo3D(CADability.IPaintTo3D paintTo3D) Line 1804 C#
CADability.dll!CADability.Model.RecalcDisplayLists(CADability.IPaintTo3D paintTo3D) Line 393 C#
CADability.dll!CADability.ProjectedModel.Paint(CADability.IPaintTo3D paintTo3D) Line 1305 C#
CADability.dll!CADability.ModelView.CADability.IView.OnPaint(CADability.Substitutes.PaintEventArgs e) Line 800 C#
LogiCal.exe!LogiCal.CADModule.CadControl2.CadCanvas.OnPaint(System.Windows.Forms.PaintEventArgs e) Line 321 C#
System.Windows.Forms.dll!System.Windows.Forms.Control.PaintWithErrorHandling(System.Windows.Forms.PaintEventArgs e, short layer) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.WmPaint(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.UserControl.WndProc(ref System.Windows.Forms.Message m) Unknown
DevExpress.Utils.v21.2.dll!DevExpress.XtraEditors.XtraUserControl.BaseWndProc(ref System.Windows.Forms.Message m) Line 569 C#
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam) Unknown
[Native to Managed Transition]
[Managed to Native Transition]
DevExpress.Utils.v21.2.dll!DevExpress.Utils.Drawing.Helpers.Win32SubclasserFactory.Win32Subclasser.SubClassProcInner(System.IntPtr hWnd, System.IntPtr Msg, System.IntPtr wParam, System.IntPtr lParam, System.IntPtr uIdSubclass, System.IntPtr dwRefData) Line 3349 C#
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) Unknown
LogiCal.exe!LogiCal.Program.Main() Line 67 C#

[Waiting on lock owned by Thread 3452, double-click or press enter to switch to thread]	

CADability.dll!CADability.GeoObject.BSpline.GetCashedApproximation(double precision) Line 91 C#
CADability.dll!CADability.GeoObject.BSpline.PrepareDisplayList(double precision) Line 1815 C#
CADability.dll!CADability.Model.RecalcGeoObject(object state) Line 143 C#
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 980 C#
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 928 C#
mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() Line 1252 C#
mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() Line 820 C#

Import Step does not always produce the same result.

If I use Project.ReadFromFile("stepfile", "stp"); to import a simple step file (no assembly) the result is not predictable. This happens for different files.

Example: Schließblech.zip

In 90% of the cases the result will be a Project with one Model and the model has one object of type Solid which has one Shell.

However, sometimes the result will be a Project with one Model and the model has one object of type Shell.

Import other file formats

There were other BRep file formats CADability was able to import: IGES, OpenCascade BRep, Parasolid and ACIS. Now only step files can be imported. The solution would be an external program, which converts these files to step files (which would be automatically instanciated) or even use the old CADability for that purpose.

Step import multithreading

Step import is slow. Most time is consumed in Face generation. This is because many faces have to be readjusted due to the restriction of valid BRep structures. Face generation could be implemented with multi threading.

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.