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 |
|
|
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 |
|
|
Methods Edit
and Exit
should now be called directly on the SketchEntity
that you wish to edit.
Old Code | New Code |
|
|
|
|
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 |
|
|
In some cases, it might also be necessary to fix loops iterating over the CurveList
to skip points.
As a consequence of this change, SelectedSketchCurve.Index
is now always relative to the CurveList
array. Therefore, it might be necessary to update any registered Workspace.SelectionChanged
event handlers.
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 namedIcon
in each specific label class (for exampleVerticalLabel.Icon
). SketchManager.Delete(Constraint)
was removed, useSketchEntity.DeleteConstraint(VisualConstraint)
instead.SketchEntity.Vertices
is now always null.SketchManager.GetAllConstraintsFromEntity
was removed.SketchManager.GetVisualConstraint
was removed.SketchManager.SketchPlane
was removed, useSketchEntity.Plane
instead.DisplayConstraintEntities
now accepts an instance ofVisualConstraint
rather than a stacked label. You can useStackedLabel.Constraint
to retrieve the label's constraint and pass it to the method.SketchManager.AnimateCamera
,SketchManager.RotateToPlane
,SketchManager.Fit
,SketchManager.Margin
andSketchManager.ZoomFitType
were removed. You should now create an instance ofSketchEntity.CameraSettings
and pass it toEdit
orExit
methods.SketchEntity.Parent
was removed.SketchManager.Translate
,SketchManager.Rotate
,SketchManager.Scale
andSketchManager.Mirror
methods were moved toSketchEntity
and renamed toTranslateCurves
,RotateCurves
,ScaleCurves
andMirrorCurves
.
Comments
Please sign in to leave a comment.