Removing deprecated script code

Added loading animation to DNA_Generator for Create NFT Data step.
pull/78/head
Torrin Leonard 2022-03-25 08:22:28 -04:00
rodzic e0528d0a65
commit f90cb38e2b
8 zmienionych plików z 36 dodań i 145 usunięć

Wyświetl plik

@ -66,7 +66,3 @@ def makeBatches(nftName, maxNFTs, nftsPerBatch, save_path, batch_json_save_path)
with open(os.path.join(batch_json_save_path, ("Batch{}.json".format(i + 1))), "w") as outfile2:
outfile2.write(incompleteBatch)
if __name__ == '__main__':
makeBatches()

Wyświetl plik

@ -8,13 +8,10 @@ import copy
import time
import json
import random
import importlib
from functools import partial
from .loading_animation import Loader
from . import Rarity, Logic, Checks
importlib.reload(Rarity)
importlib.reload(Logic)
importlib.reload(Checks)
class bcolors:
"""
@ -286,15 +283,28 @@ def send_To_Record_JSON(maxNFTs, nftsPerBatch, save_path, enableRarity, enableLo
time_start = time.time()
def create_nft_data():
DataDictionary, possibleCombinations = generateNFT_DNA(maxNFTs, nftsPerBatch, logicFile, enableRarity, enableLogic)
NFTRecord_save_path = os.path.join(Blend_My_NFTs_Output, "NFTRecord.json")
try:
DataDictionary, possibleCombinations = generateNFT_DNA(maxNFTs, nftsPerBatch, logicFile, enableRarity, enableLogic)
NFTRecord_save_path = os.path.join(Blend_My_NFTs_Output, "NFTRecord.json")
# Checks:
Checks.raise_Warning_maxNFTs(nftsPerBatch, maxNFTs)
# Checks:
Checks.raise_Warning_maxNFTs(nftsPerBatch, maxNFTs)
Checks.check_Rarity(DataDictionary["hierarchy"], DataDictionary["DNAList"], os.path.join(save_path, "Blend_My_NFTs Output/NFT_Data"))
Checks.check_Rarity(DataDictionary["hierarchy"], DataDictionary["DNAList"], os.path.join(save_path, "Blend_My_NFTs Output/NFT_Data"))
Checks.check_Duplicates(DataDictionary["DNAList"])
Checks.check_Duplicates(DataDictionary["DNAList"])
except FileNotFoundError:
raise FileNotFoundError(
f"\n{bcolors.ERROR}Blend_My_NFTs Error:\n"
f"Data not saved to NFTRecord.json. Please review your Blender scene and ensure it follows "
f"the naming conventions and scene structure. For more information, "
f"see:\n{bcolors.RESET}"
f"https://github.com/torrinworx/Blend_My_NFTs#blender-file-organization-and-structure\n"
)
else:
print("Something unexpected happened. Please check Blender System Console Traceback error for more information.")
finally:
loading.stop()
try:
ledger = json.dumps(DataDictionary, indent=1, ensure_ascii=True)
@ -313,34 +323,16 @@ def send_To_Record_JSON(maxNFTs, nftsPerBatch, save_path, enableRarity, enableLo
f"see:\n{bcolors.RESET}"
f"https://github.com/torrinworx/Blend_My_NFTs#blender-file-organization-and-structure\n"
)
return True
# Loading Animations:
bar = [
" [= ]",
" [ = ]",
" [ = ]",
" [ = ]",
" [ = ]",
" [ =]",
" [ = ]",
" [ = ]",
" [ = ]",
" [ = ]",
]
i = 0
while not create_nft_data():
print(bar[i % len(bar)], end="\r")
time.sleep(.2)
i += 1
# Loading Animation:
loading = Loader(f'Creating NFT DNA...', '').start()
create_nft_data()
loading.stop()
time_end = time.time()
print(
f"Created NFT Data in {time_end - time_start}s.\n"
f"{bcolors.OK}Created and saved NFT DNA in {time_end - time_start}s.\n{bcolors.RESET}"
)
if __name__ == '__main__':
send_To_Record_JSON()

Wyświetl plik

@ -6,15 +6,8 @@ import bpy
import os
import time
import json
import sys
import itertools
import threading
from .loading_animation import Loader
enableGeneration = False
colorList = []
generationType = None
class bcolors:
'''
@ -26,9 +19,6 @@ class bcolors:
RESET = '\033[0m' # RESET COLOR
def stripColorFromName(name):
return "_".join(name.split("_")[:-1])
def getBatchData(batchToGenerate, batch_json_save_path):
"""
Retrieves a given batches data determined by renderBatch in config.py
@ -60,11 +50,6 @@ def render_and_save_NFTs(nftName, maxNFTs, batchToGenerate, batch_json_save_path
for a in BatchDNAList:
for i in hierarchy:
for j in hierarchy[i]:
if enableGeneration:
"""
Remove Color code so blender recognises the collection
"""
j = stripColorFromName(j)
bpy.data.collections[j].hide_render = True
bpy.data.collections[j].hide_viewport = True
@ -95,10 +80,9 @@ def render_and_save_NFTs(nftName, maxNFTs, batchToGenerate, batch_json_save_path
for c in dnaDictionary:
collection = dnaDictionary[c]
if not enableGeneration:
if collection != '0':
bpy.data.collections[collection].hide_render = False
bpy.data.collections[collection].hide_viewport = False
if collection != '0':
bpy.data.collections[collection].hide_render = False
bpy.data.collections[collection].hide_viewport = False
time_start_2 = time.time()
@ -255,14 +239,8 @@ def render_and_save_NFTs(nftName, maxNFTs, batchToGenerate, batch_json_save_path
for i in hierarchy:
for j in hierarchy[i]:
if enableGeneration:
j = stripColorFromName(j)
bpy.data.collections[j].hide_render = False
bpy.data.collections[j].hide_viewport = False
print(f"\nAll NFTs successfully generated and sent to {nftBatch_save_path}"
f"\nCompleted all renders in Batch{batchToGenerate}.json in {time.time() - time_start_1}s\n")
if __name__ == '__main__':
render_and_save_NFTs()

Wyświetl plik

@ -189,7 +189,3 @@ def logicafyDNAsingle(hierarchy, singleDNA, logicFile):
break
return resultDNA
if __name__ == '__main__':
logicafyDNAsingle()

Wyświetl plik

@ -103,9 +103,3 @@ def returnErc721MetaData(name, NFT_DNA, NFT_Variants, custom_Fields_File, enable
metaDataDictErc721["attributes"] = attributes
return metaDataDictErc721
if __name__ == '__main__':
returnSolanaMetaData()
returnCardanoMetaData()
returnErc721MetaData()

Wyświetl plik

@ -32,15 +32,11 @@ def createDNArarity(hierarchy):
elif x != 0:
ifZeroBool = False
if ifZeroBool == True:
if ifZeroBool:
variantByNum = random.choices(number_List_Of_i, k=1)
elif ifZeroBool == False:
elif not ifZeroBool:
variantByNum = random.choices(number_List_Of_i, weights=rarity_List_Of_i, k=1)
singleDNA += "-" + str(variantByNum[0])
singleDNA = ''.join(singleDNA.split('-', 1))
return singleDNA
if __name__ == '__main__':
createDNArarity()

Wyświetl plik

@ -6,12 +6,8 @@ import os
import copy
import json
import shutil
import importlib
from . import Metadata
importlib.reload(Metadata)
removeList = [".gitignore", ".DS_Store"]
@ -233,6 +229,3 @@ def reformatNFTCollection(refactor_panel_input):
renameMetaData(rename_MetaData_Variables)
shutil.rmtree(refactor_panel_input.nftBatch_save_path)
if __name__ == '__main__':
reformatNFTCollection()

Wyświetl plik

@ -2,9 +2,6 @@ import bpy
import re
import copy
enableGeneration = False
colorList = []
class bcolors:
"""
The colour of console messages.
@ -42,33 +39,8 @@ def get_combinations_from_scene():
for c in traverse_tree(coll):
listAllCollInScene.append(c)
def listSubIgnoreCollections():
def getParentSubCollections(collection):
yield collection
for child in collection.children:
yield from getParentSubCollections(child)
collList = []
for c in getParentSubCollections(scriptIgnore):
collList.append(c.name)
return collList
ignoreList = listSubIgnoreCollections()
for i in listAllCollInScene:
if enableGeneration:
if i.name in colorList:
for j in range(len(colorList[i.name])):
if i.name[-1].isdigit() and i.name not in ignoreList:
listAllCollections.append(i.name + "_" + str(j + 1))
elif j == 0:
listAllCollections.append(i.name)
elif i.name[-1].isdigit() and i.name not in ignoreList:
listAllCollections.append(i.name + "_0")
else:
listAllCollections.append(i.name)
else:
listAllCollections.append(i.name)
listAllCollections.append(i.name)
listAllCollections.remove(scriptIgnore.name)
@ -145,21 +117,9 @@ def get_combinations_from_scene():
elif len(orderRarity) > 0:
number = orderRarity[0]
if enableGeneration:
if count == 1 or count == 0:
previousAttribute = i.partition("_")[0]
count +=1
elif i.partition("_")[0] == previousAttribute:
count +=1
else:
count = 1
number = str(count)
rarity = orderRarity[1]
if enableGeneration and stripColorFromName(i) in colorList:
color = orderRarity[2]
else:
color = "0"
eachObject = {"name": name, "number": number, "rarity": rarity, "color": color}
eachObject = {"name": name, "number": number, "rarity": rarity}
allAttDataList[i] = eachObject
return allAttDataList
@ -174,17 +134,7 @@ def get_combinations_from_scene():
colParLong = list(bpy.data.collections[str(i)].children)
colParShort = {}
for x in colParLong:
if enableGeneration:
"""
Append colors to blender name for PNG generator and NFTRecord.json to create the correct list
"""
if x.name in colorList:
for j in range(len(colorList[x.name])):
colParShort[x.name + "_" + str(j+1)] = None
else:
colParShort[x.name + "_0"] = None
else:
colParShort[x.name] = None
colParShort[x.name] = None
hierarchy[i] = colParShort
for a in hierarchy:
@ -227,7 +177,3 @@ def get_combinations_from_scene():
possibleCombinations = numOfCombinations(hierarchy)
return possibleCombinations
if __name__ == '__main__':
get_combinations_from_scene()