问题描述
我正在尝试模仿 GMS v3 中的自动保存功能,以便我可以在版本 1 和 2 中使用。我想首先承认脚本的主要部分来自 Bernhard Schaffer 博士的“如何编写脚本...数码显微照片脚本手册”。我对其进行了一些修改,以便相机记录的任何新图像都可以自动保存到文件中。但是,我遇到了一些问题,因为如果我决定单击实时取景图像并四处移动图像,或者使用实时fft,实时取景图像或 FFT 图像也将被保存。我的想法之一是使用标签组信息,例如“采集:参数:参数集名称”,因为对于实时视图或实时 FFT,这将处于搜索或聚焦模式。另一个想法是使用文档 ID,例如 iDocID = idoc.ImageDocumentGETID() 来定位实时图像的 ID。但是,我不知道如何使用此信息将它们从自动保存中排除。谁能指出我如何继续这个脚本? 下面是脚本
Class PeriodicAutoSave : Object
{
Number output
PeriodicAutoSave(Object self) Result("\n Object ID"+self.ScriptObjectGetID()+" created.")
~PeriodicAutoSave(Object self) Result("\n Object ID"+self.ScriptObjectGetID()+" destroyed")
Void Init2(Object self,Number op)
output=op
Void AutoSave_SaveAll(Object self)
{
String path,name,targettype,targettype1,area,mag,mode,search,result1
ImageDocument idoc
Number nr_idoc,count,index_i,index,iDocID,iDocID_search
path = "c:\\path\\"
name = "test"
targettype=="Gatan Format (*.dm4)"
targettype1 = "dm4"
If (output) Result("\n AutoSave...")
nr_idoc = CountImageDocuments()
For (count = 1; count<nr_idoc; count++)
{
idoc = GetImageDocument(count) //imagedocument
index = 1 // user decide the index to start with
index_i= nr_idoc - index
If (idoc.ImageDocumentIsDirty())
{
idoc = getfrontimagedocument()
iDocID = idoc.ImageDocumentGetID()
TagGroup tg = ImageGetTagGroup(idoc.ImageDocumentGetImage(0)) // cannot declare an 'img' for this line as it will prompt an error?
tg.TagGroupGetTagAsString("Microscope Info:Formatted Indicated Mag",mag)
Try{
{
idoc.ImageDocumentSavetoFile( "Gatan Format",path+index_i+"-"+name+"-"+mag+".dm4")
idoc.ImageDocumentSetName(index_i + "-"+name+"-"+mag+".dm4")
idoc.ImageDocumentClean()
}
If (Output) Result("\n\t saving: "+idoc.ImageDocumentGetCurrentFile())
}
Catch{
Result("\n image cannot be saved at the moment:" + GetExceptionString())
Break
}
Result("\ Continue autosave...")
}
}
}
}
Void LaunchAutoSave()
{
Object obj = Alloc(PeriodicAutoSave)
obj.Init2(2)
Number task_id = obj.AddMainThreadPeriodicTask("AutoSave_SaveALL",6)
//Sleep(10)
while(!shiftdown()) 1==2
RemoveMainThreadTask(task_id)
}
LaunchAutoSave()
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)