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.

User Interface

WinForms or WPF

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.

Arrows

This sample shows how to create a set of arrows with the Mesh.CreateArrow() static method and lay them out along an arc, positioning and orienting each one with the Transformation class.

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.

Assemble

This sample shows three ways to put two shapes back into the holes of a plate: a transformation recomputed frame by frame, a BlockReference that animates itself, and a single transformation applied at once.

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

Barbecue Ultimate Fem

This sample shows how to create a 3D model of a barbecue from extruded Brep solids, using cutting operations for the slots and the notch of the wall and Brep.AddFlange() for the sheet metal cover.

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

Building

This sample shows how to use Block and BlockReference to model a 3D building whose columns, floors and walls are defined once and inserted many times. It also shows how to use the Attribute entity to give each column insertion its own price.

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.

CompareDWG

This sample shows how to compare the entities of two 2D drawings, highlighting those that were added, removed or modified, and how to keep the cameras of two independent Design controls in sync.

ComputeDistance Ultimate Fem

This sample demonstrates how to compare a point cloud with a set of surfaces using the ComputeDistances class. The distances are computed asynchronously, and each point is then colored according to its distance from the model, using the bands of the viewport Legend.

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.

CustomViewportLayout

This sample shows how to create a custom viewport layout by overriding UpdateViewportsSizeAndLocation(), and how to switch between the built-in layouts. It also shows how to change the gap between viewports and the viewport border style, including its color and corner radius.

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

DraftAnalysis

This sample demonstrates how to split a Mesh entity into sections based on a pull direction, chosen by picking a face, and how to move the resulting BlockReference entities apart along that direction with a slider.

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

ExploreIFC

This sample shows how to read an IFC file with ReadIFC and explore its property tree, with the properties of the element selected in the tree or in the viewport.

EyeshotDemo

This sample is a fully featured application that demonstrates the capabilities of the Design control on ten different scenes. Video1

FeatureDetection Ultimate Fem

This sample shows how to detect faces of a specific surface type (plane, cylinder, cone, sphere, torus) on a Brep. Radius and half-angle filters narrow down the cylinders or cones detected, and the Show axes option draws the cylinders' axes.

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

FunctionPlot

This sample demonstrates how to draw a point cloud or mesh entity with a different color on each vertex, as well as how to quickly change the points' coordinates using the FastMesh and FastPointCloud entities.

GCodeSimulator

This sample shows how to read a G-code file with ReadGCode and simulate 3-axis CNC machining. Video1

Globe

This sample demonstrates how to create a globe model using the Mesh.CreateSphere() static method and how to apply a world map texture to it spherically with the Mesh.ApplyMaterial() method. It also shows how to rotate the scene by dragging a compass drawn over the viewport.

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

Gym Ultimate Fem

This sample demonstrates how to create a gym frame using swept, extruded and revolved NURBS surfaces trimmed with Surface.Trim().

HybridEntity

This sample shows how to dynamically change the nature of an entity. A custom Mesh-derived entity draws the beams either as a mesh or as wires, and handles drawing and selection consistently in both natures.

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.

LineTypes

This sample shows how to apply line types to curve entities, either through their layer or per entity (LineTypeMethod set to byEntity). The scene also uses Joint and Bar entities to model a truss frame.

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.

MarchingCubes

This sample shows how to extract the isosurface of a 3D scalar field with the MarchingCubes class, producing a Mesh entity. A slider changes the iso level and the surface is regenerated.

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

Part1

This sample demonstrates how to build an L-shaped bracket by creating individual Mesh entities, merging them with MergeWith() and computing the part volume with VolumeProperties. It also shows how to add multiple origin symbols (UCS markers) to the same Viewport.

PenLike

This sample shows how to draw on the Design control as with a pen: while the left mouse button is held down, the mouse path is drawn over the scene as a thick line in a DrawOverlay() override.

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.

PipeBending Ultimate Fem

This sample demonstrates how to simulate a pipe bending machine step by step and check for collisions between the pipe and the machine with the CollisionDetection class.

PistonAnimation

This sample demonstrates how to animate a collection of BlockReference entities.

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.

Rocket

This sample shows how to aim and launch a toy rocket, animated as a BlockReference, at three different targets.

Routing Ultimate Fem

This sample shows how to draw and shape an electrical wire or flexible pipe. You can click the pipe to add joints, then right-click a joint to move it with the ObjectManipulator.

RubberBandCurve Ultimate Fem

This sample demonstrates how to interactively draw and edit a NURBS curve.

RubberBandLine

This sample demonstrates how to interactively draw a LinearPath entity.

Ruler

This sample shows how to draw an interactive ruler on the viewport surface. The tick density changes based on the current zoom factor. It also shows how to overlay a logo on the 3D scene.

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().

SelectElements Fem

This sample shows how to implement the selection of individual elements or nodes of a FemMesh entity.

SelectPoints

This sample demonstrates how to implement a custom polygon selection on a FastPointCloud entity, including the Delete, Undo, and Unselect commands.

SelectTriangles

This sample shows how to select individual triangles of a Mesh, or individual segments of a LinearPath on the Lines tab, by pick, box, or polygon. The selection is designed for large objects with a high number of vertices.

Shaders

This sample shows how to create custom OpenGL vertex and fragment shaders, including toon, anisotropic, liquid fill, and skydome shaders.

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

SnapToGrid

This sample shows how to snap points to the grid lines while drawing walls with the mouse.

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

SurfaceSection Ultimate Fem

This sample shows how to compute the section of a 3D surface model with a plane that can be moved up and down.

TempEntities

This sample demonstrates how to use temporary entities to highlight an item or guide a workflow in your application, such as picking, moving, or dragging and dropping. These entities stay separate from the actual entities of the 3D scene.

TextOnCurve Ultimate Fem

This sample demonstrates how to place text along a freeform curve.

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

Transformation

This sample demonstrates how to position planar entities, such as circles and text, on planes other than the XY plane.

VolumeRendering

This sample demonstrates the Eyeshot DICOM features, including volume rendering, iso-surface reconstruction, sectioning, distance measurement, and STL export for 3D printing. Video1

Wing Ultimate Fem

This sample demonstrates how to create a solid Brep by lofting between two airfoil profiles, which can then be exported to the STEP file format.

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

Console

Cross-platform

CheckCollision

This sample shows how to use the CollisionDetection class to check a part read from a file against a Brep cone and print the results to the console.

ComputeExtents

This sample demonstrates how to calculate the bounding box of an assembly loaded from a file, and how to compute its total weight from the volume and material density of each part, walking through nested BlockReference entities.

ComputeVolume

This sample shows how to compute the volume of a Mesh entity, created with Mesh.CreateCylinder(), using the VolumeProperties class.

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

GenerateDrawing Ultimate Fem

This sample shows how to create a Brep and generate a drawing sheet with front, top and trimetric views of it, which is then exported to an HTML page with inline SVG. The views are generated asynchronously with ViewBuilder.DoWorkAsync().

GenerateToolpath Ultimate Fem

This sample demonstrates how to import geometry from a file, generate a parallel finish toolpath on it with a ball end mill, and compute the volume of stock removed. The toolpath is computed asynchronously with DoWorkAsync().

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

WriteIges Ultimate Fem

This sample shows how to create a surface, curves, and text and export them to the IGES file format with WriteIGES.