Sketch: breaking changes in Eyeshot 2024

With version 2024, we decided to refactor the sketch-related code to make it simpler and more intuitive. To do so, we had to introduce a series of breaking changes, meaning it might take a while to update your sketcher application from Eyeshot 2023 to Eyeshot 2024. This article aims to guide you through the process by listing all major changes and how they should be dealt with. 

SketchManager class was removed

We found that the SketchManager class was neither necessary nor helpful in structuring the code. Therefore, we decided to remove it and merge its functionalities in the SketchEntity class. Now the SketchEntity has most of the methods that the SketchManager class had, except a few that were removed altogether.

Before Eyeshot 2024, the Design workspace kept an instance of SketchManager that was accessible at all times through the property Design.SketchManager. Now we do not have a manager anymore, therefore we removed the property and added a new one called CurrentSketch that is always null but when a sketch is being edited. Therefore, wherever in your code you checked SketchManager.Editing, you now have to check if CurrentSketch is null:

Old Code New Code
if(design.SketchManager.Editing) {
    ...
}
if(design.CurrentSketch != null) {
    ...
}

Another breaking change is related to methods New, Edit and Exit. The method New was removed, and to replace it you are now required to create a SketchEntity using the constructor, add it to the list of entities of your design workspace (or block), and invoke Edit.

Old Code New Code
design.SketchManager.New(Plane.XY);

SketchEntity sketchEntity = new SketchEntity(Plane.XY);
design.Entities.Add(sketchEntity);
sketchEntity.Edit(design);

Methods Edit and Exit should now be called directly on the SketchEntity that you wish to edit.

Old Code New Code
design.SketchManager.Edit(sketchEntity);
sketchEntity.Edit(design);
design.SketchManager.Exit(SketchManager.exitType.KeepChanges);
sketchEntity.Exit();

To exit the sketch currently being edited you should now use design.CurrentSketch.Exit().

Note that it is the user's responsibility to add and remove the SketchEntity from the list of entities of the workspace or block. For this reason, we also removed SketchManager.exitType, which only existed to allow the user to specify whether to remove the entity after exiting. You can still provide a boolean value to the Exit method to specify whether to discard changes or not.

PointList and CurveList were merged into a single list

We decided that having all sketch curves and points in a single list rather than in two separate lists was more in line with other Eyeshot classes such as Region and CompositeCurve. Consequently, we removed SketchEntity.PointList and integrated both points and curves in SketchEntity.CurveList.

Old Code New Code
foreach (var point in sketchEntity.PointList)
{
    ...
}
foreach (var point in sketchEntity.CurveList.OfType<Point>())
{
    ...
}

In some cases, it might also be necessary to fix loops iterating over the CurveList to skip points.

Changes in the XML files

In Eyeshot 2024, all entity IDs found in XML history files are assumed to be relative to the list containing both points and curves. For this reason, older files, where IDs were treated differently for points and curves, will no longer work, unless they are manually fixed. 

Map<...> methods were removed

Before Eyeshot 2024, it was possible to obtain the geometrical sketch entity (e.g., SketchCircle) from the graphical one (e.g., Circle) and vice versa, using Map<...> methods. To avoid confusion and simplify the code, we decided to hide this one-to-one correspondence from the user and only expose graphical entities. We removed Map<...> and all other methods and properties involving geometrical sketch entities, such as SketchCurves. We also removed the SketchCurveData field since it is now possible to store custom data inside the EntityData field of the sketch graphical entities.

Other breaking changes

  • The default icon for constraint labels (StackedLabel) is no longer specified as a static field in the SketchManager but rather as a static field named Icon in each specific label class (for example VerticalLabel.Icon).
  • SketchManager.Delete(Constraint) was removed, use SketchManager.Delete(VisualConstraint) instead.
  • SketchEntity.Vertices is now always null.
  • SketchManager.GetAllConstraintsFromEntity was removed.
  • SketchManager.GetVisualConstraint was removed.
  • SketchManager.SketchPlane was removed, use SketchEntity.Plane instead.
  • DisplayConstraintEntities now accepts an instance of VisualConstraint rather than a stacked label. You can use StackedLabel.Constraint to retrieve the label's constraint and pass it to the method.
  • SketchManager.AnimateCamera, SketchManager.RotateToPlane, SketchManager.Fit, SketchManager.Margin and SketchManager.ZoomFitType were removed. You should now create an instance of SketchEntity.CameraSettings and pass it to Edit or Exit methods.
  • SketchEntity.Parent was removed.
  • SketchManager.Translate, SketchManager.Rotate, SketchManager.Scaleand SketchManager.Mirror methods were moved to SketchEntity and renamed to TranslateCurves, RotateCurves, ScaleCurves and MirrorCurves.
Was this article helpful?
1 out of 1 found this helpful

Comments

0 comments

Please sign in to leave a comment.

Articles in this section