Hi,
Is it possible to add the option of saving and reading the position of the reticule?
Save and read the position of the reticule
Forum rules
'+1' posts are welcome in this area of the forums to indicate your support for a particular feature suggestion. Suggestions that get the most +1's will be seriously considered for inclusion in future versions of SharpCap.
'+1' posts are welcome in this area of the forums to indicate your support for a particular feature suggestion. Suggestions that get the most +1's will be seriously considered for inclusion in future versions of SharpCap.
- admin
- Site Admin
- Posts: 13339
- Joined: Sat Feb 11, 2017 3:52 pm
- Location: Vale of the White Horse, UK
- Contact:
Re: Save and read the position of the reticule
Hi,
it's possible to access (fetch and modify) the reticule position using the built in Python scripting language
Since you can also add custom toolbar buttons and other UI using the Python language it would be possible to make buttons to save/load reticule position using this approach.
I often recommend using Python scripting to add features when I haven't heard the request before - it's a great way for users to add custom functionality to SharpCap that may be perfect for their particular usage but might not be of interest to many other users. If I hear lots of people asking for the same feature then that feature gets more consideration for addition to core SharpCap.
thanks,
Robin
it's possible to access (fetch and modify) the reticule position using the built in Python scripting language
Code: Select all
>>> print SharpCap.Reticules.SelectedReticule.FractionalPosition
{X=0.5, Y=0.5}
>>> clr.AddReference("System.Drawing")
>>> from System.Drawing import PointF
>>> SharpCap.Reticules.SelectedReticule.FractionalPosition = PointF(0.1,0.3)
I often recommend using Python scripting to add features when I haven't heard the request before - it's a great way for users to add custom functionality to SharpCap that may be perfect for their particular usage but might not be of interest to many other users. If I hear lots of people asking for the same feature then that feature gets more consideration for addition to core SharpCap.
thanks,
Robin
Re: Save and read the position of the reticule
Thank you for the hint, I'm interested in the Python language.
Pawcio
Pawcio
Re: Save and read the position of the reticule
I came back to the topic. I read a bit and .. it worked! Sorry about the syntax - this is my first python script.
Code: Select all
import os,sys,re
file_tmp = (os.getenv("TEMP") if os.name=="nt" else "/tmp") + os.path.sep + "tempfilename.tmp"
def write_pos():
PointF = SharpCap.Reticules.SelectedReticule.FractionalPosition
file = open(file_tmp,"w")
sys.stdout = file
print PointF
file.close()
def read_pos():
clr.AddReference("System.Drawing")
f = open(file_tmp,"r")
Point = f.readline()
f.close()
x=float.Parse(re.findall ("{X=(\\d+.\\d+)",Point)[0])
y=float.Parse(re.findall ("Y=(\\d+.\\d+)}",Point)[0])
SharpCap.Reticules.SelectedReticule = SharpCap.Reticules[1]
from System.Drawing import PointF
SharpCap.Reticules.SelectedReticule.FractionalPosition = PointF(x,y)
SharpCap.AddCustomButton("ZAPIS", None, None, write_pos)
SharpCap.AddCustomButton("ODCZYT", None, None, read_pos)
Last edited by Pawcio_K on Wed Dec 08, 2021 9:54 am, edited 1 time in total.
- admin
- Site Admin
- Posts: 13339
- Joined: Sat Feb 11, 2017 3:52 pm
- Location: Vale of the White Horse, UK
- Contact:
Re: Save and read the position of the reticule
Hi Pawcio,
good to hear that it worked, and thanks for sharing your script!
Robin
good to hear that it worked, and thanks for sharing your script!
Robin