Code Samples
The long list of ready-to-use source code samples
The following Visual Studio sample projects are located under the product installation folder (Demos and Samples sub-folders). Each code sample is delivered in four versions: Windows Forms and Windows Presentation Foundation platforms, C# and VB.NET programming languages.
AdvancedPrinting
This sample shows how to print a model on a page that holds two views: a trimetric view and a second view framed by a custom camera. The views can be printed as vector line work, computed with HiddenLinesViewOnPaper, or as raster images rendered from the viewport, and the vector page can also be exported to an *.emf file.
AnimatedPicture
This sample shows how to animate a Picture entity by swapping its texture on a timer, with a circle and two dash-dot center lines drawn on top of it. A derived Picture class keeps the frame as an Image and recompiles only the texture, and the overlaid entities override Draw() to ignore the depth test.
AspNetMvc
This sample shows how to use Eyeshot in an ASP.NET Core MVC web application. The page builds a part from user parameters (length, color and an optional hole), renders it to a bitmap with an off-screen Design control, shows it in a 3D viewer as glTF, and offers it for download as STL, IGES or STEP files.
AssemblyDemo
This sample demonstrates how to work with large assemblies and their mates. The assembly tree offers commands such as Form New Subassembly, Dissolve Subassembly, Edit Structure, Make Independent, Edit, Edit Parent and Move with Triad, and visibility and lock status can be controlled at the instance level. Components can be dragged with the mates solved as they move, and new mates (coincident, concentric, tangent, distance, angle, parallel and perpendicular) can be added by picking faces, edges and vertices. Selection works in branch or leaf mode, and files can be opened, saved, imported and exported in formats such as IGES and STEP. The rotation center is shown while the view rotates. Video1, Video2, Video3
BlendSurface Ultimate Fem
This sample shows how to build a blend surface between the edges of two surfaces with Surface.Blend(). The influence of each edge on the blend can be changed interactively, and the Extend button lets you pick an edge of the second surface and drag a manipulator to extend it. Video1
CabinetDesigner Ultimate Fem
This sample shows how to build a two-module cabinet from scratch in a background work unit and check its assembly with collision detection. The width, the top panel wood and the panel color can be changed, the weight is computed from the material densities, and the collision volumes between the parts are highlighted. Video1
CamDemo
This sample shows how to create 2D and 3D milling toolpaths, such as pocket, contour, parallel, facing and clearing operations, as well as drilling, turning and five-axis toolpaths, and how to simulate material removal on the stock. Video1
ClientServer
This sample shows how to run Eyeshot on a server and serve the results to browser clients. Clients upload CAD files and queue jobs through a REST API, such as conversions to other formats and images, transformations, and area and volume computations, and receive SignalR notifications when the results are ready to download. Video1
CollisionDetection
This sample shows how to check collisions between objects, in 3D by rotating the joints of a six-axis robot arm, and in 2D by dragging entities around a flat scene. Four check methods with different accuracy are available, and the intersection volumes are shown for the methods that compute them. For details on how collision detection works, see this article.
CopyAndPaste
This sample demonstrates how to copy and paste entities and labels between two independent Design controls, and how to align the camera of the target control with the source on demand. The two controls sit side by side in a resizable split container that sets Design.SplitterMoving while the splitter is dragged.
CustomData
This sample shows how to attach custom data to an entity through the Entity.EntityData property and how to retrieve it at runtime by selecting the entity. It also covers custom data cloning, by implementing ICloneable, and serialization, so the data is saved and loaded with the native file. If you need to extend Eyeshot entity classes instead, see the more sophisticated FileFormatExtension sample.
CustomToolbar
This sample shows how to add custom buttons to the viewport toolbar and how to change the behavior of built-in buttons, such as making the Home button switch to the front view. It also shows how to replace the content of the CoordinateSystemIcon with custom Mesh entities. Not all applications need to display world axes: in medical applications, for instance, a torso shape may be more appropriate.
Defeature Ultimate Fem
This sample demonstrates how to identify the removable topological elements of a Brep, such as holes and fillets, with Brep.GetRemovableElements() and remove them with Brep.Remove(). Picking a face lists the features that involve it and highlights the smallest one. Video1
DelaunayTriangulation
This sample demonstrates how to use the Utility.Triangulate() method to perform a Delaunay triangulation of points, loops, or both, with optional segments as internal constraints. The outer loop must be closed, meaning that its first and last points must have the same coordinates, while inner loops can be either closed or open. Closed loops must be oriented counterclockwise for the outer boundary and clockwise for the inner ones.
Dimensioning Ultimate Fem
This sample shows how to interactively dimension a 3D model: after you pick a planar face as the drawing plane, picking vertices, edges, or arcs creates linear, angular, or radial dimensions. Video1
DraftingDemo
This sample demonstrates how to interactively create 2D curves, text, hatches, and dimensions, with object and grid snapping, providing a solid foundation for a 2D CAD system. It also covers editing commands such as trim, extend, offset, mirror, fillet, and chamfer. Drawings can be imported from DWG, DXF, and SVG files and exported to PDF. Video1
DragControlPoint Ultimate Fem
This sample shows how to interactively edit the control points of a NURBS surface to model complex freeform shapes, like an airplane fuselage. Selected control points are moved with the arrow keys in the plane of the active view, and the surface can be mirrored and inspected with environment mapping or zebra stripes. Video1
ExplodedView
This sample demonstrates how to create assembly configurations with different component positions and visibility states, by moving components with the object manipulator and recording each move as a step that a timeline plays back. It also shows how to generate a drawing of the exploded assembly for the current configuration. Video1
EyeshotDemo
This sample is a fully featured application that demonstrates the capabilities of the Design control on ten different scenes. Video1
FemDemo Fem
This sample covers the volume meshing of arbitrary geometry with linear or quadratic elements, the element quality histogram, the application of restraints and loads (forces, pressures and gravity) on Brep vertices, edges and faces, linear static and modal analysis, and the plot of results. Video1, Video2
FileFormatExtension
This sample shows how to extend Eyeshot's proprietary file format with custom data and custom entities through a FileSerializer subclass, using the file header tag to read different versions of the custom data. For more information, see this article. When dealing with custom data only, consider the alternative approach shown in this code sample, which does not involve versioning.
FirstPerson
This sample demonstrates how to walk or fly through a building by setting the Viewport.Navigation.Mode property. Use the WASD keys and the mouse to navigate, and the Space bar to switch between walking and flying. Video1
FlyoutTree
This sample shows how to display the assembly tree overlay and how to create a custom overlay tree, with its own context menu, for your specific workflows. Video1
GCodeSimulator
This sample shows how to read a G-code file with ReadGCode and simulate 3-axis CNC machining. Video1
GroupSimilar
This sample shows how to use the FindSimilar class. Based on the properties of 3D objects that are invariant under roto-translation, FindSimilar identifies all objects with the same shape within a given tolerance and rebuilds the assembly tree so that it contains only unique objects, optionally treating mirrored objects as similar. Video1
ImGui Ultimate Fem
This sample demonstrates how to use the QuickForms tool to interactively change the tessellation of a Gordon NURBS surface, as well as the mesh color and a text label, from a floating window.
Layers
This sample shows how to work with layers: a toy jet is split across Fuselage, Wings, Tail and Wires layers, and each layer can be shown or hidden from the layer list. It also adds ImageOnly and LeaderAndText labels and shows a tooltip with the type and index of the entity under the mouse cursor.
Lego Ultimate Fem
This sample demonstrates how to run a long modeling operation in the background while the user interface stays responsive. A Lego brick is built as a Solid inside a WorkUnit that reports its progress and can be cancelled. The viewport's built-in progress bar and Cancel button are hidden and replaced by a standard progress bar, a status text and a Cancel button.
MachineSimulator
This sample demonstrates how to simulate the movements of a 3-axis CNC machine. The moving parts are loaded from Eyeshot files into three nested block definitions, so that moving the X carriage also moves the Y carriage and the head. Three BlockReference subclasses override Animate() and MoveTo() to compute each new position and apply it to the model-view matrix, so the motion happens on the GPU only. Start, Pause, Stop and speed controls drive the animation, and a custom Viewport draws a PAUSED overlay on top of the scene while the animation is paused.
Manipulator
This sample shows how to set a BlockReference as current and interactively move, rotate and scale it with the ObjectManipulator widget. Double-click sets the selected block reference as current, right-click starts editing, double-click applies the transformation and a second right-click cancels it. A panel controls the manipulator style, visible handles, size and snapping steps.
Measure Ultimate Fem
This sample demonstrates how to compute the minimum 3D distance between Brep faces, edges, vertices or whole entities with the MinimumDistance class, using mixed sub-item selection. The distance and its X, Y and Z components are displayed, and the measure line is drawn as an overlay.
MeshEditor
This sample shows how to edit mesh triangles and vertices interactively with the MeshEditor class. The available operations are edge flip, edge collapse, vertex dissolve for vertices shared by three or four triangles, and vertex cell and edge cell display; the changes are applied to the mesh on request. Video1
MVVM
This sample shows how to drive the Design control with WPF data binding. The entity list is an ObservableCollection kept in sync with the document, and viewport settings such as background, grid, coordinate system icon, origin symbol, view cube, legend and toolbar are bound to the controls of a side panel.
PaperDemo
This sample shows how to generate drawing views of your geometry in the Drawing workspace. The model is a configurable office desk (format, size, veneer and paint) and, yes, it is one of our own office desks, as you can see in this video. Changing the desk rebuilds it and updates its weight, and the drawing is generated on three sheets in metric and imperial units, with first and third angle projection, a detail view and overall dimensions. The Drawing tab lets you add vector, shaded and section views, dimensions, annotations and a bill of materials, change the scale, and print. You can also open or import STEP, IGES, OBJ, STL and other files to test view generation on your own geometry; a DWG/DXF file that contains AutoCAD paper space layouts brings its sheets into the Drawing workspace. Drawings can be exported to DWG as model space geometry, with the views exploded, and the active sheet can be exported to PDF. The views are built in the background as a work unit; to handle a queue of WorkUnits, see the WorkManager article. Ready to start? Read this introductory article on the Drawings environment. Video1, Video2
PerformanceStudio
This sample shows how each graphics setting affects drawing speed on a large building frame. The frame can be built as an assembly of blocks, as flattened entities or as a single mesh, to compare hierarchical, multiple and single objects. Of particular interest is the Depth Transparency option: when enabled, transparent objects write to the depth buffer, so accurate values can be obtained under the mouse cursor even on transparent objects. This affects 3D coordinate extraction and the determination of the center of rotation.
ProductConfigurator
This sample demonstrates how to create a parametric 3D chair model using the Mesh entity. You can change the seat width, the frame wood, and the seat color, and the dimensions and weight update accordingly. The resulting geometry can be exported to mesh formats such as STL and OBJ.
SceneEditor
This sample gives you full control over the scene lighting settings. The left pane shows the camera view, while the right pane shows the 3D scene from the director's point of view. You can turn on up to eight lights of point, spot, directional, and directional stationary types, and change the settings of each light. Only one light at a time can cast shadows, and point lights cannot. You'll also find the code to copy the content of one document to another with DesignDocument.CopyTo().
Simulation Fem
This sample illustrates Eyeshot's Finite Element Analysis capabilities, including plane, surface, and volume meshing, and 2D and 3D beams with hinge support. Clicking the "Numeric results" button opens a dialog that shows all the results in a table, which can be exported to a CSV file. Video1
SketcherDemo
This sample shows how to use the 2D constraint solver from the UI, including sketch extrude, revolve, and sweep features and assembly navigation to a specific component or Brep. The left pane contains the assembly and feature trees, and the sketch panel lets you import a sketch from DWG/DXF. Video1, Video2, Video3
SlicerDemo
This sample shows how to slice a 3D mesh for printing and simulate the extrusion process with a PrintSimulationMesh. Video1
SurfaceMesher Fem
This sample shows how to control the element size when meshing a surface and provides tools for evaluating the shape quality of the resulting triangles. Video1
TextureMapping
This sample shows how to apply different texture mappings to scene objects. You can try each mapping and U, V scale combination by dragging a material from the list onto a scene object. It also demonstrates how to create realistic, physically based materials. Video1
VolumeRendering
This sample demonstrates the Eyeshot DICOM features, including volume rendering, iso-surface reconstruction, sectioning, distance measurement, and STL export for 3D printing. Video1
WireEDM
This sample shows how to use the MultiFastMesh entity for machining simulations, using a wire EDM cutting process as an example.
Workspaces Ultimate Fem
This sample shows how Eyeshot workspaces (previously known as Environments) work on the same geometry. It also demonstrates how to programmatically define 2D sketches, orthographic and section views on a drawing sheet, a FEA study, and 3-axis CNC machining. Video1
EditMesh
This sample shows how to use the MeshEditor class to simplify an imported STL mesh by repeatedly collapsing the short edges of low-quality triangles and flipping edges where this improves triangle quality. Video1
MeshCurve Fem
This sample demonstrates how to subdivide a NURBS curve using a variable step with the CurveMesher class, producing a FemMesh of line elements. Video1