Icon representing a recipe

Recipe: tlaloc Band Explorer 1.03

created by Tlaloc

Profile


Name
tlaloc Band Explorer 1.03
ID
37146
Shared with
Public
Parent
None
Children
None
Created on
April 20, 2012 at 20:37 PM UTC
Updated on
April 20, 2012 at 20:37 PM UTC
Description

Dialog that lets you try different parameters for the band.Add() function. This is meant as an example for Lua programmers, although it can also be used to precisely create a band.

Best for


Code


-- tlaloc band.Add Explorer local ask = dialog.CreateDialog("band.Add Explorer") local countSegments = structure.GetCount() local atomIndexOrigin = 0 local atomIndexXAxis = 0 local atomIndexYAxis = 0 ask.SegmentOrigin = dialog.AddSlider("Origin Segment", 1, 1, countSegments, 0) ask.SegmentXAxis = dialog.AddSlider("X Axis Segment", 2, 1, countSegments, 0) ask.SegmentYAxis = dialog.AddSlider("Y Axis Segment", 3, 1, countSegments, 0) ask.Rho = dialog.AddSlider("Length (rho)", 10, 1, 100, 0) ask.Theta = dialog.AddSlider("Theta (in degrees)", 0, 0, 180, 0) ask.Phi = dialog.AddSlider("Phi (in degrees)", 0, 0, 360, 0) ask.Strength = dialog.AddSlider("Strength", 1, .1, 10, 1) ask.GoalLength = dialog.AddSlider("Goal Length", 10, 1, 100, 0) ask.AtomNumbers = dialog.AddCheckbox("Specify Atom numbers", false) ask.OK = dialog.AddButton("Create Band", 1) ask.Cancel = dialog.AddButton("Cancel", 0) if dialog.Show(ask) > 0 then local continue = true local segmentOrigin = ask.SegmentOrigin.value local segmentXAxis = ask.SegmentXAxis.value local segmentYAxis = ask.SegmentYAxis.value local rho = ask.Rho.value local theta = ask.Theta.value local phi = ask.Phi.value local bandStrength = ask.Strength.value local goalLength = ask.GoalLength.value if ask.AtomNumbers.value then local atoms = dialog.CreateDialog("Atom Numbers") atoms.AtomOrigin = dialog.AddSlider("Origin", 2, 1, structure.GetAtomCount(segmentOrigin), 0) atoms.AtomXAxis = dialog.AddSlider("X Axis", 2, 1, structure.GetAtomCount(segmentXAxis), 0) atoms.AtomYAxis = dialog.AddSlider("Y Axis", 2, 1, structure.GetAtomCount(segmentYAxis), 0) atoms.OK = dialog.AddButton("Create Band", 1) atoms.Cancel = dialog.AddButton("Cancel", 0) if dialog.Show(atoms) > 0 then atomIndexOrigin = atoms.AtomOrigin.value atomIndexXAxis = atoms.AtomXAxis.value atomIndexYAxis = atoms.AtomYAxis.value else continue = false end end if continue then -- print(segmentOrigin..","..segmentXAxis) -- band.AddBetweenSegments(segmentOrigin, segmentXAxis) -- band.Disable(band.GetCount()) -- band.AddBetweenSegments(segmentOrigin, segmentYAxis) -- band.Disable(band.GetCount()) -- band.AddBetweenSegments(segmentXAxis, segmentYAxis) -- band.Disable(band.GetCount()) local b = band.Add(segmentOrigin, segmentXAxis, segmentYAxis, rho, math.rad(theta), math.rad(phi), atomIndexOrigin, atomIndexXAxis, atomIndexYAxis) band.SetStrength(b, bandStrength) band.SetGoalLength(b, goalLength) end end

Comments