#Convert opened project

1 messages · Page 1 of 1 (latest)

rare ruin
#

To manually convert the currently opened model:
File->Convert Project->GeckoLib Animated Model->Confirm

Is there an API method that does that?

dusky escarp
rare ruin
dusky escarp
#

because its from a plugin

#

for geckolib export specifically

rare ruin
#

omg how are you so fast!!

#

Thanks...

dusky escarp
#

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

rare ruin
#

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!! care care care

dusky escarp
rare ruin
dusky escarp
#

It’s already in blockbench if the plugin is loaded

#

Formats.formatid.codec

rare ruin
# dusky escarp It’s already in blockbench if the plugin is loaded

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',
      });
    }
dusky escarp
#
Codecs.bedrock.export()``` is what it runs
#

Codecs.bedrock.compile() is what you want

#

will return the model as a json string

rare ruin
#

ohh!