问题
I have an image in DigitalMicrograph GMS3 (v 3.21.1374.0) which i have applied a custom databar to (trying to learn how to do this via script here: add / apply custom databar to image in DigitalMicrograph GMS3)
I have a custom layout that I can add manually by doing the following:
- Right click on the image
- Hover on layout (in context menu)
- Left click "Apply Layout..."
- Select the custom layout in dialog that pops up (the one I want is called "CheckLayout")
- Click OK
How do I do this with a script? I know how to get the image and the imagedisplay objects but that is as far as I get.
//main - get front image and apply custom layout
image Img := GetFrontImage()
imageDisplay imgDisplay = Img.ImageGetImageDisplay(0)
//apply custom layout to image here
Any ideas?
回答1:
The layout is a property of an ImageDocument not an image. The correct way of doing this (provided there exists a layout of name 'MyLayout') is:
ImageDocument doc = GetFrontImageDocument()
doc.ImageDocumentApplyLayout("MyLayout")
You might additionally be interested in the commands:
void ImageDocumentApplyLayout( ImageDocument, String )
void ImageDocumentRemoveDatabar( ImageDocument )
Number ImageDocumentGetLayoutCount( ImageDocument )
String ImageDocumentGetLayoutName( ImageDocument, Number )
as used in
ImageDocument doc = GetFrontImageDocument()
number nLO = doc.ImageDocumentGetLayoutCount()
Result( "\n Layouts in document:" + nLO )
For( number i=0; i<nLO; i++)
{
string layoutName = doc.ImageDocumentGetLayoutName(i)
Result( "\n\t"+i+":"+layoutName)
}
来源:https://stackoverflow.com/questions/50822112/apply-custom-layout-to-image-in-digitalmicrograph-gms3