Show folder-picker dialog, return selected path; pass filename to get the folder that contains it instead
File.GetFileName()
Show file-picker dialog, return selected path
File.GetFileNames()
Show multi-file-picker dialog, return list of paths
File.ReadCrystalList(filename)
Load a crystal list file (*.xml); omit filename to open a dialog
File.ReadCrystal(filename)
Load a CIF/AMC crystal file; omit filename to open a dialog. If the named file cannot be read, the macro stops with an error and the current crystal is unchanged
File.ExportAsCIF(filename)
Export the current crystal as CIF; omit filename to open a dialog
File.ReadText(filename)
Read a text file (UTF-8) and return it as a string; omit filename to open a dialog. Pairs with Crystal.LoadCifText() / SaveText()
File.SaveText(textData, filename)
Save text data to a file; writes textData as UTF-8, and omitting filename opens a save dialog
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.
Energy (keV for X-rays and electrons, meV for neutrons)
Wavelength
double
Wavelength (nm)
Thickness
double
Specimen thickness (nm)
NumberOfDiffractedWaves
int
Number of Bloch waves
CameraLength2
double
Camera length (mm)
ExcitationError
double
Spot radius (nm⁻¹): in kinematical/excitation mode, SpotInfo() exports reflections with |Sg| within this value
SkipRendering
bool
Effective only in dynamical mode (Calc_Dynamical()): the Bloch-wave calculation still runs (so SpotInfo() is valid), but no spots are drawn — images saved meanwhile contain no spots. No effect in kinematical/excitation mode
Position (mm) of the foot of the perpendicular from the sample to the detector, measured from the image centre; the image centre itself is at detector coordinates (−x, −y). Foot(0, 0) puts the foot at the image centre
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 Detect & fit 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. Returns 0 without searching when no image is loaded, fewer than two spots are registered or no crystal is selected
SpotID.CandidateList()
Return the candidate orientation list as CSV text
SpotID.SpotList()
Return the observed spots as CSV text, with the same columns as the Save button of Spot information. 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.
Beam energy (keV for X-rays and electrons, meV for neutrons)
CameraLength
double
Camera length (mm)
PixelSizeInMM
double
Pixel size (mm). Writing it switches the pixel-size unit to mm; reading it returns the value converted to mm without changing the unit
PixelSizeInNMinv
double
Pixel size (nm⁻¹). Writing it switches the unit to nm⁻¹; reading it returns the value converted to nm⁻¹ without changing the unit
MaxNumberOfSpots
int
Maximum number of spots FindSpots() may detect
NearestNeighbor
int
Minimum separation allowed between detected spots (pixels)
FittingRange
double
Radius of the region around each spot used for peak fitting (pixels)
AcceptableError
double
Tolerance of the relative d-spacing difference when matching spots to reflections (%)
IgnoreProhibitedReflections
bool
Ignore kinematically forbidden reflections, which can still appear via multiple diffraction. Always true for X-rays and neutrons; a value set then takes effect when the source is set back to electrons
MultiGrain
bool
Search for several grains; False means a single grain
MaxNumberOfGrains
int
Maximum number of grain orientations searched when MultiGrain is True
NumberOfDetectedSpots
int
Number of detected spots (read-only)
NumberOfCandidates
int
Number of candidates found by the last Identify() (read-only)
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. filename must end with .stl or .3mf (no dialog is opened); returns an information string with the triangle count and the printed size
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.