#Convert opened project
1 messages · Page 1 of 1 (latest)
After the project is converted, I can do: Filre-> Export-> Export GeckoLib Model.
Do you happen to know this part in the repo as well?.
I searched in the repo but I sadly didn't find it... ):
because its from a plugin
for geckolib export specifically
if you want to trigger the action through code, you should be able to use js BarItems.export_geckolib_model.click()
thats the same as pressing the button
yeah but it opens a dialog to where it should be saved so I'll need to see how it functions internally so that I save it without that it asks each time I want to export
But thank you so much!!

If I use this, I'd need to import the codec of the plugin.
Is that possible?
ok so below is what I did. It kind of works, but not really.
I mean, when I export it directly with the button it is perfect.
But when I export it with the code below it looks weird and many bones are missing/misplaced/weird things happens to the models.
And I don't understand why isn't the same result coming out of my plugin as the "export" button.
// Try to get the GeckoLib codec
const geckolibCodec = targetFormat.codec;
if (geckolibCodec && typeof geckolibCodec.compile === 'function') {
// Use the GeckoLib codec's compile method to generate the model data
const modelData = geckolibCodec.compile();
// Define the output file name and path
const outputFileName = Project.name + '.geo.json';
const outputFile = outputPath + '\\' + outputFileName;
// Write the model data to the output file
if (typeof geckolibCodec.write === 'function') {
geckolibCodec.write(modelData, outputFile);
} else {
Blockbench.showMessageBox({
title: 'Error',
message: 'GeckoLib codec write method not found.',
icon: 'error_outline',
});
}
} else {
Blockbench.showMessageBox({
title: 'Error',
message: 'GeckoLib codec not found. Make sure the GeckoLib plugin is loaded.',
icon: 'error_outline',
});
}
looking at the code for the plugin it just uses the bedrock codec
Codecs.bedrock.export()``` is what it runs
Codecs.bedrock.compile() is what you want
will return the model as a json string
ohh!
