Page 1 of 1

New script commands in SP6

Posted: 02 Apr 2024, 14:54
by fabdev
Selecting files and folders
the command SelectFile let the user to select just one file, and returns the filename as a string. Instead, the command SelectFiles allows to select several files and returns them as an array. It's possible to suggest an initial folder and the extension of the files:

Code: Select all

filename = SelectFile("C:\", "*.fit")
print filename

arr = SelectFiles("", "*.fit")
for i = 1 to UBound(arr)
 print arr(i)
next i
dir = SelectDir("C:\", "Select a folder for saving")
print dir
Persistent data
These commands allow to save some variables into a database (in memory). This is useful to share the values between different scripts. These values are not saved on disk, so they will be lost when Astroart is closed, but it's possible to save and reopen them with the commands: Data.Save(filename) and Data.Open(filename).
Launch the following script two times:

Code: Select all

if not Data.Contains("MyNumber") then
  print "This is the first execution"
  Data.Write("MyNumber", 314)
  Data.Write("MyName", "Oscar")
  print "Values saved"
end if

print "This is NOT the first execution"
print "The number was:" ; Data.Read("MyNumber")
print "The name was:" ; Data.Read("MyName")
The command Image.DrawCollimation draws a big ellipse with represent the shape of the stars, and draws the roundness.

Code: Select all

r = Image.Roundness
a = Image.Inclination
Image.DrawCollimation(r, a) 
for example, open an image, apply the following convolution:

1 0 0
0 1 0
0 0 1

then run the script above.

During an actual collimation, if you need to use only the central part of the sensor, select a subframe as shown here:

Code: Select all

size = 25    ' 25% of full frame, central part
offs = (100-size) / 2
Camera.Subframe(size,size, offs,offs)
while true
  r = Image.Roundness
  a = Image.Inclination
  Image.DrawCollimation(r, a)  
end while