A crystal is built in a pending draft: start one, fill it with the setters, and Commit() validates everything, builds the crystal, and applies it as the current crystal in one step (the GUI and all open simulators update, as when a CIF file is loaded). A failed Commit() reports all validation errors together, changes nothing, and keeps the draft so it can be fixed and committed again.
Function
Description
Crystal.BeginCreate(name)
Start a draft for a new crystal
Crystal.BeginEdit()
Start a draft from the current crystal (cell, space group, atoms and orientation are carried over)
Crystal.LoadCifText(cifText)
Start a draft from CIF text (the content of a .cif file, not a path)
Crystal.SetName(name)
Rename the draft
Crystal.SetCellInAng(a, b, c, alpha, beta, gamma)
Cell constants in Å and degrees. Each call replaces the whole cell; omitted arguments are derived from the space-group constraints (for a cubic crystal, a alone is enough), and explicit values that contradict them raise an error
Crystal.SetSpaceGroup(symbol)
Space group by symbol (HM short/full or Hall; spaces and _ are ignored). Append the setting ('Fd-3m:2', 'R-3c:H', 'P21/c:b1') when the group has several — ambiguous symbols raise an error listing the candidates
Crystal.SetSpaceGroupByNumber(itNumber, setting)
Space group by IT number (1–230); setting ('1', '2', 'H', 'R', 'b1', …) picks among multiple settings
Crystal.AddAtom(label, element, x, y, z, occ, bIso)
Add an atom of the asymmetric unit: element symbol, fractional coordinates, occupancy (0 < occ ≤ 1, default 1) and isotropic B in Ų (default 0). Equivalent positions, Wyckoff letters and multiplicities are derived automatically
After a successful Commit(), the next BeginEdit() starts from the updated crystal, so changes accumulate — for absolute scans, read the base values before the loop, as above. To register the committed crystal in the crystal list, call CrystalList.Add().
Set the orientation from nine rotation-matrix elements (validated and re-orthonormalized before use)
Euler angles are not unique at gimbal positions (θ = 0 or 180°): GetEuler() after Euler() reproduces the same attitude, but not necessarily the same numbers. To save and restore the orientation exactly, use Dir.GetRotationMatrix() / Dir.SetRotationMatrix(). The full convention is described in 4. Rotation Geometry.
Drives Spot ID v2 from a macro: load an image or a spot list, detect the spots, search for orientations and read the candidates back, without touching the window. FindSpots() and Identify() return only once the work has finished, so they can be chained directly.
Load a file as File > Load does: .csv is read as a spot list (an image must be loaded first), any other extension as a diffraction pattern image (dm3, dm4, mrc, ipa, tif and other supported formats). Omit filename to open a file dialog
SpotID.FindSpots()
Detect the spots in the loaded image and fit them, as the Find spots button does
SpotID.Identify()
Search for orientations that explain the detected spots, as the Identify spots button does, and return the number of candidates. The crystals tested are those selected in the crystal list of the main window
SpotID.CandidateList()
Return the candidate orientation list as CSV text
SpotID.SpotList()
Return the observed spots as CSV text, with the same columns as File > Save. Pair it with File.SaveText() to write a file that LoadFile() can read back
CandidateList() gives, for each candidate: crystal name, the Z-X-Z Euler angles (deg), the nine rotation-matrix elements R11–R33 (crystal frame to laboratory frame, applied to column vectors), the mean-squared residual (nm⁻²), and the assignment of observed spots to hkl indices. Candidates come ordered by the number of assigned spots (descending), then by the residual (ascending). Numbers are written in the invariant culture, so the decimal separator is always a period.
Drives the Structure Viewer window from a macro. SaveImage() and Export3DModel() open the window first when necessary, because the 3D model is built when the window is shown.
Function
Description
StructureViewer.Open()
Open the Structure Viewer window
StructureViewer.Close()
Close the Structure Viewer window
StructureViewer.SaveImage(filename)
Save the rendered main view as a PNG file, at the pixel size given by the Size (W×H) box; omit filename to open a dialog
Export the displayed structure for 3D printing, like Export 3D Model (3MF/STL) in the File menu. The extension picks the format (.stl single color / .3mf colored by element); only filename is required — the other defaults equal the dialog defaults (largest dimension 80 mm, unit-cell edges ⌀2.4 mm, bonds thickened to ⌀1.2 mm). Pass fixedScaleInMMperNm > 0 to build several models at the same scale
These three image-simulation classes share many members. To avoid repetition, the tables below use placeholders:
# : common to HRTEM, STEM and Potential. Replace # with HRTEM, STEM, or Potential (e.g. STEM.Simulate(), Potential.AccVol).
$ : common to HRTEM and STEM only. Replace $ with HRTEM or STEM.
Members written with an explicit class name (STEM.… / HRTEM.…) belong to that class only. The Potential class adds no members of its own; it uses only the # members.