|
|
|
|
Administrators Customers Important Contributors FamilyTrees.GenoPro.com GenoPro version: 3.1.0.1
Last Login: 2 days ago @ 9:23 PM
Posts: 3,464,
Visits: 26,854
|
Attached is an amended version that adds 'drag and drop' functionality and also grabs genopro.exe path from the registry. Download the .txt file, rename as ExportEMFs.bat then just drag your .gno file over it and drop on it to produce emf images of each GenoMap.
(Rename required as forum does not allow .bat files as attachments. Could have zipped it instead but rename seems easier)
'lego audio video erro ergo disco' or "I read, I listen, I watch, I make mistakes, therefore I learn"
ExportEMFs.txt
(20 views,
7.50 KB)
|
|
|
|
|
Forum Members
Last Login: Thursday, January 22, 2015
Posts: 8,
Visits: 18
|
Thanks :-)My first time using windows scripting host api, but I program in Java/ JavaScript so not much of a jump in learning. Your examples made it easy to implement :-) I initially uses autohotkeys as you suggested, but thought nicer having a one script. Good idea about looking up in registry and maybe aborting if key not found! For us hard coding the exe is ok as all our severs are x64, but yes script is there for people to customize for their own needs. And yes a one line where you specify just the file name could be easily implemented using example code as a template :-)
|
|
|
|
|
Administrators Customers Important Contributors FamilyTrees.GenoPro.com GenoPro version: 3.1.0.1
Last Login: 2 days ago @ 9:23 PM
Posts: 3,464,
Visits: 26,854
|
Wow! I am seriously impressed with some very clever scripting techniques you have used here. Certainly enough to keep my few remaining grey cells active. I love the batch zone / script zone idea. I have come across SendKeys before but had slipped out of my memory. 
Just a couple of things I would change. Some of us old 'uns haven't got 64 bit Windows so it won't find GenoPro.exe in Program Files (x86), so perhaps get the path from the registry? HKEY_CLASSES_ROOT\GenoPro.Document\protocol\StdFileEditing\server for example? Also allow for a single argument of just the .gno file to allow a simple drag'n'drop of a .gno onto the .bat file.
'lego audio video erro ergo disco' or "I read, I listen, I watch, I make mistakes, therefore I learn"
|
|
|
|
|
Forum Members
Last Login: Thursday, January 22, 2015
Posts: 8,
Visits: 18
|
the regex I wrote will pickup the first line and will be fine even if there is an end tag.
Here is my code - it is a batch file that defers all execution code to the jscript in the batch file. It will unzip the .gno data. xml fileIt will convert old 1.x format files to the new file format by opening and saving the file in genopro. If will export the files out to emf files. ConvertGno.bat <JobId> <.gnoFileToExportToEmf> <LogFile> Example: ConvertGno.bat 111 E:\psoft\Adlib\4.11\Shared\FSA\NewFormat.gno c:\test.log People feel free to use the code as you wish.
|
|
|
|
|
Administrators Customers Important Contributors FamilyTrees.GenoPro.com GenoPro version: 3.1.0.1
Last Login: 2 days ago @ 9:23 PM
Posts: 3,464,
Visits: 26,854
|
Well I think I can say in hindsight that my decision to take the 'easy' option of regex was wrong!
My sample xml had for example | <GenoMap Name="Potter" Zoom="115" Position="139,-81" BoundaryRect="-395,216,400,-437"> |
so beware there could be a closing tag. 
Haven't got my head around your regex for the Name yet but I now think the DOM approach using MS XML will be more robust, I like a challenge and at 64 years old (tomorrow!) I need to keep the grey cells working to delay the onset of dementia so I'll take a shot at it.
'lego audio video erro ergo disco' or "I read, I listen, I watch, I make mistakes, therefore I learn"
|
|
|
|
|
Forum Members
Last Login: Thursday, January 22, 2015
Posts: 8,
Visits: 18
|
thanks
i had issues with your regex - your matches looked for an end tag when there is none...so i replaced it with the below
var maps = xmlText.match(/<GenoMap .*>/mg);
also
i replaced you getting the name attribute with
var mapName = maps[index].replace(/(.*Name\=")([^"]+)(".*)/, "$2");
as your regex didnt work as expected.
i will post my file once im finished - thanks for the help!
|
|
|
|
|
Administrators Customers Important Contributors FamilyTrees.GenoPro.com GenoPro version: 3.1.0.1
Last Login: 2 days ago @ 9:23 PM
Posts: 3,464,
Visits: 26,854
|
appleshaw, kane81 is refering to old (i.e. pre file format change to XML) .gno files. version 1.x? There is no need to rename .gno before unzipping, as shown in my earlier post, 7-Zip is able to determine the compression algorithm and extract Data.xml kane81, there are a t least a couple of ways to extract the GenoMap tags, one is to load the XML into a DOM using say MS XML parser. I have used this approach in many of my Report skins. However in this case I thought it would be easier to use regular expressions. It took a while as my regex knowledge is fading but attached is a revised script that names the output emfs using the Name of each GenoMap found. (Sorry I forgot to change the comments at beginning refering to the old output name) Its contents are /* * Create EMF images of each GenoMap in a GenoPro XML file given in a command line argument * * EMFs are named GenoMap<n>.emf, <n> is index number of map and are created in the current folder * * Usage: * * cscript SavePictureOfGenoMap.js <GenoPro XML file> * * e.g. cscript SavePictureOfGenoMap.js Data.xml */ var fso = new ActiveXObject("Scripting.FileSystemObject"), genopro = new ActiveXObject("GenoPro.Document"); var file = fso.OpenTextFile(WScript.Arguments(0), 1); var xml = file.readall(); genopro.SetTextXml(xml); file.Close(); var i, maps = xml.match(/<GenoMap[\s\S]*?<\/GenoMap>/mg); // get each GenoMap Tag N.B. [\s\S] matches any character including newline, the ? makes it non greedy for (i=0; i<maps.length; i++) { var name = maps[i].match(/Name\="([^"]+)"/); // get the Name attribute from this GenoMap tag with the name as a submatch if (fso.FileExists(name[1] + '.emf')) fso.DeleteFile(name[1] + '.emf'); // name[1] is the submatch genopro.SavePictureOfGenoMap(i, name[1] + '.emf'); if (fso.FileExists(name[1] + '.emf')) { WScript.Echo('Created ' +name[1] + '.emf'); } else { WScript.Echo('Failed to create ' +name[1] + '.emf'); } } WScript.Echo("Finished: Created "+ i +" EMF files");
|
as for old 1.x .gno files, there is no XML to load as you have said and so the above approach cannot be used. In a former life I have used AutoIt to poke keys/strings at 'interactive' programs to achieve a batch mode operation. A quick Google indicates that AutoHotKey maybe be a candidate as a AutoIt replacement. Which version of GenoPro do you use to laod your old .gno files? Does it have an 'Export to EMF' function? If not it will be necessary to convert those old .gno files to the new format.
'lego audio video erro ergo disco' or "I read, I listen, I watch, I make mistakes, therefore I learn"
emf.js
(13 views,
1.26 KB)
|
|
|
|
|
Customers Important Contributors FamilyTrees.GenoPro.com GenoPro version: 3.1.0.0
Last Login: 2 hours ago
Posts: 1,595,
Visits: 32,483
|
If you rename a current .gno file as .zip and extract it, it is the same as an xml file. You can of course save as xml
|
|
|
|
|
Forum Members
Last Login: Thursday, January 22, 2015
Posts: 8,
Visits: 18
|
Also is it possible to get the tab name that you are saving out to a file too?
ie: something like var tabName = genopro.GetTabName(index);
|
|
|
|
|
Forum Members
Last Login: Thursday, January 22, 2015
Posts: 8,
Visits: 18
|
Thanks,
Tested and it works great - however is there anyway I can also convert the old .gno files to emf files? the old .gno files are not zipped and I tried renaming to .xml but that didnt work either :/
|