From b05edfa82209a578451efae0f141481b0380b81d Mon Sep 17 00:00:00 2001 From: matt-159 Date: Mon, 27 Jun 2022 23:37:51 -0700 Subject: [PATCH 01/22] improved readability --- __init__.py | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/__init__.py b/__init__.py index 3390b9f..6fdc103 100644 --- a/__init__.py +++ b/__init__.py @@ -166,29 +166,29 @@ def runAsHeadless(): # print(pairs) - settings.nftName = pairs[0][1] - settings.collectionSize = int(pairs[1][1]) - settings.nftsPerBatch = int(pairs[2][1]) - settings.save_path = pairs[3][1] - settings.enableRarity = pairs[4][1] == 'True' - settings.enableLogic = pairs[5][1] == 'True' - settings.imageBool = pairs[6][1] == 'True' - settings.imageEnum = pairs[7][1] - settings.animationBool = pairs[8][1] == 'True' - settings.animationEnum = pairs[9][1] - settings.modelBool = pairs[10][1] == 'True' - settings.modelEnum = pairs[11][1] - settings.batchToGenerate = int(pairs[12][1]) - settings.cardanoMetaDataBool = pairs[13][1] == 'True' - settings.cardano_description = pairs[14][1] - settings.erc721MetaData = pairs[15][1] == 'True' - settings.erc721_description = pairs[16][1] - settings.solanaMetaDataBool = pairs[17][1] == 'True' - settings.solanaDescription = pairs[18][1] - settings.enableCustomFields = pairs[19][1] == 'True' - settings.customfieldsFile = pairs[20][1] - settings.enableMaterials = pairs[21][1] == 'True' - settings.materialsFile = pairs[22][1] + settings.nftName = pairs[0][1] + settings.collectionSize = int(pairs[1][1]) + settings.nftsPerBatch = int(pairs[2][1]) + settings.save_path = pairs[3][1] + settings.enableRarity = pairs[4][1] == 'True' + settings.enableLogic = pairs[5][1] == 'True' + settings.imageBool = pairs[6][1] == 'True' + settings.imageEnum = pairs[7][1] + settings.animationBool = pairs[8][1] == 'True' + settings.animationEnum = pairs[9][1] + settings.modelBool = pairs[10][1] == 'True' + settings.modelEnum = pairs[11][1] + settings.batchToGenerate = int(pairs[12][1]) + settings.cardanoMetaDataBool = pairs[13][1] == 'True' + settings.cardano_description = pairs[14][1] + settings.erc721MetaData = pairs[15][1] == 'True' + settings.erc721_description = pairs[16][1] + settings.solanaMetaDataBool = pairs[17][1] == 'True' + settings.solanaDescription = pairs[18][1] + settings.enableCustomFields = pairs[19][1] == 'True' + settings.customfieldsFile = pairs[20][1] + settings.enableMaterials = pairs[21][1] == 'True' + settings.materialsFile = pairs[22][1] if args.save_path: settings.save_path = args.save_path From a4e61c230f33434aad27a7889b81ad2b22cc53dd Mon Sep 17 00:00:00 2001 From: matt-159 Date: Mon, 27 Jun 2022 23:44:07 -0700 Subject: [PATCH 02/22] updated comment --- __init__.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/__init__.py b/__init__.py index 6fdc103..1470e72 100644 --- a/__init__.py +++ b/__init__.py @@ -24,7 +24,7 @@ import sys import json import importlib -# "a little hacky bs" - Matthew TheBrochacho ;) +# "a little hacky bs" - matt159 ;) sys.path.append(os.path.dirname(os.path.realpath(__file__))) from main import \ @@ -219,23 +219,38 @@ def runAsHeadless(): elif args.operation == 'generate-nfts': nftName = settings.nftName - save_path = bpy.path.abspath(settings.save_path) batchToGenerate = settings.batchToGenerate collectionSize = settings.collectionSize - Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path = make_directories(save_path) + _save_path = bpy.path.abspath(settings.save_path) if args.batch_data_path: batch_json_save_path = args.batch_data_path; enableImages = settings.imageBool imageFileFormat = settings.imageEnum - enableAnimations = settings.animationBool animationFileFormat = settings.animationEnum enableModelsBlender = settings.modelBool modelFileFormat = settings.modelEnum + batch_json_save_path = args.batch_data_path + save_path = _save_path, + batchToGenerate = bpy.context.scene.input_tool.batchToGenerate, + collectionSize = bpy.context.scene.input_tool.collectionSize, + Blend_My_NFTs_Output = _Blend_My_NFTs_Output, + batch_json_save_path = _batch_json_save_path, + nftBatch_save_path = _nftBatch_save_path, + + enableImages = bpy.context.scene.input_tool.imageBool, + + enableAnimations = bpy.context.scene.input_tool.animationBool, + animationFileFormat = bpy.context.scene.input_tool.animationEnum, + + enableModelsBlender = bpy.context.scene.input_tool.modelBool, + + enableCustomFields = bpy.context.scene.input_tool.enableCustomFields, + enableMaterials = settings.enableMaterials materialsFile = settings.materialsFile From 6993317e663fdd4fec42eb33e898792244db7638 Mon Sep 17 00:00:00 2001 From: matt-159 Date: Tue, 28 Jun 2022 12:36:47 -0700 Subject: [PATCH 03/22] added class for packaging data to functions --- __init__.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/__init__.py b/__init__.py index 1470e72..f7f507b 100644 --- a/__init__.py +++ b/__init__.py @@ -23,6 +23,8 @@ import os import sys import json import importlib +from dataclasses import dataclass +from typing import Any # "a little hacky bs" - matt159 ;) sys.path.append(os.path.dirname(os.path.realpath(__file__))) @@ -72,6 +74,49 @@ combinations: int = 0 recommended_limit: int = 0 +@dataclass +class RenderData: + nftName: str + save_path: str + batchToGenerate: int + collectionSize: int + + Blend_My_NFTs_Output: str + batch_json_save_path: str + nftBatch_save_path: str + + enableImages: bool + imageFileFormat: str + + enableAnimations: bool + animationFileFormat: str + + enableModelsBlender: bool + modelFileFormat: str + + enableCustomFields: bool + + cardanoMetaDataBool: bool + solanaMetaDataBool: bool + erc721MetaData: bool + + cardano_description: str + solana_description: str + erc721_description: str + + enableMaterials: bool + materialsFile: str + + custom_Fields: dict = None + fail_state: Any = False + failed_batch: Any = None + failed_dna: Any = None + failed_dna_index: Any = None + + def __post_init__(self): + self.custom_Fields = {} + + @persistent def Refresh_UI(dummy1, dummy2): """ From a6e0dce7076d383bc0a3a1e5c488b8c8004a519d Mon Sep 17 00:00:00 2001 From: matt-159 Date: Tue, 28 Jun 2022 12:39:57 -0700 Subject: [PATCH 04/22] replaced input class references with RenderData --- __init__.py | 168 ++++++++++++++++++++++++++-------------------------- 1 file changed, 85 insertions(+), 83 deletions(-) diff --git a/__init__.py b/__init__.py index f7f507b..1a46ec1 100644 --- a/__init__.py +++ b/__init__.py @@ -18,7 +18,7 @@ from bpy.app.handlers import persistent from bpy.props import (IntProperty, BoolProperty, CollectionProperty) - + import os import sys import json @@ -263,55 +263,47 @@ def runAsHeadless(): materialsFile, Blend_My_NFTs_Output, batch_json_save_path) elif args.operation == 'generate-nfts': - nftName = settings.nftName - batchToGenerate = settings.batchToGenerate - collectionSize = settings.collectionSize - Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path = make_directories(save_path) - _save_path = bpy.path.abspath(settings.save_path) + _Blend_My_NFTs_Output, _batch_json_save_path, _nftBatch_save_path = make_directories(_save_path) + if args.batch_data_path: - batch_json_save_path = args.batch_data_path; - - enableImages = settings.imageBool - imageFileFormat = settings.imageEnum - enableAnimations = settings.animationBool - animationFileFormat = settings.animationEnum - - enableModelsBlender = settings.modelBool - modelFileFormat = settings.modelEnum batch_json_save_path = args.batch_data_path + + input = RenderData ( + nftName = bpy.context.scene.input_tool.nftName, save_path = _save_path, batchToGenerate = bpy.context.scene.input_tool.batchToGenerate, collectionSize = bpy.context.scene.input_tool.collectionSize, + Blend_My_NFTs_Output = _Blend_My_NFTs_Output, batch_json_save_path = _batch_json_save_path, nftBatch_save_path = _nftBatch_save_path, enableImages = bpy.context.scene.input_tool.imageBool, + imageFileFormat = bpy.context.scene.input_tool.imageEnum, enableAnimations = bpy.context.scene.input_tool.animationBool, animationFileFormat = bpy.context.scene.input_tool.animationEnum, enableModelsBlender = bpy.context.scene.input_tool.modelBool, + modelFileFormat = bpy.context.scene.input_tool.modelEnum, enableCustomFields = bpy.context.scene.input_tool.enableCustomFields, + cardanoMetaDataBool = bpy.context.scene.input_tool.cardanoMetaDataBool, + solanaMetaDataBool = bpy.context.scene.input_tool.solanaMetaDataBool, + erc721MetaData = bpy.context.scene.input_tool.erc721MetaData, - enableMaterials = settings.enableMaterials - materialsFile = settings.materialsFile + cardano_description = bpy.context.scene.input_tool.cardano_description, + solana_description = bpy.context.scene.input_tool.solana_description, + erc721_description = bpy.context.scene.input_tool.erc721_description, - # fail state variables, set to no fail due to resume_failed_batch() Operator in BMNFTS_PT_GenerateNFTs Panel - fail_state = False - failed_batch = None - failed_dna = None - failed_dna_index = None + enableMaterials = bpy.context.scene.input_tool.enableMaterials, + materialsFile = bpy.path.abspath(bpy.context.scene.input_tool.materialsFile) + ) + + Exporter.render_and_save_NFTs(input) - Exporter.render_and_save_NFTs(nftName, collectionSize, batchToGenerate, batch_json_save_path, - nftBatch_save_path, enableImages, - imageFileFormat, enableAnimations, animationFileFormat, enableModelsBlender, - modelFileFormat, fail_state, failed_batch, failed_dna, failed_dna_index, - enableMaterials, materialsFile - ) elif args.operation == 'refactor-batches': class refactorData: save_path = bpy.path.abspath(settings.save_path) @@ -538,42 +530,41 @@ class exportNFTs(bpy.types.Operator): name="Reverse Order") def execute(self, context): - class input: - nftName = bpy.context.scene.input_tool.nftName - save_path = bpy.path.abspath(bpy.context.scene.input_tool.save_path) - batchToGenerate = bpy.context.scene.input_tool.batchToGenerate - collectionSize = bpy.context.scene.input_tool.collectionSize + _save_path = bpy.path.abspath(bpy.context.scene.input_tool.save_path) + _Blend_My_NFTs_Output, _batch_json_save_path, _nftBatch_save_path = make_directories(_save_path) - Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path = make_directories(save_path) + input = RenderData ( + nftName = bpy.context.scene.input_tool.nftName, + save_path = _save_path, + batchToGenerate = bpy.context.scene.input_tool.batchToGenerate, + collectionSize = bpy.context.scene.input_tool.collectionSize, - enableImages = bpy.context.scene.input_tool.imageBool - imageFileFormat = bpy.context.scene.input_tool.imageEnum + Blend_My_NFTs_Output = _Blend_My_NFTs_Output, + batch_json_save_path = _batch_json_save_path, + nftBatch_save_path = _nftBatch_save_path, - enableAnimations = bpy.context.scene.input_tool.animationBool - animationFileFormat = bpy.context.scene.input_tool.animationEnum + enableImages = bpy.context.scene.input_tool.imageBool, + imageFileFormat = bpy.context.scene.input_tool.imageEnum, - enableModelsBlender = bpy.context.scene.input_tool.modelBool - modelFileFormat = bpy.context.scene.input_tool.modelEnum + enableAnimations = bpy.context.scene.input_tool.animationBool, + animationFileFormat = bpy.context.scene.input_tool.animationEnum, - enableCustomFields = bpy.context.scene.input_tool.enableCustomFields - custom_Fields = {} + enableModelsBlender = bpy.context.scene.input_tool.modelBool, + modelFileFormat = bpy.context.scene.input_tool.modelEnum, + + enableCustomFields = bpy.context.scene.input_tool.enableCustomFields, + + cardanoMetaDataBool = bpy.context.scene.input_tool.cardanoMetaDataBool, + solanaMetaDataBool = bpy.context.scene.input_tool.solanaMetaDataBool, + erc721MetaData = bpy.context.scene.input_tool.erc721MetaData, - cardanoMetaDataBool = bpy.context.scene.input_tool.cardanoMetaDataBool - solanaMetaDataBool = bpy.context.scene.input_tool.solanaMetaDataBool - erc721MetaData = bpy.context.scene.input_tool.erc721MetaData + cardano_description = bpy.context.scene.input_tool.cardano_description, + solana_description = bpy.context.scene.input_tool.solana_description, + erc721_description = bpy.context.scene.input_tool.erc721_description, - cardano_description = bpy.context.scene.input_tool.cardano_description - solana_description = bpy.context.scene.input_tool.solana_description - erc721_description = bpy.context.scene.input_tool.erc721_description - - enableMaterials = bpy.context.scene.input_tool.enableMaterials - materialsFile = bpy.path.abspath(bpy.context.scene.input_tool.materialsFile) - - # fail state variables, set to no fail due to resume_failed_batch() Operator in BMNFTS_PT_GenerateNFTs Panel - fail_state = False - failed_batch = None - failed_dna = None - failed_dna_index = None + enableMaterials = bpy.context.scene.input_tool.enableMaterials, + materialsFile = bpy.path.abspath(bpy.context.scene.input_tool.materialsFile) + ) # Handling Custom Fields UIList input: if input.enableCustomFields: @@ -606,42 +597,53 @@ class resume_failed_batch(bpy.types.Operator): bl_options = {"REGISTER", "UNDO"} def execute(self, context): - class input: - save_path = bpy.path.abspath(bpy.context.scene.input_tool.save_path) - batchToGenerate = bpy.context.scene.input_tool.batchToGenerate + _save_path = bpy.path.abspath(bpy.context.scene.input_tool.save_path) + _Blend_My_NFTs_Output, _batch_json_save_path, _nftBatch_save_path = make_directories(_save_path) - Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path = make_directories(save_path) - file_name = os.path.join(batch_json_save_path, "Batch{}.json".format(batchToGenerate)) - batch = json.load(open(file_name)) + _batchToGenerate = bpy.context.scene.input_tool.batchToGenerate - nftName = batch["Generation Save"][-1]["Render_Settings"]["nftName"] - collectionSize = batch["Generation Save"][-1]["Render_Settings"]["collectionSize"] - nftBatch_save_path = batch["Generation Save"][-1]["Render_Settings"]["nftBatch_save_path"] + file_name = os.path.join(_batch_json_save_path, "Batch{}.json".format(_batchToGenerate)) + batchData = json.load(open(file_name)) - enableImages = batch["Generation Save"][-1]["Render_Settings"]["enableImages"] - imageFileFormat = batch["Generation Save"][-1]["Render_Settings"]["imageFileFormat"] + _fail_state, _failed_batch, _failed_dna, _failed_dna_index = Checks.check_FailedBatches(_batch_json_save_path) - enableAnimations = batch["Generation Save"][-1]["Render_Settings"]["enableAnimations"] - animationFileFormat = batch["Generation Save"][-1]["Render_Settings"]["animationFileFormat"] + input = RenderData ( + nftName = batchData["Generation Save"][-1]["Render_Settings"]["nftName"], + save_path = _save_path, + collectionSize = batchData["Generation Save"][-1]["Render_Settings"]["collectionSize"], - enableModelsBlender = batch["Generation Save"][-1]["Render_Settings"]["enableModelsBlender"] - modelFileFormat = batch["Generation Save"][-1]["Render_Settings"]["modelFileFormat"] + Blend_My_NFTs_Output = _Blend_My_NFTs_Output, + batch_json_save_path = _batch_json_save_path, + nftBatch_save_path = batchData["Generation Save"][-1]["Render_Settings"]["nftBatch_save_path"], - enableCustomFields = batch["Generation Save"][-1]["Render_Settings"]["enableCustomFields"] - custom_Fields = batch["Generation Save"][-1]["Render_Settings"]["custom_Fields"] + enableImages = batchData["Generation Save"][-1]["Render_Settings"]["enableImages"], + imageFileFormat = batchData["Generation Save"][-1]["Render_Settings"]["imageFileFormat"], - cardanoMetaDataBool = batch["Generation Save"][-1]["Render_Settings"]["cardanoMetaDataBool"] - solanaMetaDataBool = batch["Generation Save"][-1]["Render_Settings"]["solanaMetaDataBool"] - erc721MetaData = batch["Generation Save"][-1]["Render_Settings"]["erc721MetaData"] + enableAnimations = batchData["Generation Save"][-1]["Render_Settings"]["enableAnimations"], + animationFileFormat = batchData["Generation Save"][-1]["Render_Settings"]["animationFileFormat"], - cardano_description = batch["Generation Save"][-1]["Render_Settings"]["cardano_description"] - solana_description = batch["Generation Save"][-1]["Render_Settings"]["solana_description"] - erc721_description = batch["Generation Save"][-1]["Render_Settings"]["erc721_description"] + enableModelsBlender = batchData["Generation Save"][-1]["Render_Settings"]["enableModelsBlender"], + modelFileFormat = batchData["Generation Save"][-1]["Render_Settings"]["modelFileFormat"], - enableMaterials = batch["Generation Save"][-1]["Render_Settings"]["enableMaterials"] - materialsFile = batch["Generation Save"][-1]["Render_Settings"]["materialsFile"] + enableCustomFields = batchData["Generation Save"][-1]["Render_Settings"]["enableCustomFields"], + custom_Fields = batchData["Generation Save"][-1]["Render_Settings"]["custom_Fields"], - fail_state, failed_batch, failed_dna, failed_dna_index = Checks.check_FailedBatches(batch_json_save_path) + cardanoMetaDataBool = batchData["Generation Save"][-1]["Render_Settings"]["cardanoMetaDataBool"], + solanaMetaDataBool = batchData["Generation Save"][-1]["Render_Settings"]["solanaMetaDataBool"], + erc721MetaData = batchData["Generation Save"][-1]["Render_Settings"]["erc721MetaData"], + + cardano_description = batchData["Generation Save"][-1]["Render_Settings"]["cardano_description"], + solana_description = batchData["Generation Save"][-1]["Render_Settings"]["solana_description"], + erc721_description = batchData["Generation Save"][-1]["Render_Settings"]["erc721_description"], + + enableMaterials = batchData["Generation Save"][-1]["Render_Settings"]["enableMaterials"], + materialsFile = batchData["Generation Save"][-1]["Render_Settings"]["materialsFile"], + + fail_state = _fail_state, + failed_batch = _failed_batch, + failed_dna = _failed_dna, + failed_dna_index = _failed_dna_index + ) Exporter.render_and_save_NFTs(input) From b447031cc84be1491c917250d11a38e275119f83 Mon Sep 17 00:00:00 2001 From: matt-159 Date: Tue, 28 Jun 2022 13:50:51 -0700 Subject: [PATCH 05/22] improved readability --- __init__.py | 76 ++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/__init__.py b/__init__.py index 1a46ec1..05d2a9f 100644 --- a/__init__.py +++ b/__init__.py @@ -18,7 +18,7 @@ from bpy.app.handlers import persistent from bpy.props import (IntProperty, BoolProperty, CollectionProperty) - + import os import sys import json @@ -245,17 +245,17 @@ def runAsHeadless(): # don't mind me, just copy-pasting code around... if args.operation == 'create-dna': - nftName = settings.nftName - collectionSize = settings.collectionSize - nftsPerBatch = settings.nftsPerBatch - save_path = bpy.path.abspath(settings.save_path) - logicFile = bpy.path.abspath(settings.logicFile) + nftName = settings.nftName + collectionSize = settings.collectionSize + nftsPerBatch = settings.nftsPerBatch + save_path = bpy.path.abspath(settings.save_path) + logicFile = bpy.path.abspath(settings.logicFile) - enableRarity = settings.enableRarity - enableLogic = settings.enableLogic + enableRarity = settings.enableRarity + enableLogic = settings.enableLogic - enableMaterials = settings.enableMaterials - materialsFile = settings.materialsFile + enableMaterials = settings.enableMaterials + materialsFile = settings.materialsFile Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path = make_directories(save_path) @@ -306,18 +306,18 @@ def runAsHeadless(): elif args.operation == 'refactor-batches': class refactorData: - save_path = bpy.path.abspath(settings.save_path) + save_path = bpy.path.abspath(settings.save_path) - custom_Fields_File = bpy.path.abspath(settings.customfieldsFile) - enableCustomFields = settings.enableCustomFields + custom_Fields_File = bpy.path.abspath(settings.customfieldsFile) + enableCustomFields = settings.enableCustomFields - cardanoMetaDataBool = settings.cardanoMetaDataBool - solanaMetaDataBool = settings.solanaMetaDataBool - erc721MetaData = settings.erc721MetaData + cardanoMetaDataBool = settings.cardanoMetaDataBool + solanaMetaDataBool = settings.solanaMetaDataBool + erc721MetaData = settings.erc721MetaData - cardano_description = settings.cardano_description - solana_description = settings.solana_description - erc721_description = settings.erc721_description + cardano_description = settings.cardano_description + solana_description = settings.solana_description + erc721_description = settings.erc721_description Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path = make_directories(save_path) @@ -445,19 +445,19 @@ class createData(bpy.types.Operator): name="Reverse Order") def execute(self, context): - nftName = bpy.context.scene.input_tool.nftName - collectionSize = bpy.context.scene.input_tool.collectionSize - nftsPerBatch = bpy.context.scene.input_tool.nftsPerBatch - save_path = bpy.path.abspath(bpy.context.scene.input_tool.save_path) + nftName = bpy.context.scene.input_tool.nftName + collectionSize = bpy.context.scene.input_tool.collectionSize + nftsPerBatch = bpy.context.scene.input_tool.nftsPerBatch + save_path = bpy.path.abspath(bpy.context.scene.input_tool.save_path) - enableRarity = bpy.context.scene.input_tool.enableRarity + enableRarity = bpy.context.scene.input_tool.enableRarity - enableLogic = bpy.context.scene.input_tool.enableLogic - enable_Logic_Json = bpy.context.scene.input_tool.enable_Logic_Json - logicFile = bpy.path.abspath(bpy.context.scene.input_tool.logicFile) + enableLogic = bpy.context.scene.input_tool.enableLogic + enable_Logic_Json = bpy.context.scene.input_tool.enable_Logic_Json + logicFile = bpy.path.abspath(bpy.context.scene.input_tool.logicFile) - enableMaterials = bpy.context.scene.input_tool.enableMaterials - materialsFile = bpy.path.abspath(bpy.context.scene.input_tool.materialsFile) + enableMaterials = bpy.context.scene.input_tool.enableMaterials + materialsFile = bpy.path.abspath(bpy.context.scene.input_tool.materialsFile) # Handling Custom Fields UIList input: if enableLogic: @@ -666,18 +666,18 @@ class refactor_Batches(bpy.types.Operator): def execute(self, context): class input: - save_path = bpy.path.abspath(bpy.context.scene.input_tool.save_path) + save_path = bpy.path.abspath(bpy.context.scene.input_tool.save_path) - enableCustomFields = bpy.context.scene.input_tool.enableCustomFields - custom_Fields = {} + enableCustomFields = bpy.context.scene.input_tool.enableCustomFields + custom_Fields = {} - cardanoMetaDataBool = bpy.context.scene.input_tool.cardanoMetaDataBool - solanaMetaDataBool = bpy.context.scene.input_tool.solanaMetaDataBool - erc721MetaData = bpy.context.scene.input_tool.erc721MetaData + cardanoMetaDataBool = bpy.context.scene.input_tool.cardanoMetaDataBool + solanaMetaDataBool = bpy.context.scene.input_tool.solanaMetaDataBool + erc721MetaData = bpy.context.scene.input_tool.erc721MetaData - cardano_description = bpy.context.scene.input_tool.cardano_description - solana_description = bpy.context.scene.input_tool.solana_description - erc721_description = bpy.context.scene.input_tool.erc721_description + cardano_description = bpy.context.scene.input_tool.cardano_description + solana_description = bpy.context.scene.input_tool.solana_description + erc721_description = bpy.context.scene.input_tool.erc721_description Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path = make_directories(save_path) From 55201aaa3c9984d371891899a3129dc578ae4e96 Mon Sep 17 00:00:00 2001 From: matt-159 Date: Wed, 29 Jun 2022 14:59:31 -0700 Subject: [PATCH 06/22] force GPU usage with cycles renderer --- __init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/__init__.py b/__init__.py index 05d2a9f..d5897f8 100644 --- a/__init__.py +++ b/__init__.py @@ -169,6 +169,17 @@ def runAsHeadless(): """ For use when running from the command line. """ + + # force CUDA device usage with cycles renderer + cprefs = bpy.context.preferences.addons['cycles'].preferences + cprefs.compute_device_type = 'CUDA' + cprefs.get_devices() + print(cprefs.devices.keys()) + + for key in cprefs.devices.keys(): + cprefs.devices[key].use = True + + print('Using {} devices for rendering!'.format(cprefs.get_num_gpu_devices())) def dumpSettings(settings): output = ( From 20221f42481141ec91b056bba78a46ca4a293f4a Mon Sep 17 00:00:00 2001 From: matt-159 Date: Thu, 30 Jun 2022 17:09:20 -0700 Subject: [PATCH 07/22] added logic fields to RenderData class --- __init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/__init__.py b/__init__.py index d5897f8..65183b7 100644 --- a/__init__.py +++ b/__init__.py @@ -107,6 +107,10 @@ class RenderData: enableMaterials: bool materialsFile: str + enableLogic: bool + enableLogicJson: bool + logicFilePath: str + custom_Fields: dict = None fail_state: Any = False failed_batch: Any = None From 5113edd2c6516cdc6513bb6683b2d3ef4ebe30a8 Mon Sep 17 00:00:00 2001 From: matt-159 Date: Thu, 30 Jun 2022 17:12:34 -0700 Subject: [PATCH 08/22] improved readability --- __init__.py | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/__init__.py b/__init__.py index 65183b7..626bee8 100644 --- a/__init__.py +++ b/__init__.py @@ -187,29 +187,29 @@ def runAsHeadless(): def dumpSettings(settings): output = ( - f"nftName={settings.nftName}\n" - f"collectionSize={str(settings.collectionSize)}\n" - f"nftsPerBatch={str(settings.nftsPerBatch)}\n" - f"save_path={settings.save_path}\n" - f"enableRarity={(settings.enableRarity)}\n" - f"enableLogic={str(settings.enableLogic)}\n" - f"imageBool={str(settings.imageBool)}\n" - f"imageEnum={settings.imageEnum}\n" - f"animationBool={str(settings.animationBool)}\n" - f"animationEnum={settings.animationEnum}\n" - f"modelBool={str(settings.modelBool)}\n" - f"modelEnum={settings.modelEnum}\n" - f"batchToGenerate={str(settings.batchToGenerate)}\n" - f"cardanoMetaDataBool={str(settings.cardanoMetaDataBool)}\n" - f"cardano_description={settings.cardano_description}\n" - f"erc721MetaData={str(settings.erc721MetaData)}\n" - f"erc721_description={settings.erc721_description}\n" - f"solanaMetaDataBool={str(settings.solanaMetaDataBool)}\n" - f"solana_description={settings.solana_description}\n" - f"enableCustomFields={str(settings.enableCustomFields)}\n" - f"customfieldsFile={settings.customfieldsFile}\n" - f"enableMaterials={str(settings.customfieldsFile)}\n" - f"materialsFile={settings.materialsFile}\n" + f"nftName={ settings.nftName }\n" + f"collectionSize={ str(settings.collectionSize) }\n" + f"nftsPerBatch={ str(settings.nftsPerBatch) }\n" + f"save_path={ settings.save_path }\n" + f"enableRarity={ (settings.enableRarity) }\n" + f"enableLogic={ str(settings.enableLogic) }\n" + f"imageBool={ str(settings.imageBool) }\n" + f"imageEnum={ settings.imageEnum }\n" + f"animationBool={ str(settings.animationBool) }\n" + f"animationEnum={ settings.animationEnum }\n" + f"modelBool={ str(settings.modelBool) }\n" + f"modelEnum={ settings.modelEnum }\n" + f"batchToGenerate={ str(settings.batchToGenerate) }\n" + f"cardanoMetaDataBool={ str(settings.cardanoMetaDataBool) }\n" + f"cardano_description={ settings.cardano_description }\n" + f"erc721MetaData={ str(settings.erc721MetaData) }\n" + f"erc721_description={ settings.erc721_description }\n" + f"solanaMetaDataBool={ str(settings.solanaMetaDataBool) }\n" + f"solana_description={ settings.solana_description }\n" + f"enableCustomFields={ str(settings.enableCustomFields) }\n" + f"customfieldsFile={ settings.customfieldsFile }\n" + f"enableMaterials={ str(settings.customfieldsFile) }\n" + f"materialsFile={ settings.materialsFile }\n" ) print(output) From 926422463ba32183c08c5bb9f14b4562d163bfe1 Mon Sep 17 00:00:00 2001 From: matt-159 Date: Thu, 30 Jun 2022 18:09:51 -0700 Subject: [PATCH 09/22] Simplified CreateData.execute() --- __init__.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/__init__.py b/__init__.py index 626bee8..0c43878 100644 --- a/__init__.py +++ b/__init__.py @@ -474,15 +474,13 @@ class createData(bpy.types.Operator): enableMaterials = bpy.context.scene.input_tool.enableMaterials materialsFile = bpy.path.abspath(bpy.context.scene.input_tool.materialsFile) + Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path = make_directories(save_path) + # Handling Custom Fields UIList input: if enableLogic: if enable_Logic_Json and logicFile: logicFile = json.load(open(logicFile)) - Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path = make_directories(save_path) - DNA_Generator.send_To_Record_JSON(collectionSize, nftsPerBatch, save_path, enableRarity, enableLogic, logicFile, enableMaterials, - materialsFile, Blend_My_NFTs_Output, batch_json_save_path) - if enable_Logic_Json and not logicFile: self.report({'ERROR'}, f"No Logic.json file path set. Please set the file path to your Logic.json file.") @@ -503,9 +501,6 @@ class createData(bpy.types.Operator): "Items-2": item_list2.split(',') } num += 1 - Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path = make_directories(save_path) - DNA_Generator.send_To_Record_JSON(collectionSize, nftsPerBatch, save_path, enableRarity, enableLogic, logicFile, enableMaterials, - materialsFile, Blend_My_NFTs_Output, batch_json_save_path) else: logicFile = {} num = 1 @@ -519,14 +514,10 @@ class createData(bpy.types.Operator): "Items-2": item_list2.split(',') } num += 1 - Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path = make_directories(save_path) - DNA_Generator.send_To_Record_JSON(collectionSize, nftsPerBatch, save_path, enableRarity, enableLogic, logicFile, enableMaterials, - materialsFile, Blend_My_NFTs_Output, batch_json_save_path) - if not enableLogic: - Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path = make_directories(save_path) - DNA_Generator.send_To_Record_JSON(collectionSize, nftsPerBatch, save_path, enableRarity, enableLogic, logicFile, enableMaterials, + DNA_Generator.send_To_Record_JSON(collectionSize, nftsPerBatch, save_path, enableRarity, enableLogic, logicFile, enableMaterials, materialsFile, Blend_My_NFTs_Output, batch_json_save_path) + self.report({'INFO'}, f"NFT Data created!") return {"FINISHED"} From e46dc8a07d221b2490bfaa933f379923daa300a1 Mon Sep 17 00:00:00 2001 From: matt-159 Date: Thu, 30 Jun 2022 20:32:14 -0700 Subject: [PATCH 10/22] Rename RenderData class to BMNFTData --- __init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/__init__.py b/__init__.py index 0c43878..016ec86 100644 --- a/__init__.py +++ b/__init__.py @@ -75,7 +75,7 @@ recommended_limit: int = 0 @dataclass -class RenderData: +class BMNFTData: nftName: str save_path: str batchToGenerate: int @@ -284,7 +284,7 @@ def runAsHeadless(): if args.batch_data_path: batch_json_save_path = args.batch_data_path - input = RenderData ( + input = BMNFTData ( nftName = bpy.context.scene.input_tool.nftName, save_path = _save_path, batchToGenerate = bpy.context.scene.input_tool.batchToGenerate, @@ -539,7 +539,7 @@ class exportNFTs(bpy.types.Operator): _save_path = bpy.path.abspath(bpy.context.scene.input_tool.save_path) _Blend_My_NFTs_Output, _batch_json_save_path, _nftBatch_save_path = make_directories(_save_path) - input = RenderData ( + input = BMNFTData ( nftName = bpy.context.scene.input_tool.nftName, save_path = _save_path, batchToGenerate = bpy.context.scene.input_tool.batchToGenerate, @@ -613,7 +613,7 @@ class resume_failed_batch(bpy.types.Operator): _fail_state, _failed_batch, _failed_dna, _failed_dna_index = Checks.check_FailedBatches(_batch_json_save_path) - input = RenderData ( + input = BMNFTData ( nftName = batchData["Generation Save"][-1]["Render_Settings"]["nftName"], save_path = _save_path, collectionSize = batchData["Generation Save"][-1]["Render_Settings"]["collectionSize"], From 4bdfa394ccbb0fbccca81a7c71ff0b46b06745f6 Mon Sep 17 00:00:00 2001 From: matt-159 Date: Thu, 30 Jun 2022 21:01:43 -0700 Subject: [PATCH 11/22] added logic file settings to config file --- __init__.py | 84 ++++++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/__init__.py b/__init__.py index 016ec86..1167d60 100644 --- a/__init__.py +++ b/__init__.py @@ -232,23 +232,25 @@ def runAsHeadless(): settings.save_path = pairs[3][1] settings.enableRarity = pairs[4][1] == 'True' settings.enableLogic = pairs[5][1] == 'True' - settings.imageBool = pairs[6][1] == 'True' - settings.imageEnum = pairs[7][1] - settings.animationBool = pairs[8][1] == 'True' - settings.animationEnum = pairs[9][1] - settings.modelBool = pairs[10][1] == 'True' - settings.modelEnum = pairs[11][1] - settings.batchToGenerate = int(pairs[12][1]) - settings.cardanoMetaDataBool = pairs[13][1] == 'True' - settings.cardano_description = pairs[14][1] - settings.erc721MetaData = pairs[15][1] == 'True' - settings.erc721_description = pairs[16][1] - settings.solanaMetaDataBool = pairs[17][1] == 'True' - settings.solanaDescription = pairs[18][1] - settings.enableCustomFields = pairs[19][1] == 'True' - settings.customfieldsFile = pairs[20][1] - settings.enableMaterials = pairs[21][1] == 'True' - settings.materialsFile = pairs[22][1] + settings.enableLogicJson = pairs[6][1] == 'True' + settings.logicFile = pairs[7][1] + settings.imageBool = pairs[8][1] == 'True' + settings.imageEnum = pairs[9][1] + settings.animationBool = pairs[10][1] == 'True' + settings.animationEnum = pairs[11][1] + settings.modelBool = pairs[12][1] == 'True' + settings.modelEnum = pairs[13][1] + settings.batchToGenerate = int(pairs[14][1]) + settings.cardanoMetaDataBool = pairs[15][1] == 'True' + settings.cardano_description = pairs[16][1] + settings.erc721MetaData = pairs[17][1] == 'True' + settings.erc721_description = pairs[18][1] + settings.solanaMetaDataBool = pairs[19][1] == 'True' + settings.solanaDescription = pairs[20][1] + settings.enableCustomFields = pairs[21][1] == 'True' + settings.customfieldsFile = pairs[22][1] + settings.enableMaterials = pairs[23][1] == 'True' + settings.materialsFile = pairs[24][1] if args.save_path: settings.save_path = args.save_path @@ -714,49 +716,51 @@ class export_settings(bpy.types.Operator): "#when running Blend_My_NFTs in a headless environment.\n" "\n" "#The name of your nft project\n" - f"nftName={settings.nftName}\n" + f"nftName={ settings.nftName }\n" "\n" "#NFT Collection Size\n" - f"collectionSize={settings.collectionSize}\n" + f"collectionSize={ settings.collectionSize }\n" "\n" "#The number of NFTs to generate per batch\n" - f"nftsPerBatch={str(settings.nftsPerBatch)}\n" + f"nftsPerBatch={ str(settings.nftsPerBatch) }\n" "\n" "#Save path for your NFT files\n" - f"save_path={settings.save_path}\n" + f"save_path={ settings.save_path }\n" "\n" "#Enable Rarity\n" - f"enableRarity={(settings.enableRarity)}\n" + f"enableRarity={ (settings.enableRarity) }\n" "\n" "#Enable Logic\n" - f"enableLogic={str(settings.enableLogic)}\n" + f"enableLogic={ str(settings.enableLogic) }\n" + f"enableLogicJson={ str(settings.enableLogicJson) }\n" + f"logicFilePath={ settings.logicFile }\n" "\n" "#NFT Media output type(s):\n" - f"imageBool={str(settings.imageBool)}\n" - f"imageEnum={settings.imageEnum}\n" - f"animationBool={str(settings.animationBool)}\n" - f"animationEnum={settings.animationEnum}\n" - f"modelBool={str(settings.modelBool)}\n" - f"modelEnum={settings.modelEnum}\n" + f"imageBool={ str(settings.imageBool) }\n" + f"imageEnum={ settings.imageEnum }\n" + f"animationBool={ str(settings.animationBool) }\n" + f"animationEnum={ settings.animationEnum }\n" + f"modelBool={ str(settings.modelBool) }\n" + f"modelEnum={ settings.modelEnum }\n" "\n" "#Batch to generate\n" - f"batchToGenerate={str(settings.batchToGenerate)}\n" + f"batchToGenerate={ str(settings.batchToGenerate) }\n" "\n" "#Metadata Format\n" - f"cardanoMetaDataBool={str(settings.cardanoMetaDataBool)}\n" - f"cardano_description={settings.cardano_description}\n" - f"erc721MetaData={str(settings.erc721MetaData)}\n" - f"erc721_description={settings.erc721_description}\n" - f"solanaMetaDataBool={str(settings.solanaMetaDataBool)}\n" - f"solana_description={settings.solana_description}\n" + f"cardanoMetaDataBool={ str(settings.cardanoMetaDataBool) }\n" + f"cardano_description={ settings.cardano_description }\n" + f"erc721MetaData={ str(settings.erc721MetaData) }\n" + f"erc721_description={ settings.erc721_description }\n" + f"solanaMetaDataBool={ str(settings.solanaMetaDataBool) }\n" + f"solana_description={ settings.solana_description }\n" "\n" "#Enable Custom Fields\n" - f"enableCustomFields={str(settings.enableCustomFields)}\n" - f"customfieldsFile={settings.customfieldsFile}\n" + f"enableCustomFields={ str(settings.enableCustomFields) }\n" + f"customfieldsFile={ settings.customfieldsFile }\n" "\n" "#Enable Materials\n" - f"enableMaterials={str(settings.enableMaterials)}\n" - f"materialsFile={settings.materialsFile}\n" + f"enableMaterials={ str(settings.enableMaterials) }\n" + f"materialsFile={ settings.materialsFile }\n" ) print(output, file=config) From 09bcceb209e4fd86bab14a049a2d8fcab280caa2 Mon Sep 17 00:00:00 2001 From: matt-159 Date: Thu, 30 Jun 2022 21:03:39 -0700 Subject: [PATCH 12/22] added logic file argument --- main/HeadlessUtil.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main/HeadlessUtil.py b/main/HeadlessUtil.py index e9e10d2..6b09303 100644 --- a/main/HeadlessUtil.py +++ b/main/HeadlessUtil.py @@ -56,5 +56,12 @@ def getPythonArgs(): required=False, help="Use pre-existing batch data for rendering" ) + + parser.add_argument("--logic-file", + dest="logic_file", + metavar='FILE', + required=False, + help="Overwrite the logic file path in the config file" + ) return (parser.parse_args(argv), parser) \ No newline at end of file From 50c5d09da70c1ceb69da86f5e16a56dcc2df851d Mon Sep 17 00:00:00 2001 From: matt-159 Date: Thu, 30 Jun 2022 21:36:07 -0700 Subject: [PATCH 13/22] Added intermediary function wrapper --- main/Intermediate.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 main/Intermediate.py diff --git a/main/Intermediate.py b/main/Intermediate.py new file mode 100644 index 0000000..39b4f92 --- /dev/null +++ b/main/Intermediate.py @@ -0,0 +1,15 @@ +from main import DNA_Generator + +def send_To_Record_JSON(input): + + DNA_Generator.send_To_Record_JSON( input.collectionSize, + input.nftsPerBatch, + input.save_path, + input.enableRarity, + input.enableLogic, + input.logicFile, + input.enableMaterials, + input.materialsFile, + input.Blend_My_NFTs_Output, + input.batch_json_save_path + ) \ No newline at end of file From 1dbbe96f453843eb44314a335cca7e9a4627db51 Mon Sep 17 00:00:00 2001 From: matt-159 Date: Thu, 30 Jun 2022 21:44:15 -0700 Subject: [PATCH 14/22] Removed duplicated code --- __init__.py | 115 +++++++++++++++++++--------------------------------- 1 file changed, 42 insertions(+), 73 deletions(-) diff --git a/__init__.py b/__init__.py index 1167d60..eaa353c 100644 --- a/__init__.py +++ b/__init__.py @@ -35,6 +35,7 @@ from main import \ Exporter, \ get_combinations, \ HeadlessUtil, \ + Intermediate, \ loading_animation, \ Logic, \ Material_Generator, \ @@ -255,90 +256,58 @@ def runAsHeadless(): if args.save_path: settings.save_path = args.save_path + _save_path = bpy.path.abspath(settings.save_path) + _Blend_My_NFTs_Output, _batch_json_save_path, _nftBatch_save_path = make_directories(_save_path) + if args.batch_number: settings.batchToGenerate = args.batch_number - # dumpSettings(settings) + if args.batch_data_path: + _batch_json_save_path = args.batch_data_path + + + input = BMNFTData ( + nftName = bpy.context.scene.input_tool.nftName, + save_path = _save_path, + batchToGenerate = bpy.context.scene.input_tool.batchToGenerate, + collectionSize = bpy.context.scene.input_tool.collectionSize, + + Blend_My_NFTs_Output = _Blend_My_NFTs_Output, + batch_json_save_path = _batch_json_save_path, + nftBatch_save_path = _nftBatch_save_path, + + enableImages = bpy.context.scene.input_tool.imageBool, + imageFileFormat = bpy.context.scene.input_tool.imageEnum, + + enableAnimations = bpy.context.scene.input_tool.animationBool, + animationFileFormat = bpy.context.scene.input_tool.animationEnum, + + enableModelsBlender = bpy.context.scene.input_tool.modelBool, + modelFileFormat = bpy.context.scene.input_tool.modelEnum, + + enableCustomFields = bpy.context.scene.input_tool.enableCustomFields, + + cardanoMetaDataBool = bpy.context.scene.input_tool.cardanoMetaDataBool, + solanaMetaDataBool = bpy.context.scene.input_tool.solanaMetaDataBool, + erc721MetaData = bpy.context.scene.input_tool.erc721MetaData, + + cardano_description = bpy.context.scene.input_tool.cardano_description, + solana_description = bpy.context.scene.input_tool.solana_description, + erc721_description = bpy.context.scene.input_tool.erc721_description, + + enableMaterials = bpy.context.scene.input_tool.enableMaterials, + materialsFile = bpy.path.abspath(bpy.context.scene.input_tool.materialsFile) + ) # don't mind me, just copy-pasting code around... if args.operation == 'create-dna': - nftName = settings.nftName - collectionSize = settings.collectionSize - nftsPerBatch = settings.nftsPerBatch - save_path = bpy.path.abspath(settings.save_path) - logicFile = bpy.path.abspath(settings.logicFile) - - enableRarity = settings.enableRarity - enableLogic = settings.enableLogic - - enableMaterials = settings.enableMaterials - materialsFile = settings.materialsFile - - Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path = make_directories(save_path) - - DNA_Generator.send_To_Record_JSON(collectionSize, nftsPerBatch, save_path, enableRarity, enableLogic, logicFile, enableMaterials, - materialsFile, Blend_My_NFTs_Output, batch_json_save_path) + Intermediate.send_To_Record_JSON(input) elif args.operation == 'generate-nfts': - _save_path = bpy.path.abspath(settings.save_path) - _Blend_My_NFTs_Output, _batch_json_save_path, _nftBatch_save_path = make_directories(_save_path) - - if args.batch_data_path: - batch_json_save_path = args.batch_data_path - - input = BMNFTData ( - nftName = bpy.context.scene.input_tool.nftName, - save_path = _save_path, - batchToGenerate = bpy.context.scene.input_tool.batchToGenerate, - collectionSize = bpy.context.scene.input_tool.collectionSize, - - Blend_My_NFTs_Output = _Blend_My_NFTs_Output, - batch_json_save_path = _batch_json_save_path, - nftBatch_save_path = _nftBatch_save_path, - - enableImages = bpy.context.scene.input_tool.imageBool, - imageFileFormat = bpy.context.scene.input_tool.imageEnum, - - enableAnimations = bpy.context.scene.input_tool.animationBool, - animationFileFormat = bpy.context.scene.input_tool.animationEnum, - - enableModelsBlender = bpy.context.scene.input_tool.modelBool, - modelFileFormat = bpy.context.scene.input_tool.modelEnum, - - enableCustomFields = bpy.context.scene.input_tool.enableCustomFields, - - cardanoMetaDataBool = bpy.context.scene.input_tool.cardanoMetaDataBool, - solanaMetaDataBool = bpy.context.scene.input_tool.solanaMetaDataBool, - erc721MetaData = bpy.context.scene.input_tool.erc721MetaData, - - cardano_description = bpy.context.scene.input_tool.cardano_description, - solana_description = bpy.context.scene.input_tool.solana_description, - erc721_description = bpy.context.scene.input_tool.erc721_description, - - enableMaterials = bpy.context.scene.input_tool.enableMaterials, - materialsFile = bpy.path.abspath(bpy.context.scene.input_tool.materialsFile) - ) - Exporter.render_and_save_NFTs(input) elif args.operation == 'refactor-batches': - class refactorData: - save_path = bpy.path.abspath(settings.save_path) - - custom_Fields_File = bpy.path.abspath(settings.customfieldsFile) - enableCustomFields = settings.enableCustomFields - - cardanoMetaDataBool = settings.cardanoMetaDataBool - solanaMetaDataBool = settings.solanaMetaDataBool - erc721MetaData = settings.erc721MetaData - - cardano_description = settings.cardano_description - solana_description = settings.solana_description - erc721_description = settings.erc721_description - - Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path = make_directories(save_path) - - Refactorer.reformatNFTCollection(refactorData) + Refactorer.reformatNFTCollection(input) # ======== User input Property Group ======== # From 5abbb525a41319eccae19df8e249f72cfecb7038 Mon Sep 17 00:00:00 2001 From: matt-159 Date: Thu, 30 Jun 2022 22:14:22 -0700 Subject: [PATCH 15/22] improved readability --- main/Exporter.py | 64 ++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/main/Exporter.py b/main/Exporter.py index 4e8eb1e..51f86fe 100644 --- a/main/Exporter.py +++ b/main/Exporter.py @@ -41,37 +41,37 @@ def save_generation_state(input): "Generation Start Date and Time": [CURRENT_TIME, CURRENT_DATE, LOCAL_TIMEZONE], "Render_Settings": { - "nftName": input.nftName, - "save_path": input.save_path, - "batchToGenerate": input.batchToGenerate, - "collectionSize": input.collectionSize, + "nftName": input.nftName, + "save_path": input.save_path, + "batchToGenerate": input.batchToGenerate, + "collectionSize": input.collectionSize, "Blend_My_NFTs_Output": input.Blend_My_NFTs_Output, "batch_json_save_path": input.batch_json_save_path, - "nftBatch_save_path": input.nftBatch_save_path, + "nftBatch_save_path": input.nftBatch_save_path, - "enableImages": input.enableImages, - "imageFileFormat": input.imageFileFormat, + "enableImages": input.enableImages, + "imageFileFormat": input.imageFileFormat, - "enableAnimations": input.enableAnimations, - "animationFileFormat": input.animationFileFormat, + "enableAnimations": input.enableAnimations, + "animationFileFormat": input.animationFileFormat, - "enableModelsBlender": input.enableModelsBlender, - "modelFileFormat": input.modelFileFormat, + "enableModelsBlender": input.enableModelsBlender, + "modelFileFormat": input.modelFileFormat, - "enableCustomFields": input.enableCustomFields, - "custom_Fields": input.custom_Fields, + "enableCustomFields": input.enableCustomFields, + "custom_Fields": input.custom_Fields, - "cardanoMetaDataBool": input.cardanoMetaDataBool, - "solanaMetaDataBool": input.solanaMetaDataBool, - "erc721MetaData": input.erc721MetaData, + "cardanoMetaDataBool": input.cardanoMetaDataBool, + "solanaMetaDataBool": input.solanaMetaDataBool, + "erc721MetaData": input.erc721MetaData, - "cardano_description": input.cardano_description, - "solana_description": input.solana_description, - "erc721_description": input.erc721_description, + "cardano_description": input.cardano_description, + "solana_description": input.solana_description, + "erc721_description": input.erc721_description, - "enableMaterials": input.enableMaterials, - "materialsFile": input.materialsFile, + "enableMaterials": input.enableMaterials, + "materialsFile": input.materialsFile, }, }) @@ -250,20 +250,20 @@ def render_and_save_NFTs(input): time_start_2 = time.time() # Main paths for batch subfolders: - batchFolder = os.path.join(input.nftBatch_save_path, "Batch" + str(input.batchToGenerate)) + batchFolder = os.path.join(input.nftBatch_save_path, "Batch" + str(input.batchToGenerate)) - imageFolder = os.path.join(batchFolder, "Images") - animationFolder = os.path.join(batchFolder, "Animations") - modelFolder = os.path.join(batchFolder, "Models") - BMNFT_metaData_Folder = os.path.join(batchFolder, "BMNFT_metadata") + imageFolder = os.path.join(batchFolder, "Images") + animationFolder = os.path.join(batchFolder, "Animations") + modelFolder = os.path.join(batchFolder, "Models") + BMNFT_metaData_Folder = os.path.join(batchFolder, "BMNFT_metadata") - imagePath = os.path.join(imageFolder, name) - animationPath = os.path.join(animationFolder, name) - modelPath = os.path.join(modelFolder, name) + imagePath = os.path.join(imageFolder, name) + animationPath = os.path.join(animationFolder, name) + modelPath = os.path.join(modelFolder, name) - cardanoMetadataPath = os.path.join(batchFolder, "Cardano_metadata") - solanaMetadataPath = os.path.join(batchFolder, "Solana_metadata") - erc721MetadataPath = os.path.join(batchFolder, "Erc721_metadata") + cardanoMetadataPath = os.path.join(batchFolder, "Cardano_metadata") + solanaMetadataPath = os.path.join(batchFolder, "Solana_metadata") + erc721MetadataPath = os.path.join(batchFolder, "Erc721_metadata") # Generation/Rendering: if input.enableImages: From 684069432877642af8277e4672b9e91462e422d0 Mon Sep 17 00:00:00 2001 From: matt-159 Date: Thu, 14 Jul 2022 05:35:48 -0700 Subject: [PATCH 16/22] Added needed fields to BMNFTData --- __init__.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/__init__.py b/__init__.py index eaa353c..40e712f 100644 --- a/__init__.py +++ b/__init__.py @@ -79,6 +79,7 @@ recommended_limit: int = 0 class BMNFTData: nftName: str save_path: str + nftsPerBatch: int batchToGenerate: int collectionSize: int @@ -110,7 +111,9 @@ class BMNFTData: enableLogic: bool enableLogicJson: bool - logicFilePath: str + logicFile: str + + enableRarity: bool custom_Fields: dict = None fail_state: Any = False @@ -269,13 +272,20 @@ def runAsHeadless(): input = BMNFTData ( nftName = bpy.context.scene.input_tool.nftName, save_path = _save_path, + nftsPerBatch = bpy.context.scene.input_tool.nftsPerBatch, batchToGenerate = bpy.context.scene.input_tool.batchToGenerate, collectionSize = bpy.context.scene.input_tool.collectionSize, + enableRarity = bpy.context.scene.input_tool.enableRarity, + Blend_My_NFTs_Output = _Blend_My_NFTs_Output, batch_json_save_path = _batch_json_save_path, nftBatch_save_path = _nftBatch_save_path, + enableLogic = bpy.context.scene.input_tool.enableLogic, + enableLogicJson = bpy.context.scene.input_tool.enable_Logic_Json, + logicFile = bpy.context.scene.input_tool.logicFile, + enableImages = bpy.context.scene.input_tool.imageBool, imageFileFormat = bpy.context.scene.input_tool.imageEnum, @@ -284,7 +294,7 @@ def runAsHeadless(): enableModelsBlender = bpy.context.scene.input_tool.modelBool, modelFileFormat = bpy.context.scene.input_tool.modelEnum, - + enableCustomFields = bpy.context.scene.input_tool.enableCustomFields, cardanoMetaDataBool = bpy.context.scene.input_tool.cardanoMetaDataBool, @@ -299,6 +309,7 @@ def runAsHeadless(): materialsFile = bpy.path.abspath(bpy.context.scene.input_tool.materialsFile) ) + # don't mind me, just copy-pasting code around... if args.operation == 'create-dna': Intermediate.send_To_Record_JSON(input) @@ -510,16 +521,23 @@ class exportNFTs(bpy.types.Operator): _save_path = bpy.path.abspath(bpy.context.scene.input_tool.save_path) _Blend_My_NFTs_Output, _batch_json_save_path, _nftBatch_save_path = make_directories(_save_path) - input = BMNFTData ( + input = BMNFTData ( nftName = bpy.context.scene.input_tool.nftName, save_path = _save_path, + nftsPerBatch = bpy.context.scene.input_tool.nftsPerBatch, batchToGenerate = bpy.context.scene.input_tool.batchToGenerate, collectionSize = bpy.context.scene.input_tool.collectionSize, + enableRarity = bpy.context.scene.input_tool.enableRarity, + Blend_My_NFTs_Output = _Blend_My_NFTs_Output, batch_json_save_path = _batch_json_save_path, nftBatch_save_path = _nftBatch_save_path, + enableLogic = bpy.context.scene.input_tool.enableLogic, + enableLogicJson = bpy.context.scene.input_tool.enable_Logic_Json, + logicFile = bpy.context.scene.input_tool.logicFile, + enableImages = bpy.context.scene.input_tool.imageBool, imageFileFormat = bpy.context.scene.input_tool.imageEnum, @@ -528,9 +546,9 @@ class exportNFTs(bpy.types.Operator): enableModelsBlender = bpy.context.scene.input_tool.modelBool, modelFileFormat = bpy.context.scene.input_tool.modelEnum, - + enableCustomFields = bpy.context.scene.input_tool.enableCustomFields, - + cardanoMetaDataBool = bpy.context.scene.input_tool.cardanoMetaDataBool, solanaMetaDataBool = bpy.context.scene.input_tool.solanaMetaDataBool, erc721MetaData = bpy.context.scene.input_tool.erc721MetaData, From 0e9872b7010ed3fe017603af6a24ad3429a03ab6 Mon Sep 17 00:00:00 2001 From: matt-159 Date: Thu, 14 Jul 2022 05:41:03 -0700 Subject: [PATCH 17/22] fixed setting name in config export --- __init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__init__.py b/__init__.py index 40e712f..25c75cd 100644 --- a/__init__.py +++ b/__init__.py @@ -719,7 +719,7 @@ class export_settings(bpy.types.Operator): "\n" "#Enable Logic\n" f"enableLogic={ str(settings.enableLogic) }\n" - f"enableLogicJson={ str(settings.enableLogicJson) }\n" + f"enableLogicJson={ str(settings.enable_Logic_Json) }\n" f"logicFilePath={ settings.logicFile }\n" "\n" "#NFT Media output type(s):\n" From 833908411a3aa3259a97f3bcfa970fe3b451c848 Mon Sep 17 00:00:00 2001 From: matt-159 Date: Thu, 14 Jul 2022 06:57:21 -0700 Subject: [PATCH 18/22] added Intermediate to module list --- __init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/__init__.py b/__init__.py index 25c75cd..d3985e8 100644 --- a/__init__.py +++ b/__init__.py @@ -55,6 +55,7 @@ if "bpy" in locals(): "get_combinations": get_combinations, "HeadlessUtil": HeadlessUtil, "loading_animation": loading_animation, + "Intermediate": Intermediate, "Logic": Logic, "Material_Generator": Material_Generator, "Metadata": Metadata, @@ -74,7 +75,6 @@ if "bpy" in locals(): combinations: int = 0 recommended_limit: int = 0 - @dataclass class BMNFTData: nftName: str @@ -310,7 +310,6 @@ def runAsHeadless(): ) - # don't mind me, just copy-pasting code around... if args.operation == 'create-dna': Intermediate.send_To_Record_JSON(input) From 47ca8146530dd60b313391b08e4f9f8551ba124f Mon Sep 17 00:00:00 2001 From: matt-159 Date: Thu, 14 Jul 2022 06:58:18 -0700 Subject: [PATCH 19/22] fixed variable name --- __init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__init__.py b/__init__.py index d3985e8..6487be6 100644 --- a/__init__.py +++ b/__init__.py @@ -110,7 +110,7 @@ class BMNFTData: materialsFile: str enableLogic: bool - enableLogicJson: bool + enable_Logic_Json: bool logicFile: str enableRarity: bool From ffc216798e216f1ef534e427c854758aff37ca66 Mon Sep 17 00:00:00 2001 From: matt-159 Date: Thu, 14 Jul 2022 07:02:05 -0700 Subject: [PATCH 20/22] pulled out duplicated code into getBMNFTData() function --- __init__.py | 183 +++++++++++++------------------------------ main/Intermediate.py | 11 ++- 2 files changed, 65 insertions(+), 129 deletions(-) diff --git a/__init__.py b/__init__.py index 6487be6..72dba75 100644 --- a/__init__.py +++ b/__init__.py @@ -124,6 +124,51 @@ class BMNFTData: def __post_init__(self): self.custom_Fields = {} +def getBMNFTData(): + _save_path = bpy.path.abspath(bpy.context.scene.input_tool.save_path) + _Blend_My_NFTs_Output, _batch_json_save_path, _nftBatch_save_path = make_directories(_save_path) + + data = BMNFTData ( + nftName = bpy.context.scene.input_tool.nftName, + save_path = _save_path, + nftsPerBatch = bpy.context.scene.input_tool.nftsPerBatch, + batchToGenerate = bpy.context.scene.input_tool.batchToGenerate, + collectionSize = bpy.context.scene.input_tool.collectionSize, + + enableRarity = bpy.context.scene.input_tool.enableRarity, + + Blend_My_NFTs_Output = _Blend_My_NFTs_Output, + batch_json_save_path = _batch_json_save_path, + nftBatch_save_path = _nftBatch_save_path, + + enableLogic = bpy.context.scene.input_tool.enableLogic, + enable_Logic_Json = bpy.context.scene.input_tool.enable_Logic_Json, + logicFile = bpy.context.scene.input_tool.logicFile, + + enableImages = bpy.context.scene.input_tool.imageBool, + imageFileFormat = bpy.context.scene.input_tool.imageEnum, + + enableAnimations = bpy.context.scene.input_tool.animationBool, + animationFileFormat = bpy.context.scene.input_tool.animationEnum, + + enableModelsBlender = bpy.context.scene.input_tool.modelBool, + modelFileFormat = bpy.context.scene.input_tool.modelEnum, + + enableCustomFields = bpy.context.scene.input_tool.enableCustomFields, + + cardanoMetaDataBool = bpy.context.scene.input_tool.cardanoMetaDataBool, + solanaMetaDataBool = bpy.context.scene.input_tool.solanaMetaDataBool, + erc721MetaData = bpy.context.scene.input_tool.erc721MetaData, + + cardano_description = bpy.context.scene.input_tool.cardano_description, + solana_description = bpy.context.scene.input_tool.solana_description, + erc721_description = bpy.context.scene.input_tool.erc721_description, + + enableMaterials = bpy.context.scene.input_tool.enableMaterials, + materialsFile = bpy.path.abspath(bpy.context.scene.input_tool.materialsFile) + ) + + return data @persistent def Refresh_UI(dummy1, dummy2): @@ -259,56 +304,13 @@ def runAsHeadless(): if args.save_path: settings.save_path = args.save_path - _save_path = bpy.path.abspath(settings.save_path) - _Blend_My_NFTs_Output, _batch_json_save_path, _nftBatch_save_path = make_directories(_save_path) - if args.batch_number: settings.batchToGenerate = args.batch_number + input = getBMNFTData() + if args.batch_data_path: - _batch_json_save_path = args.batch_data_path - - - input = BMNFTData ( - nftName = bpy.context.scene.input_tool.nftName, - save_path = _save_path, - nftsPerBatch = bpy.context.scene.input_tool.nftsPerBatch, - batchToGenerate = bpy.context.scene.input_tool.batchToGenerate, - collectionSize = bpy.context.scene.input_tool.collectionSize, - - enableRarity = bpy.context.scene.input_tool.enableRarity, - - Blend_My_NFTs_Output = _Blend_My_NFTs_Output, - batch_json_save_path = _batch_json_save_path, - nftBatch_save_path = _nftBatch_save_path, - - enableLogic = bpy.context.scene.input_tool.enableLogic, - enableLogicJson = bpy.context.scene.input_tool.enable_Logic_Json, - logicFile = bpy.context.scene.input_tool.logicFile, - - enableImages = bpy.context.scene.input_tool.imageBool, - imageFileFormat = bpy.context.scene.input_tool.imageEnum, - - enableAnimations = bpy.context.scene.input_tool.animationBool, - animationFileFormat = bpy.context.scene.input_tool.animationEnum, - - enableModelsBlender = bpy.context.scene.input_tool.modelBool, - modelFileFormat = bpy.context.scene.input_tool.modelEnum, - - enableCustomFields = bpy.context.scene.input_tool.enableCustomFields, - - cardanoMetaDataBool = bpy.context.scene.input_tool.cardanoMetaDataBool, - solanaMetaDataBool = bpy.context.scene.input_tool.solanaMetaDataBool, - erc721MetaData = bpy.context.scene.input_tool.erc721MetaData, - - cardano_description = bpy.context.scene.input_tool.cardano_description, - solana_description = bpy.context.scene.input_tool.solana_description, - erc721_description = bpy.context.scene.input_tool.erc721_description, - - enableMaterials = bpy.context.scene.input_tool.enableMaterials, - materialsFile = bpy.path.abspath(bpy.context.scene.input_tool.materialsFile) - ) - + input.batch_json_save_path = args.batch_data_path if args.operation == 'create-dna': Intermediate.send_To_Record_JSON(input) @@ -441,28 +443,11 @@ class createData(bpy.types.Operator): name="Reverse Order") def execute(self, context): - nftName = bpy.context.scene.input_tool.nftName - collectionSize = bpy.context.scene.input_tool.collectionSize - nftsPerBatch = bpy.context.scene.input_tool.nftsPerBatch - save_path = bpy.path.abspath(bpy.context.scene.input_tool.save_path) - - enableRarity = bpy.context.scene.input_tool.enableRarity - - enableLogic = bpy.context.scene.input_tool.enableLogic - enable_Logic_Json = bpy.context.scene.input_tool.enable_Logic_Json - logicFile = bpy.path.abspath(bpy.context.scene.input_tool.logicFile) - - enableMaterials = bpy.context.scene.input_tool.enableMaterials - materialsFile = bpy.path.abspath(bpy.context.scene.input_tool.materialsFile) - - Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path = make_directories(save_path) - # Handling Custom Fields UIList input: - if enableLogic: - if enable_Logic_Json and logicFile: - logicFile = json.load(open(logicFile)) + input = getBMNFTData() - if enable_Logic_Json and not logicFile: + if input.enableLogic: + if input.enable_Logic_Json and not input.logicFile: self.report({'ERROR'}, f"No Logic.json file path set. Please set the file path to your Logic.json file.") if not enable_Logic_Json: @@ -498,6 +483,7 @@ class createData(bpy.types.Operator): DNA_Generator.send_To_Record_JSON(collectionSize, nftsPerBatch, save_path, enableRarity, enableLogic, logicFile, enableMaterials, materialsFile, Blend_My_NFTs_Output, batch_json_save_path) + Intermediate.send_To_Record_JSON(input) self.report({'INFO'}, f"NFT Data created!") return {"FINISHED"} @@ -517,49 +503,8 @@ class exportNFTs(bpy.types.Operator): name="Reverse Order") def execute(self, context): - _save_path = bpy.path.abspath(bpy.context.scene.input_tool.save_path) - _Blend_My_NFTs_Output, _batch_json_save_path, _nftBatch_save_path = make_directories(_save_path) - - input = BMNFTData ( - nftName = bpy.context.scene.input_tool.nftName, - save_path = _save_path, - nftsPerBatch = bpy.context.scene.input_tool.nftsPerBatch, - batchToGenerate = bpy.context.scene.input_tool.batchToGenerate, - collectionSize = bpy.context.scene.input_tool.collectionSize, - - enableRarity = bpy.context.scene.input_tool.enableRarity, - - Blend_My_NFTs_Output = _Blend_My_NFTs_Output, - batch_json_save_path = _batch_json_save_path, - nftBatch_save_path = _nftBatch_save_path, - - enableLogic = bpy.context.scene.input_tool.enableLogic, - enableLogicJson = bpy.context.scene.input_tool.enable_Logic_Json, - logicFile = bpy.context.scene.input_tool.logicFile, - - enableImages = bpy.context.scene.input_tool.imageBool, - imageFileFormat = bpy.context.scene.input_tool.imageEnum, - - enableAnimations = bpy.context.scene.input_tool.animationBool, - animationFileFormat = bpy.context.scene.input_tool.animationEnum, - - enableModelsBlender = bpy.context.scene.input_tool.modelBool, - modelFileFormat = bpy.context.scene.input_tool.modelEnum, - - enableCustomFields = bpy.context.scene.input_tool.enableCustomFields, - - cardanoMetaDataBool = bpy.context.scene.input_tool.cardanoMetaDataBool, - solanaMetaDataBool = bpy.context.scene.input_tool.solanaMetaDataBool, - erc721MetaData = bpy.context.scene.input_tool.erc721MetaData, - - cardano_description = bpy.context.scene.input_tool.cardano_description, - solana_description = bpy.context.scene.input_tool.solana_description, - erc721_description = bpy.context.scene.input_tool.erc721_description, - - enableMaterials = bpy.context.scene.input_tool.enableMaterials, - materialsFile = bpy.path.abspath(bpy.context.scene.input_tool.materialsFile) - ) + input = getBMNFTData() # Handling Custom Fields UIList input: if input.enableCustomFields: scn = context.scene @@ -577,7 +522,8 @@ class exportNFTs(bpy.types.Operator): else: input.custom_Fields[item.field_name] = item.field_value - Exporter.render_and_save_NFTs(input) + + Intermediate.render_and_save_NFTs(input) self.report({'INFO'}, f"All NFTs generated for batch {input.batchToGenerate}!") @@ -658,25 +604,8 @@ class refactor_Batches(bpy.types.Operator): name="Reverse Order") def execute(self, context): - class input: - - save_path = bpy.path.abspath(bpy.context.scene.input_tool.save_path) - - enableCustomFields = bpy.context.scene.input_tool.enableCustomFields - custom_Fields = {} - - cardanoMetaDataBool = bpy.context.scene.input_tool.cardanoMetaDataBool - solanaMetaDataBool = bpy.context.scene.input_tool.solanaMetaDataBool - erc721MetaData = bpy.context.scene.input_tool.erc721MetaData - - cardano_description = bpy.context.scene.input_tool.cardano_description - solana_description = bpy.context.scene.input_tool.solana_description - erc721_description = bpy.context.scene.input_tool.erc721_description - - Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path = make_directories(save_path) - # Passing info to main functions for refactoring: - Refactorer.reformatNFTCollection(input) + Refactorer.reformatNFTCollection(getBMNFTData()) return {"FINISHED"} def invoke(self, context, event): diff --git a/main/Intermediate.py b/main/Intermediate.py index 39b4f92..9852684 100644 --- a/main/Intermediate.py +++ b/main/Intermediate.py @@ -1,6 +1,10 @@ -from main import DNA_Generator +import json +import bpy def send_To_Record_JSON(input): +from main import DNA_Generator, Exporter + +def send_To_Record_JSON(input, reverse_order=False): DNA_Generator.send_To_Record_JSON( input.collectionSize, input.nftsPerBatch, @@ -12,4 +16,7 @@ def send_To_Record_JSON(input): input.materialsFile, input.Blend_My_NFTs_Output, input.batch_json_save_path - ) \ No newline at end of file + ) + +def render_and_save_NFTs(input, reverse_order=False): + From ce8a04f5f9c605f0af04d012a20f1e69324105e4 Mon Sep 17 00:00:00 2001 From: matt-159 Date: Thu, 14 Jul 2022 07:02:25 -0700 Subject: [PATCH 21/22] Pulled out code into Intermediate module --- __init__.py | 49 -------------------------------------- main/Intermediate.py | 56 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 50 deletions(-) diff --git a/__init__.py b/__init__.py index 72dba75..155dbd5 100644 --- a/__init__.py +++ b/__init__.py @@ -450,39 +450,6 @@ class createData(bpy.types.Operator): if input.enable_Logic_Json and not input.logicFile: self.report({'ERROR'}, f"No Logic.json file path set. Please set the file path to your Logic.json file.") - if not enable_Logic_Json: - scn = context.scene - if self.reverse_order: - logicFile = {} - num = 1 - for i in range(scn.logic_fields_index, -1, -1): - item = scn.logic_fields[i] - - item_list1 = item.item_list1 - rule_type = item.rule_type - item_list2 = item.item_list2 - logicFile[f"Rule-{num}"] = { - "Items-1": item_list1.split(','), - "Rule-Type": rule_type, - "Items-2": item_list2.split(',') - } - num += 1 - else: - logicFile = {} - num = 1 - for item in scn.logic_fields: - item_list1 = item.item_list1 - rule_type = item.rule_type - item_list2 = item.item_list2 - logicFile[f"Rule-{num}"] = { - "Items-1": item_list1.split(','), - "Rule-Type": rule_type, - "Items-2": item_list2.split(',') - } - num += 1 - - DNA_Generator.send_To_Record_JSON(collectionSize, nftsPerBatch, save_path, enableRarity, enableLogic, logicFile, enableMaterials, - materialsFile, Blend_My_NFTs_Output, batch_json_save_path) Intermediate.send_To_Record_JSON(input) self.report({'INFO'}, f"NFT Data created!") @@ -506,22 +473,6 @@ class exportNFTs(bpy.types.Operator): input = getBMNFTData() # Handling Custom Fields UIList input: - if input.enableCustomFields: - scn = context.scene - if self.reverse_order: - for i in range(scn.custom_metadata_fields_index, -1, -1): - item = scn.custom_metadata_fields[i] - if item.field_name in list(input.custom_Fields.keys()): - raise ValueError(f"A duplicate of '{item.field_name}' was found. Please ensure all Custom Metadata field Names are unique.") - else: - input.custom_Fields[item.field_name] = item.field_value - else: - for item in scn.custom_metadata_fields: - if item.field_name in list(input.custom_Fields.keys()): - raise ValueError(f"A duplicate of '{item.field_name}' was found. Please ensure all Custom Metadata field Names are unique.") - else: - input.custom_Fields[item.field_name] = item.field_value - Intermediate.render_and_save_NFTs(input) diff --git a/main/Intermediate.py b/main/Intermediate.py index 9852684..5606e60 100644 --- a/main/Intermediate.py +++ b/main/Intermediate.py @@ -1,10 +1,47 @@ import json import bpy -def send_To_Record_JSON(input): from main import DNA_Generator, Exporter def send_To_Record_JSON(input, reverse_order=False): + + if input.enableLogic: + if input.enable_Logic_Json and input.logicFile: + input.logicFile = json.load(open(input.logicFile)) + + if input.enable_Logic_Json and not input.logicFile: + print({'ERROR'}, f"No Logic.json file path set. Please set the file path to your Logic.json file.") + + if not input.enable_Logic_Json: + scn = bpy.context.scene + if reverse_order: + input.logicFile = {} + num = 1 + for i in range(scn.logic_fields_index, -1, -1): + item = scn.logic_fields[i] + + item_list1 = item.item_list1 + rule_type = item.rule_type + item_list2 = item.item_list2 + input.logicFile[f"Rule-{num}"] = { + "Items-1": item_list1.split(','), + "Rule-Type": rule_type, + "Items-2": item_list2.split(',') + } + num += 1 + else: + input.logicFile = {} + num = 1 + for item in scn.logic_fields: + item_list1 = item.item_list1 + rule_type = item.rule_type + item_list2 = item.item_list2 + input.logicFile[f"Rule-{num}"] = { + "Items-1": item_list1.split(','), + "Rule-Type": rule_type, + "Items-2": item_list2.split(',') + } + num += 1 DNA_Generator.send_To_Record_JSON( input.collectionSize, input.nftsPerBatch, @@ -20,3 +57,20 @@ def send_To_Record_JSON(input, reverse_order=False): def render_and_save_NFTs(input, reverse_order=False): + if input.enableCustomFields: + scn = bpy.context.scene + if reverse_order: + for i in range(scn.custom_metadata_fields_index, -1, -1): + item = scn.custom_metadata_fields[i] + if item.field_name in list(input.custom_Fields.keys()): + raise ValueError(f"A duplicate of '{item.field_name}' was found. Please ensure all Custom Metadata field Names are unique.") + else: + input.custom_Fields[item.field_name] = item.field_value + else: + for item in scn.custom_metadata_fields: + if item.field_name in list(input.custom_Fields.keys()): + raise ValueError(f"A duplicate of '{item.field_name}' was found. Please ensure all Custom Metadata field Names are unique.") + else: + input.custom_Fields[item.field_name] = item.field_value + + Exporter.render_and_save_NFTs(input) \ No newline at end of file From fa31a4bd7c662e92b80dbc994ee8dd4b9bfc0d0d Mon Sep 17 00:00:00 2001 From: matt-159 Date: Thu, 14 Jul 2022 10:19:32 -0700 Subject: [PATCH 22/22] Forgot to redirect this render_and_save_NFTs() --- __init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__init__.py b/__init__.py index 155dbd5..b4c7472 100644 --- a/__init__.py +++ b/__init__.py @@ -316,7 +316,7 @@ def runAsHeadless(): Intermediate.send_To_Record_JSON(input) elif args.operation == 'generate-nfts': - Exporter.render_and_save_NFTs(input) + Intermediate.render_and_save_NFTs(input) elif args.operation == 'refactor-batches': Refactorer.reformatNFTCollection(input)