kopia lustrzana https://github.com/torrinworx/Blend_My_NFTs
Merge pull request #131 from matt-159/headless-update
Using BMNFTs headless has feature parity with using the UIpull/135/head
commit
138e1b967b
534
__init__.py
534
__init__.py
|
@ -23,8 +23,10 @@ import os
|
|||
import sys
|
||||
import json
|
||||
import importlib
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
# "a little hacky bs" - Matthew TheBrochacho ;)
|
||||
# "a little hacky bs" - matt159 ;)
|
||||
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
|
||||
|
||||
from main import \
|
||||
|
@ -33,6 +35,7 @@ from main import \
|
|||
Exporter, \
|
||||
get_combinations, \
|
||||
HeadlessUtil, \
|
||||
Intermediate, \
|
||||
loading_animation, \
|
||||
Logic, \
|
||||
Material_Generator, \
|
||||
|
@ -52,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,
|
||||
|
@ -71,6 +75,100 @@ if "bpy" in locals():
|
|||
combinations: int = 0
|
||||
recommended_limit: int = 0
|
||||
|
||||
@dataclass
|
||||
class BMNFTData:
|
||||
nftName: str
|
||||
save_path: str
|
||||
nftsPerBatch: int
|
||||
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
|
||||
|
||||
enableLogic: bool
|
||||
enable_Logic_Json: bool
|
||||
logicFile: str
|
||||
|
||||
enableRarity: bool
|
||||
|
||||
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 = {}
|
||||
|
||||
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):
|
||||
|
@ -124,32 +222,43 @@ 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 = (
|
||||
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)
|
||||
|
||||
|
@ -166,29 +275,31 @@ 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.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
|
||||
|
@ -196,80 +307,19 @@ def runAsHeadless():
|
|||
if args.batch_number:
|
||||
settings.batchToGenerate = args.batch_number
|
||||
|
||||
# dumpSettings(settings)
|
||||
input = getBMNFTData()
|
||||
|
||||
if args.batch_data_path:
|
||||
input.batch_json_save_path = args.batch_data_path
|
||||
|
||||
# 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':
|
||||
nftName = settings.nftName
|
||||
save_path = bpy.path.abspath(settings.save_path)
|
||||
batchToGenerate = settings.batchToGenerate
|
||||
collectionSize = settings.collectionSize
|
||||
Intermediate.render_and_save_NFTs(input)
|
||||
|
||||
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
|
||||
|
||||
enableMaterials = settings.enableMaterials
|
||||
materialsFile = settings.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
|
||||
|
||||
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)
|
||||
|
||||
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 ======== #
|
||||
|
@ -393,73 +443,15 @@ 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)
|
||||
|
||||
# Handling Custom Fields UIList input:
|
||||
if enableLogic:
|
||||
if enable_Logic_Json and logicFile:
|
||||
logicFile = json.load(open(logicFile))
|
||||
input = getBMNFTData()
|
||||
|
||||
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:
|
||||
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:
|
||||
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
|
||||
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
|
||||
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
|
||||
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,
|
||||
materialsFile, Blend_My_NFTs_Output, batch_json_save_path)
|
||||
Intermediate.send_To_Record_JSON(input)
|
||||
|
||||
self.report({'INFO'}, f"NFT Data created!")
|
||||
return {"FINISHED"}
|
||||
|
||||
|
@ -478,61 +470,11 @@ 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
|
||||
|
||||
Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path = make_directories(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
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
Exporter.render_and_save_NFTs(input)
|
||||
|
||||
Intermediate.render_and_save_NFTs(input)
|
||||
|
||||
self.report({'INFO'}, f"All NFTs generated for batch {input.batchToGenerate}!")
|
||||
|
||||
|
@ -546,42 +488,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 = BMNFTData (
|
||||
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)
|
||||
|
||||
|
@ -602,25 +555,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):
|
||||
|
@ -646,49 +582,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.enable_Logic_Json) }\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)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
|
@ -0,0 +1,76 @@
|
|||
import json
|
||||
import bpy
|
||||
|
||||
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,
|
||||
input.save_path,
|
||||
input.enableRarity,
|
||||
input.enableLogic,
|
||||
input.logicFile,
|
||||
input.enableMaterials,
|
||||
input.materialsFile,
|
||||
input.Blend_My_NFTs_Output,
|
||||
input.batch_json_save_path
|
||||
)
|
||||
|
||||
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)
|
Ładowanie…
Reference in New Issue