save ROI file with image title.roi
Hi,
Probably a beginner's problem.
I try to save the roi file from the feature manager with the image title and run this in a batch process.
Some weird things:
in code something like this (within a public function):
dim ROIname
'to get filename
ROIname = ThisApplication.ActiveDocument.FileName
' two ways to modify ROIname
Replace(ROIname,".tif",".roi")
or
ROIname = Left(trim(ROIname), len(trim(ROIname))-4) + ".roi"
both will give me the proper thing filetitle.roi
then the code from tool box recording....
With Select.FeaturesManagerCommands.Save(InteractROI) .Text = "SaveROI" .FileName = ROIname .Run() End With
However, when I edit and Load the extra code disappears as well as the var setting in the saveROI properties of the designer.
I tried setting the ROIname over the tool box in the designer and several other things. no help thus here my request.
What is my failure and how do I best pass the filetitle to ROI saving?
Thanks in advance
Daniel
0
Best Answer
-
Hi,
If you want to use custom code in SimpleMacro and able to modify it in the designer, you must use CodeCommand block (drop it from the toolbox):Public Function InteractROI() As SimpleScript InteractROI = New SimpleScript 'User variable Dim ROIname With Automate.ScriptingCommands.CodeCommand(InteractROI) If .Run() Then ' User Code Here ROIname = ThisApplication.ActiveDocument.FileName Replace(ROIname,".tif",".roi") End If End With With [Select].FeaturesManagerCommands.Save(InteractROI) .Text = "SaveROI" 'using my variable .FileName = ROIname .Run() End With End Function
Another option is to change the type of the macro to Sub, in that case it will not be possible to edit it in the designer, but you are free to modify it as you want in the Code view:Public Sub InteractROI2() Dim InteractROI As New SimpleScript 'User variable Dim ROIname ROIname = ThisApplication.ActiveDocument.FileName Replace(ROIname,".tif",".roi") With [Select].FeaturesManagerCommands.Save(InteractROI) .Text = "SaveROI" 'using my variable .FileName = ROIname .Run() End With End Sub
Regards,
Yuri0
Answers