New script commands in SP6

Scripts and programs to automate Astroart
Post Reply
fabdev
Posts: 500
Joined: 03 Dec 2018, 21:43

New script commands in SP6

Post by fabdev » 02 Apr 2024, 14:54

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
Pause(3)

arr = SelectFiles("", "*.fit")
for i = 1 to UBound(arr)
 print arr(i)
next i
Pause(3)
 
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"
  Script.Stop
end if

print "This is NOT the first execution"
print "The number was:" ; Data.Read("MyNumber")
print "The name was:" ; Data.Read("MyName")
Collimation
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
  Camera.Start(3)
  Camera.Wait
  r = Image.Roundness
  a = Image.Inclination
  Image.DrawCollimation(r, a)  
  Image.ClosePrevious
end while

Post Reply