• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Bgl2xml v Bgl2xml_GUI

GHD

Messages
12,243
Country
england
I am trying to write a program to find in which files a certain library object is defined and placed. To do this I call Bgl2xml V1.3.1.0 12th Jan 2011 to decompile bgls and then scan the output for model GUIDs.

In most cases it works very well, but, for a particular library, the GUID is output without the "-" dividing the fields (I am expecting these to be present).

Using Bgl2Xml_GUI.exe 1.4.0.0 12th July 2011, it doesn't output the GUID at all :eek:

Example:

Bgl2Xml.exe V1.3.1.0 12th Jan 2011

<ModelData
name="911f7b004d66fa908e6a5a9c6fe2f7ef"
sourceFile="ramp_light_dual.mdl"
fileOffset="0"/>

Bgl2Xml_GUI.exe 1.4.0.0 12th July 2011

<ModelData
sourceFile="ramp_light_dual.mdl"
fileOffset="0"/>

Is there any way I can convert the unhyphenated GUID to hyphenated?
 

scruffyduck

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
34,853
Country
unitedkingdom
Can you send me the file George?
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,859
Country
netherlands
Hi,

If the modeldata command has a guid defined, it's a fs2004 object. So then the format without dashes is as expected. For fsx objects the guid is not in the modeldata command anymore, but in the mdl itself.
 

scruffyduck

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
34,853
Country
unitedkingdom
I think Arno is correct on this. The libraries probably contain FS9 models. I have not checked this yet though............
 

GHD

Messages
12,243
Country
england
Hi,

If the modeldata command has a guid defined, it's a fs2004 object. So then the format without dashes is as expected. For fsx objects the guid is not in the modeldata command anymore, but in the mdl itself.

But will FSX report a missing object in FS9 format?
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,859
Country
netherlands
I don't think so. Actually at the binary level in the bgl file there is no difference how the guid is stored. Only in the XML file there is a difference.

You can convert between the two, I do that in modelconverterx as well. I'll dig up my code tomorrow.
 

scruffyduck

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
34,853
Country
unitedkingdom
ADE will convert also when creating the XML before compile.
 

GHD

Messages
12,243
Country
england
All I have is the FSX error dialog which is in FSX format, so I need to convert the FS9 format given by Bgl2Xml.
 

GHD

Messages
12,243
Country
england
I think I have figured it out.

If the unhypenated GUID has the bytes in order 0 to 15, the hyphenated GUID will be:

(3, 2, 1, 0) - (5, 4) - (7, 6) - (8, 9) - (10, 11, 12, 13, 14, 15)

It seems to work on my system.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,859
Country
netherlands
Yes, that sounds right. Sorry, did have the time to look up the code.
 

scruffyduck

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
34,853
Country
unitedkingdom
This is the code from my library (in C#)

/// <summary>
/// Used to convert an FS9 style GUID to the FSX/registry standard
/// </summary>
/// <param name="input">Input GUID. Can be in old or new format. If in new format it is just returned</param>
/// <returns>GUID in FSX/registry format</returns>
public static string ConvertOldGuid2New(string input)
{

if (input.Length == 32 || input.Length == 36 || input.Length == 38)
{

if (input.Contains("-"))
{
return input; // in new format just send it back
}

var output = new StringBuilder();
var bytes = new string[16];

for (int i = 0; i < 32; i += 2)
{
int j = i / 2;
bytes[j] = input.Substring(i, 2);
}

output.Append(bytes[0] + bytes[1] + bytes[2] + bytes[3] + "-");
output.Append(bytes[6] + bytes[7] + "-");
output.Append(bytes[4] + bytes[5] + "-");
output.Append(bytes[11] + bytes[10] + "-");
output.Append(bytes[9] + bytes[8] + bytes[15] + bytes[14] + bytes[13] + bytes[12]);
return output.ToString();
}

throw new Exception("Guid Converter input not 32 or 36 characters");
}

The output lines are assembling the byes in order
 

GHD

Messages
12,243
Country
england
Thanks Jon.

In the end, I created new code which allowed me to find placement bgls containing references to undefined GUIDs.

Given a 32 character string containing an FS9 format GUID as created by Bgl2Xml, FS9[0-31], to convert to a 36 character FSX format GUID, FSX[0-35]:

Code:
 FSX = FS9[0];
 FSX += FS9[1];
 FSX += FS9[2];
 FSX += FS9[3];
 FSX += FS9[4];
 FSX += FS9[5];
 FSX += FS9[6];
 FSX += FS9[7];
 FSX += "-";
 FSX += FS9[12];
 FSX += FS9[13];
 FSX += FS9[14];
 FSX += FS9[15];
 FSX += "-";
 FSX += FS9[8];
 FSX += FS9[9];
 FSX += FS9[10];
 FSX += FS9[11];
 FSX += "-";
 FSX += FS9[22];
 FSX += FS9[23];
 FSX += FS9[20];
 FSX += FS9[21];
 FSX += "-";
 FSX += FS9[18];
 FSX += FS9[19];
 FSX += FS9[16];
 FSX += FS9[17];
 FSX += FS9[30];
 FSX += FS9[31];
 FSX += FS9[28];
 FSX += FS9[29];
 FSX += FS9[26];
 FSX += FS9[27];
 FSX += FS9[24];
 FSX += FS9[25];
 
Last edited:
Top