kopia lustrzana https://github.com/torrinworx/Blend_My_NFTs
Fixing issues with failed batches
Resolved conflicts with failed batches recovery related to headless variable integration from previous merge. Fixed issue where animations would get corrupt when resuming failed batch. The last file to be generated will now be deleted if it exists to avoid this issue.pull/136/head
rodzic
4f42106fa3
commit
fa1c2c5883
62
__init__.py
62
__init__.py
|
@ -551,42 +551,64 @@ class resume_failed_batch(bpy.types.Operator):
|
||||||
|
|
||||||
_fail_state, _failed_batch, _failed_dna, _failed_dna_index = Checks.check_FailedBatches(_batch_json_save_path)
|
_fail_state, _failed_batch, _failed_dna, _failed_dna_index = Checks.check_FailedBatches(_batch_json_save_path)
|
||||||
|
|
||||||
|
render_settings = batchData["Generation Save"][-1]["Render_Settings"]
|
||||||
|
|
||||||
input = BMNFTData(
|
input = BMNFTData(
|
||||||
nftName=batchData["Generation Save"][-1]["Render_Settings"]["nftName"],
|
nftName=render_settings["nftName"],
|
||||||
save_path=_save_path,
|
save_path=_save_path,
|
||||||
collectionSize=batchData["Generation Save"][-1]["Render_Settings"]["collectionSize"],
|
nftsPerBatch=render_settings["nftsPerBatch"],
|
||||||
|
batchToGenerate=render_settings["batchToGenerate"],
|
||||||
|
collectionSize=render_settings["collectionSize"],
|
||||||
|
|
||||||
Blend_My_NFTs_Output=_Blend_My_NFTs_Output,
|
Blend_My_NFTs_Output=_Blend_My_NFTs_Output,
|
||||||
batch_json_save_path=_batch_json_save_path,
|
batch_json_save_path=_batch_json_save_path,
|
||||||
nftBatch_save_path=batchData["Generation Save"][-1]["Render_Settings"]["nftBatch_save_path"],
|
nftBatch_save_path=render_settings["nftBatch_save_path"],
|
||||||
|
|
||||||
enableImages=batchData["Generation Save"][-1]["Render_Settings"]["enableImages"],
|
enableImages=render_settings["enableImages"],
|
||||||
imageFileFormat=batchData["Generation Save"][-1]["Render_Settings"]["imageFileFormat"],
|
imageFileFormat=render_settings["imageFileFormat"],
|
||||||
|
|
||||||
enableAnimations=batchData["Generation Save"][-1]["Render_Settings"]["enableAnimations"],
|
enableAnimations=render_settings["enableAnimations"],
|
||||||
animationFileFormat=batchData["Generation Save"][-1]["Render_Settings"]["animationFileFormat"],
|
animationFileFormat=render_settings["animationFileFormat"],
|
||||||
|
|
||||||
enableModelsBlender=batchData["Generation Save"][-1]["Render_Settings"]["enableModelsBlender"],
|
enableModelsBlender=render_settings["enableModelsBlender"],
|
||||||
modelFileFormat=batchData["Generation Save"][-1]["Render_Settings"]["modelFileFormat"],
|
modelFileFormat=render_settings["modelFileFormat"],
|
||||||
|
|
||||||
enableCustomFields=batchData["Generation Save"][-1]["Render_Settings"]["enableCustomFields"],
|
enableCustomFields=render_settings["enableCustomFields"],
|
||||||
custom_Fields=batchData["Generation Save"][-1]["Render_Settings"]["custom_Fields"],
|
|
||||||
|
|
||||||
cardanoMetaDataBool=batchData["Generation Save"][-1]["Render_Settings"]["cardanoMetaDataBool"],
|
cardanoMetaDataBool=render_settings["cardanoMetaDataBool"],
|
||||||
solanaMetaDataBool=batchData["Generation Save"][-1]["Render_Settings"]["solanaMetaDataBool"],
|
solanaMetaDataBool=render_settings["solanaMetaDataBool"],
|
||||||
erc721MetaData=batchData["Generation Save"][-1]["Render_Settings"]["erc721MetaData"],
|
erc721MetaData=render_settings["erc721MetaData"],
|
||||||
|
|
||||||
cardano_description=batchData["Generation Save"][-1]["Render_Settings"]["cardano_description"],
|
cardano_description=render_settings["cardano_description"],
|
||||||
solana_description=batchData["Generation Save"][-1]["Render_Settings"]["solana_description"],
|
solana_description=render_settings["solana_description"],
|
||||||
erc721_description=batchData["Generation Save"][-1]["Render_Settings"]["erc721_description"],
|
erc721_description=render_settings["erc721_description"],
|
||||||
|
|
||||||
enableMaterials=batchData["Generation Save"][-1]["Render_Settings"]["enableMaterials"],
|
enableMaterials=render_settings["enableMaterials"],
|
||||||
materialsFile=batchData["Generation Save"][-1]["Render_Settings"]["materialsFile"],
|
materialsFile=render_settings["materialsFile"],
|
||||||
|
|
||||||
|
enableLogic=render_settings["enableLogic"],
|
||||||
|
enable_Logic_Json=render_settings["enable_Logic_Json"],
|
||||||
|
logicFile=render_settings["logicFile"],
|
||||||
|
|
||||||
|
enableRarity=render_settings["enableRarity"],
|
||||||
|
|
||||||
|
enableAutoShutdown=render_settings["enableAutoShutdown"],
|
||||||
|
|
||||||
|
specify_timeBool=render_settings["specify_timeBool"],
|
||||||
|
hours=render_settings["hours"],
|
||||||
|
minutes=render_settings["minutes"],
|
||||||
|
|
||||||
|
emailNotificationBool=render_settings["emailNotificationBool"],
|
||||||
|
sender_from=render_settings["sender_from"],
|
||||||
|
email_password=render_settings["email_password"],
|
||||||
|
receiver_to=render_settings["receiver_to"],
|
||||||
|
|
||||||
fail_state=_fail_state,
|
fail_state=_fail_state,
|
||||||
failed_batch=_failed_batch,
|
failed_batch=_failed_batch,
|
||||||
failed_dna=_failed_dna,
|
failed_dna=_failed_dna,
|
||||||
failed_dna_index=_failed_dna_index
|
failed_dna_index=_failed_dna_index,
|
||||||
|
|
||||||
|
custom_Fields=render_settings["custom_Fields"],
|
||||||
)
|
)
|
||||||
|
|
||||||
Exporter.render_and_save_NFTs(input)
|
Exporter.render_and_save_NFTs(input)
|
||||||
|
|
|
@ -43,9 +43,9 @@ def save_generation_state(input):
|
||||||
"DNA Generated": None,
|
"DNA Generated": None,
|
||||||
"Generation Start Date and Time": [CURRENT_TIME, CURRENT_DATE, LOCAL_TIMEZONE],
|
"Generation Start Date and Time": [CURRENT_TIME, CURRENT_DATE, LOCAL_TIMEZONE],
|
||||||
"Render_Settings": {
|
"Render_Settings": {
|
||||||
|
|
||||||
"nftName": input.nftName,
|
"nftName": input.nftName,
|
||||||
"save_path": input.save_path,
|
"save_path": input.save_path,
|
||||||
|
"nftsPerBatch": input.nftsPerBatch,
|
||||||
"batchToGenerate": input.batchToGenerate,
|
"batchToGenerate": input.batchToGenerate,
|
||||||
"collectionSize": input.collectionSize,
|
"collectionSize": input.collectionSize,
|
||||||
|
|
||||||
|
@ -63,7 +63,6 @@ def save_generation_state(input):
|
||||||
"modelFileFormat": input.modelFileFormat,
|
"modelFileFormat": input.modelFileFormat,
|
||||||
|
|
||||||
"enableCustomFields": input.enableCustomFields,
|
"enableCustomFields": input.enableCustomFields,
|
||||||
"custom_Fields": input.custom_Fields,
|
|
||||||
|
|
||||||
"cardanoMetaDataBool": input.cardanoMetaDataBool,
|
"cardanoMetaDataBool": input.cardanoMetaDataBool,
|
||||||
"solanaMetaDataBool": input.solanaMetaDataBool,
|
"solanaMetaDataBool": input.solanaMetaDataBool,
|
||||||
|
@ -76,6 +75,24 @@ def save_generation_state(input):
|
||||||
"enableMaterials": input.enableMaterials,
|
"enableMaterials": input.enableMaterials,
|
||||||
"materialsFile": input.materialsFile,
|
"materialsFile": input.materialsFile,
|
||||||
|
|
||||||
|
"enableLogic": input.enableLogic,
|
||||||
|
"enable_Logic_Json": input.enable_Logic_Json,
|
||||||
|
"logicFile": input.logicFile,
|
||||||
|
|
||||||
|
"enableRarity": input.enableRarity,
|
||||||
|
|
||||||
|
"enableAutoShutdown": input.enableAutoShutdown,
|
||||||
|
|
||||||
|
"specify_timeBool": input.specify_timeBool,
|
||||||
|
"hours": input.hours,
|
||||||
|
"minutes": input.minutes,
|
||||||
|
|
||||||
|
"emailNotificationBool": input.emailNotificationBool,
|
||||||
|
"sender_from": input.sender_from,
|
||||||
|
"email_password": input.email_password,
|
||||||
|
"receiver_to": input.receiver_to,
|
||||||
|
|
||||||
|
"custom_Fields": input.custom_Fields,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -272,12 +289,24 @@ def render_and_save_NFTs(input):
|
||||||
solanaMetadataPath = os.path.join(batchFolder, "Solana_metadata")
|
solanaMetadataPath = os.path.join(batchFolder, "Solana_metadata")
|
||||||
erc721MetadataPath = os.path.join(batchFolder, "Erc721_metadata")
|
erc721MetadataPath = os.path.join(batchFolder, "Erc721_metadata")
|
||||||
|
|
||||||
|
|
||||||
|
def check_failed_exists(file_path):
|
||||||
|
# Delete a file if a fail state is detected and if the file being re-generated already exists. Prevents
|
||||||
|
# animations from corrupting.
|
||||||
|
|
||||||
|
if input.fail_state:
|
||||||
|
if os.path.exists(file_path):
|
||||||
|
os.remove(file_path)
|
||||||
|
|
||||||
# Generation/Rendering:
|
# Generation/Rendering:
|
||||||
if input.enableImages:
|
if input.enableImages:
|
||||||
|
|
||||||
print(f"{bcolors.OK}---Image---{bcolors.RESET}")
|
print(f"{bcolors.OK}---Image---{bcolors.RESET}")
|
||||||
|
|
||||||
image_render_time_start = time.time()
|
image_render_time_start = time.time()
|
||||||
|
|
||||||
|
check_failed_exists(imagePath)
|
||||||
|
|
||||||
def render_image():
|
def render_image():
|
||||||
if not os.path.exists(imageFolder):
|
if not os.path.exists(imageFolder):
|
||||||
os.makedirs(imageFolder)
|
os.makedirs(imageFolder)
|
||||||
|
@ -302,6 +331,8 @@ def render_and_save_NFTs(input):
|
||||||
|
|
||||||
animation_render_time_start = time.time()
|
animation_render_time_start = time.time()
|
||||||
|
|
||||||
|
check_failed_exists(animationPath)
|
||||||
|
|
||||||
def render_animation():
|
def render_animation():
|
||||||
if not os.path.exists(animationFolder):
|
if not os.path.exists(animationFolder):
|
||||||
os.makedirs(animationFolder)
|
os.makedirs(animationFolder)
|
||||||
|
@ -373,40 +404,49 @@ def render_and_save_NFTs(input):
|
||||||
# obj.select_set(False)
|
# obj.select_set(False)
|
||||||
|
|
||||||
if input.modelFileFormat == 'GLB':
|
if input.modelFileFormat == 'GLB':
|
||||||
|
check_failed_exists(f"{modelPath}.glb")
|
||||||
bpy.ops.export_scene.gltf(filepath=f"{modelPath}.glb",
|
bpy.ops.export_scene.gltf(filepath=f"{modelPath}.glb",
|
||||||
check_existing=True,
|
check_existing=True,
|
||||||
export_format='GLB',
|
export_format='GLB',
|
||||||
export_keep_originals=True,
|
export_keep_originals=True,
|
||||||
use_selection=True)
|
use_selection=True)
|
||||||
if input.modelFileFormat == 'GLTF_SEPARATE':
|
if input.modelFileFormat == 'GLTF_SEPARATE':
|
||||||
|
check_failed_exists(f"{modelPath}.gltf")
|
||||||
|
check_failed_exists(f"{modelPath}.bin")
|
||||||
bpy.ops.export_scene.gltf(filepath=f"{modelPath}",
|
bpy.ops.export_scene.gltf(filepath=f"{modelPath}",
|
||||||
check_existing=True,
|
check_existing=True,
|
||||||
export_format='GLTF_SEPARATE',
|
export_format='GLTF_SEPARATE',
|
||||||
export_keep_originals=True,
|
export_keep_originals=True,
|
||||||
use_selection=True)
|
use_selection=True)
|
||||||
if input.modelFileFormat == 'GLTF_EMBEDDED':
|
if input.modelFileFormat == 'GLTF_EMBEDDED':
|
||||||
|
check_failed_exists(f"{modelPath}.gltf")
|
||||||
bpy.ops.export_scene.gltf(filepath=f"{modelPath}.gltf",
|
bpy.ops.export_scene.gltf(filepath=f"{modelPath}.gltf",
|
||||||
check_existing=True,
|
check_existing=True,
|
||||||
export_format='GLTF_EMBEDDED',
|
export_format='GLTF_EMBEDDED',
|
||||||
export_keep_originals=True,
|
export_keep_originals=True,
|
||||||
use_selection=True)
|
use_selection=True)
|
||||||
elif input.modelFileFormat == 'FBX':
|
elif input.modelFileFormat == 'FBX':
|
||||||
|
check_failed_exists(f"{modelPath}.fbx")
|
||||||
bpy.ops.export_scene.fbx(filepath=f"{modelPath}.fbx",
|
bpy.ops.export_scene.fbx(filepath=f"{modelPath}.fbx",
|
||||||
check_existing=True,
|
check_existing=True,
|
||||||
use_selection=True)
|
use_selection=True)
|
||||||
elif input.modelFileFormat == 'OBJ':
|
elif input.modelFileFormat == 'OBJ':
|
||||||
|
check_failed_exists(f"{modelPath}.obj")
|
||||||
bpy.ops.export_scene.obj(filepath=f"{modelPath}.obj",
|
bpy.ops.export_scene.obj(filepath=f"{modelPath}.obj",
|
||||||
check_existing=True,
|
check_existing=True,
|
||||||
use_selection=True, )
|
use_selection=True, )
|
||||||
elif input.modelFileFormat == 'X3D':
|
elif input.modelFileFormat == 'X3D':
|
||||||
|
check_failed_exists(f"{modelPath}.x3d")
|
||||||
bpy.ops.export_scene.x3d(filepath=f"{modelPath}.x3d",
|
bpy.ops.export_scene.x3d(filepath=f"{modelPath}.x3d",
|
||||||
check_existing=True,
|
check_existing=True,
|
||||||
use_selection=True)
|
use_selection=True)
|
||||||
elif input.modelFileFormat == 'STL':
|
elif input.modelFileFormat == 'STL':
|
||||||
|
check_failed_exists(f"{modelPath}.stl")
|
||||||
bpy.ops.export_mesh.stl(filepath=f"{modelPath}.stl",
|
bpy.ops.export_mesh.stl(filepath=f"{modelPath}.stl",
|
||||||
check_existing=True,
|
check_existing=True,
|
||||||
use_selection=True)
|
use_selection=True)
|
||||||
elif input.modelFileFormat == 'VOX':
|
elif input.modelFileFormat == 'VOX':
|
||||||
|
check_failed_exists(f"{modelPath}.vox")
|
||||||
bpy.ops.export_vox.some_data(filepath=f"{modelPath}.vox")
|
bpy.ops.export_vox.some_data(filepath=f"{modelPath}.vox")
|
||||||
|
|
||||||
# Loading Animation:
|
# Loading Animation:
|
||||||
|
@ -417,7 +457,7 @@ def render_and_save_NFTs(input):
|
||||||
model_generation_time_end = time.time()
|
model_generation_time_end = time.time()
|
||||||
|
|
||||||
print(
|
print(
|
||||||
f"{bcolors.OK}Generated model in {model_generation_time_end - model_generation_time_start}s.\n{bcolors.RESET}"
|
f"{bcolors.OK}Generated 3D model in {model_generation_time_end - model_generation_time_start}s.\n{bcolors.RESET}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Generating Metadata:
|
# Generating Metadata:
|
||||||
|
|
Ładowanie…
Reference in New Issue