kopia lustrzana https://github.com/torrinworx/Blend_My_NFTs
Committing changes
__init__.py: - added Custom Field Operators for metadata - Added Description fields for Cardano, Solana, and ERC721 metadata templates - Reconfigured variables in Operator function to be in class - Created passable variables for new metadata fields - Updated methods - Added new Cardano metadata description field to panel - Added new Solana metadata description field to panel - Added new ERC721 metadata description field to panel - Removed old Logic Panel Batch_Refactorer.py: - Cleaned methods for passing variables with classes - Refactored functions and methods for calling functions from metaData.py - Created new class rename_MetaData_Variables for better variable passing DNA_Generator.py: - Removed unnecessary spaces Exporter.py: - BMNFT_metadata files now include "Empty" if DNA is set to "0" by Logic.py Logic.py: - Added Collections method to read dictionaries - Attributes and variants are now read independently and work properly - Variant order numbers are now properly selected metaData.py: - Removed unnecessary imports - Refactored function imports with new classes from Batch_Refactorer.py - Description is now inserted into each template as defined by the user in Refactor panel - Custom fields are now included in each templatepull/67/head
rodzic
8f6e8405c8
commit
7bd22835ce
102
__init__.py
102
__init__.py
|
@ -35,7 +35,6 @@ else:
|
|||
Batch_Refactorer, \
|
||||
get_combinations
|
||||
|
||||
|
||||
# User input Property Group:
|
||||
class BMNFTS_PGT_MyProperties(bpy.types.PropertyGroup):
|
||||
|
||||
|
@ -106,12 +105,32 @@ class BMNFTS_PGT_MyProperties(bpy.types.PropertyGroup):
|
|||
enableLogic: bpy.props.BoolProperty(name="Enable Logic")
|
||||
logicFile: bpy.props.StringProperty(
|
||||
name="Logic File",
|
||||
description="Path where Logic.txt is located.",
|
||||
description="Path where Logic.json is located.",
|
||||
default="",
|
||||
maxlen=1024,
|
||||
subtype="FILE_PATH"
|
||||
)
|
||||
|
||||
# Custom Metadata Fields:
|
||||
enableCustomFields: bpy.props.BoolProperty(name="Enable Custom Metadata Fields")
|
||||
customfieldsFile: bpy.props.StringProperty(
|
||||
name="Custom Fields File",
|
||||
description="Path where Custom_Fields.json is located.",
|
||||
default="",
|
||||
maxlen=1024,
|
||||
subtype="FILE_PATH"
|
||||
)
|
||||
|
||||
# Cardano Custom Metadata Fields
|
||||
cardano_description: bpy.props.StringProperty(name="Cardano description")
|
||||
|
||||
# Solana Custom Metadata Fields
|
||||
|
||||
solana_description: bpy.props.StringProperty(name="Solana description")
|
||||
|
||||
# ERC721 Custom Metadata Fields
|
||||
erc721_description: bpy.props.StringProperty(name="ERC721 description")
|
||||
|
||||
|
||||
def make_directories(save_path):
|
||||
Blend_My_NFTs_Output = os.path.join(save_path, "Blend_My_NFTs Output", "NFT_Data")
|
||||
|
@ -127,6 +146,7 @@ def make_directories(save_path):
|
|||
os.makedirs(nftBatch_save_path)
|
||||
return Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path
|
||||
|
||||
|
||||
# Update NFT count:
|
||||
combinations: int = 0
|
||||
recommended_limit: int = 0
|
||||
|
@ -142,6 +162,7 @@ def update_combinations(dummy1, dummy2):
|
|||
|
||||
redraw_panel()
|
||||
|
||||
|
||||
bpy.app.handlers.depsgraph_update_post.append(update_combinations)
|
||||
|
||||
# Main Operators:
|
||||
|
@ -212,16 +233,24 @@ class refactor_Batches(bpy.types.Operator):
|
|||
def execute(self, context):
|
||||
self.report({'INFO'}, "Batches Refactored, MetaData created!")
|
||||
|
||||
save_path = bpy.path.abspath(bpy.context.scene.my_tool.save_path)
|
||||
class refactor_panel_input:
|
||||
save_path = bpy.path.abspath(bpy.context.scene.my_tool.save_path)
|
||||
|
||||
cardanoMetaDataBool = bpy.context.scene.my_tool.cardanoMetaDataBool
|
||||
solanaMetaDataBool = bpy.context.scene.my_tool.solanaMetaDataBool
|
||||
erc721MetaData = bpy.context.scene.my_tool.erc721MetaData
|
||||
custom_Fields_File = bpy.path.abspath(bpy.context.scene.my_tool.customfieldsFile)
|
||||
enableCustomFields = bpy.context.scene.my_tool.enableCustomFields
|
||||
|
||||
Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path = make_directories(save_path)
|
||||
cardanoMetaDataBool = bpy.context.scene.my_tool.cardanoMetaDataBool
|
||||
solanaMetaDataBool = bpy.context.scene.my_tool.solanaMetaDataBool
|
||||
erc721MetaData = bpy.context.scene.my_tool.erc721MetaData
|
||||
|
||||
cardano_description = bpy.context.scene.my_tool.cardano_description
|
||||
solana_description = bpy.context.scene.my_tool.solana_description
|
||||
erc721_description = bpy.context.scene.my_tool.erc721_description
|
||||
|
||||
Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path = make_directories(save_path)
|
||||
|
||||
Batch_Refactorer.reformatNFTCollection(refactor_panel_input)
|
||||
|
||||
Batch_Refactorer.reformatNFTCollection(save_path, Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path,
|
||||
cardanoMetaDataBool, solanaMetaDataBool, erc721MetaData)
|
||||
return {"FINISHED"}
|
||||
|
||||
def invoke(self, context, event):
|
||||
|
@ -287,17 +316,17 @@ class BMNFTS_PT_GenerateNFTs(bpy.types.Panel):
|
|||
|
||||
row = layout.row()
|
||||
row.prop(mytool, "imageBool")
|
||||
if bpy.context.scene.my_tool.imageBool == True:
|
||||
if bpy.context.scene.my_tool.imageBool:
|
||||
row.prop(mytool, "imageEnum")
|
||||
|
||||
row = layout.row()
|
||||
row.prop(mytool, "animationBool")
|
||||
if bpy.context.scene.my_tool.animationBool == True:
|
||||
if bpy.context.scene.my_tool.animationBool:
|
||||
row.prop(mytool, "animationEnum")
|
||||
|
||||
row = layout.row()
|
||||
row.prop(mytool, "modelBool")
|
||||
if bpy.context.scene.my_tool.modelBool == True:
|
||||
if bpy.context.scene.my_tool.modelBool:
|
||||
row.prop(mytool, "modelEnum")
|
||||
|
||||
row = layout.row()
|
||||
|
@ -324,8 +353,41 @@ class BMNFTS_PT_Refactor(bpy.types.Panel):
|
|||
|
||||
row = layout.row()
|
||||
row.prop(mytool, "cardanoMetaDataBool")
|
||||
if bpy.context.scene.my_tool.cardanoMetaDataBool:
|
||||
row = layout.row()
|
||||
row.prop(mytool, "cardano_description")
|
||||
|
||||
row = layout.row()
|
||||
row.operator("wm.url_open", text="Cardano Metadata Documentation",
|
||||
icon='URL').url = "https://cips.cardano.org/cips/cip25/"
|
||||
|
||||
row = layout.row()
|
||||
row.prop(mytool, "solanaMetaDataBool")
|
||||
if bpy.context.scene.my_tool.solanaMetaDataBool:
|
||||
row = layout.row()
|
||||
row.prop(mytool, "solana_description")
|
||||
|
||||
row = layout.row()
|
||||
row.operator("wm.url_open", text="Solana Metadata Documentation",
|
||||
icon='URL').url = "https://docs.metaplex.com/token-metadata/specification"
|
||||
|
||||
row = layout.row()
|
||||
row.prop(mytool, "erc721MetaData")
|
||||
if bpy.context.scene.my_tool.erc721MetaData:
|
||||
row = layout.row()
|
||||
row.prop(mytool, "erc721_description")
|
||||
|
||||
row = layout.row()
|
||||
row.operator("wm.url_open", text="ERC721 Metadata Documentation",
|
||||
icon='URL').url = "https://docs.opensea.io/docs/metadata-standards"
|
||||
|
||||
row = layout.row()
|
||||
row.prop(mytool, "enableCustomFields")
|
||||
if bpy.context.scene.my_tool.enableCustomFields:
|
||||
row = layout.row()
|
||||
row.prop(mytool, "customfieldsFile")
|
||||
|
||||
row = layout.row()
|
||||
self.layout.operator("refactor.batches", icon='FOLDER_REDIRECT', text="Refactor Batches & create MetaData")
|
||||
|
||||
# Documentation Panel:
|
||||
|
@ -345,19 +407,6 @@ class BMNFTS_PT_Documentation(bpy.types.Panel):
|
|||
row.operator("wm.url_open", text="Documentation",
|
||||
icon='URL').url = "https://github.com/torrinworx/Blend_My_NFTs"
|
||||
|
||||
# Logic Panel:
|
||||
class BMNFTS_PT_LOGIC_Panel(bpy.types.Panel):
|
||||
bl_label = "Logic"
|
||||
bl_idname = "BMNFTS_PT_LOGIC_Panel"
|
||||
bl_space_type = 'VIEW_3D'
|
||||
bl_region_type = 'UI'
|
||||
bl_category = 'Blend_My_NFTs'
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
scene = context.scene
|
||||
mytool = scene.my_tool
|
||||
|
||||
# # Materials Panel:
|
||||
#
|
||||
# class BMNFTS_PT_MATERIALS_Panel(bpy.types.Panel):
|
||||
|
@ -388,7 +437,6 @@ class BMNFTS_PT_LOGIC_Panel(bpy.types.Panel):
|
|||
# row = layout.row()
|
||||
# row.prop(mytool, "apiKey")
|
||||
|
||||
|
||||
def redraw_panel():
|
||||
try:
|
||||
bpy.utils.unregister_class(BMNFTS_PT_CreateData)
|
||||
|
@ -406,8 +454,6 @@ classes = (
|
|||
BMNFTS_PT_Documentation,
|
||||
|
||||
# Other panels:
|
||||
|
||||
BMNFTS_PT_LOGIC_Panel,
|
||||
# BMNFTS_PT_MATERIALS_Panel,
|
||||
# BMNFTS_PT_API_Panel,
|
||||
|
||||
|
|
|
@ -59,55 +59,59 @@ def sendMetaDataToJson(metaDataDict, metaDataPath, jsonName):
|
|||
with open(os.path.join(metaDataPath, jsonName), 'w') as outfile:
|
||||
outfile.write(jsonMetaData + '\n')
|
||||
|
||||
def renameMetaData(completeCollPath, completeMetaDataPath, cardanoMetaDataBool, solanaMetaDataBool, erc721MetaData):
|
||||
metaDataListOld = os.listdir(completeMetaDataPath)
|
||||
cardanoMetaDataPath = os.path.join(completeCollPath, "Cardano_metaData")
|
||||
solanaMetaDataPath = os.path.join(completeCollPath, "Solana_metaData")
|
||||
erc721MetaDataPath = os.path.join(completeCollPath, "Erc721_metaData")
|
||||
def renameMetaData(rename_MetaData_Variables):
|
||||
metaDataListOld = os.listdir(rename_MetaData_Variables.completeMetaDataPath)
|
||||
cardanoMetaDataPath = os.path.join(rename_MetaData_Variables.completeCollPath, "Cardano_metaData")
|
||||
solanaMetaDataPath = os.path.join(rename_MetaData_Variables.completeCollPath, "Solana_metaData")
|
||||
erc721MetaDataPath = os.path.join(rename_MetaData_Variables.completeCollPath, "Erc721_metaData")
|
||||
|
||||
for i in metaDataListOld:
|
||||
name, NFT_DNA, NFT_Variants = getMetaDataDirty(completeMetaDataPath, i)
|
||||
name, NFT_DNA, NFT_Variants = getMetaDataDirty(rename_MetaData_Variables.completeMetaDataPath, i)
|
||||
|
||||
file_name = os.path.splitext(i)[0]
|
||||
file_num = file_name.split("_")[1]
|
||||
|
||||
if cardanoMetaDataBool:
|
||||
if rename_MetaData_Variables.cardanoMetaDataBool:
|
||||
if not os.path.exists(cardanoMetaDataPath):
|
||||
os.mkdir(cardanoMetaDataPath)
|
||||
|
||||
cardanoJsonNew = "Cardano_" + i
|
||||
cardanoNewName = name.split("_")[0] + "_" + str(file_num)
|
||||
|
||||
metaDataDictCardano = metaData.returnCardanoMetaData(cardanoNewName, NFT_DNA, NFT_Variants)
|
||||
sendMetaDataToJson(metaDataDictCardano, cardanoMetaDataPath, cardanoJsonNew)
|
||||
metaDataDictCardano = metaData.returnCardanoMetaData(cardanoNewName, NFT_DNA, NFT_Variants, rename_MetaData_Variables.custom_Fields_File, rename_MetaData_Variables.enableCustomFields, rename_MetaData_Variables.cardano_description)
|
||||
|
||||
if solanaMetaDataBool:
|
||||
sendMetaDataToJson(metaDataDictCardano, cardanoMetaDataPath, cardanoJsonNew,)
|
||||
|
||||
if rename_MetaData_Variables.solanaMetaDataBool:
|
||||
if not os.path.exists(solanaMetaDataPath):
|
||||
os.mkdir(solanaMetaDataPath)
|
||||
|
||||
solanaJsonNew = "Solana_" + i
|
||||
solanaNewName = name.split("_")[0] + "_" + str(file_num)
|
||||
|
||||
metaDataDictSolana = metaData.returnSolanaMetaData(solanaNewName, NFT_DNA, NFT_Variants)
|
||||
metaDataDictSolana = metaData.returnSolanaMetaData(solanaNewName, NFT_DNA, NFT_Variants, rename_MetaData_Variables.custom_Fields_File, rename_MetaData_Variables.enableCustomFields, rename_MetaData_Variables.solana_description)
|
||||
|
||||
sendMetaDataToJson(metaDataDictSolana, solanaMetaDataPath, solanaJsonNew)
|
||||
|
||||
if erc721MetaData:
|
||||
if rename_MetaData_Variables.erc721MetaData:
|
||||
if not os.path.exists(erc721MetaDataPath):
|
||||
os.mkdir(erc721MetaDataPath)
|
||||
|
||||
erc721JsonNew = "Erc721_" + i
|
||||
erc721NewName = name.split("_")[0] + "_" + str(file_num)
|
||||
|
||||
metaDataDictErc721 = metaData.returnErc721MetaData(erc721NewName, NFT_DNA, NFT_Variants)
|
||||
metaDataDictErc721 = metaData.returnErc721MetaData(erc721NewName, NFT_DNA, NFT_Variants, rename_MetaData_Variables.custom_Fields_File, rename_MetaData_Variables.enableCustomFields, rename_MetaData_Variables.erc721_description)
|
||||
|
||||
sendMetaDataToJson(metaDataDictErc721, erc721MetaDataPath, erc721JsonNew)
|
||||
return
|
||||
|
||||
def reformatNFTCollection(save_path, Blend_My_NFTs_Output, batch_json_save_path, nftBatch_save_path, cardanoMetaDataBool,
|
||||
solanaMetaDataBool, erc721MetaData):
|
||||
def reformatNFTCollection(refactor_panel_input):
|
||||
images, animations, models, metaData = getNFType(refactor_panel_input.nftBatch_save_path)
|
||||
|
||||
images, animations, models, metaData = getNFType(nftBatch_save_path)
|
||||
global completeCollPath
|
||||
global completeMetaDataPath
|
||||
|
||||
completeCollPath = os.path.join(save_path, "Blend_My_NFTs Output", "Complete_Collection")
|
||||
completeCollPath = os.path.join(refactor_panel_input.save_path, "Blend_My_NFTs Output", "Complete_Collection")
|
||||
completeImagePath = os.path.join(completeCollPath, "Images")
|
||||
completeAnimationsPath = os.path.join(completeCollPath, "Animations")
|
||||
completeModelsPath = os.path.join(completeCollPath, "Models")
|
||||
|
@ -124,7 +128,7 @@ def reformatNFTCollection(save_path, Blend_My_NFTs_Output, batch_json_save_path,
|
|||
if metaData and not os.path.exists(completeMetaDataPath):
|
||||
os.mkdir(completeMetaDataPath)
|
||||
|
||||
batchListDirty = os.listdir(nftBatch_save_path)
|
||||
batchListDirty = os.listdir(refactor_panel_input.nftBatch_save_path)
|
||||
batchList = [x for x in batchListDirty if (x not in removeList)]
|
||||
|
||||
imageCount = 1
|
||||
|
@ -133,11 +137,11 @@ def reformatNFTCollection(save_path, Blend_My_NFTs_Output, batch_json_save_path,
|
|||
dataCount = 1
|
||||
for i in batchList:
|
||||
if images:
|
||||
imagesDir = os.path.join(nftBatch_save_path, i, "Images")
|
||||
imagesDir = os.path.join(refactor_panel_input.nftBatch_save_path, i, "Images")
|
||||
imagesList = sorted(os.listdir(imagesDir))
|
||||
|
||||
for j in imagesList:
|
||||
imageOldPath = os.path.join(nftBatch_save_path, i, "Images", j)
|
||||
imageOldPath = os.path.join(refactor_panel_input.nftBatch_save_path, i, "Images", j)
|
||||
nameOldDirty = copy.deepcopy(os.path.splitext(j)[0])
|
||||
extension = copy.deepcopy(os.path.splitext(j)[1])
|
||||
nameOldClean = nameOldDirty.split("_")[0]
|
||||
|
@ -150,11 +154,11 @@ def reformatNFTCollection(save_path, Blend_My_NFTs_Output, batch_json_save_path,
|
|||
imageCount += 1
|
||||
|
||||
if animations:
|
||||
animationsDir = os.path.join(nftBatch_save_path, i, "Animations")
|
||||
animationsDir = os.path.join(refactor_panel_input.nftBatch_save_path, i, "Animations")
|
||||
animationsList = sorted(os.listdir(animationsDir))
|
||||
|
||||
for j in animationsList:
|
||||
animationOldPath = os.path.join(nftBatch_save_path, i, "Animations", j)
|
||||
animationOldPath = os.path.join(refactor_panel_input.nftBatch_save_path, i, "Animations", j)
|
||||
nameOldDirty = copy.deepcopy(os.path.splitext(j)[0])
|
||||
extension = copy.deepcopy(os.path.splitext(j)[1])
|
||||
nameOldClean = nameOldDirty.split("_")[0]
|
||||
|
@ -167,11 +171,11 @@ def reformatNFTCollection(save_path, Blend_My_NFTs_Output, batch_json_save_path,
|
|||
animationCount += 1
|
||||
|
||||
if models:
|
||||
modelsDir = os.path.join(nftBatch_save_path, i, "Models")
|
||||
modelsDir = os.path.join(refactor_panel_input.nftBatch_save_path, i, "Models")
|
||||
modelsList = sorted(os.listdir(modelsDir))
|
||||
|
||||
for j in modelsList:
|
||||
modelOldPath = os.path.join(nftBatch_save_path, i, "Models", j)
|
||||
modelOldPath = os.path.join(refactor_panel_input.nftBatch_save_path, i, "Models", j)
|
||||
nameOldDirty = copy.deepcopy(os.path.splitext(j)[0])
|
||||
extension = copy.deepcopy(os.path.splitext(j)[1])
|
||||
nameOldClean = nameOldDirty.split("_")[0]
|
||||
|
@ -184,11 +188,11 @@ def reformatNFTCollection(save_path, Blend_My_NFTs_Output, batch_json_save_path,
|
|||
modelCount += 1
|
||||
|
||||
if metaData:
|
||||
dataDir = os.path.join(nftBatch_save_path, i, "BMNFT_metaData")
|
||||
dataDir = os.path.join(refactor_panel_input.nftBatch_save_path, i, "BMNFT_metaData")
|
||||
dataList = sorted(os.listdir(dataDir))
|
||||
|
||||
for j in dataList:
|
||||
dataOldPath = os.path.join(nftBatch_save_path, i, "BMNFT_metaData", j)
|
||||
dataOldPath = os.path.join(refactor_panel_input.nftBatch_save_path, i, "BMNFT_metaData", j)
|
||||
nameOldDirty = copy.deepcopy(os.path.splitext(j)[0])
|
||||
extension = copy.deepcopy(os.path.splitext(j)[1])
|
||||
nameOldClean = nameOldDirty.split("_")[0]
|
||||
|
@ -207,11 +211,28 @@ def reformatNFTCollection(save_path, Blend_My_NFTs_Output, batch_json_save_path,
|
|||
|
||||
dataCount += 1
|
||||
|
||||
print(f"All NFT files stored and sorted to the Complete_Collection folder in {save_path}")
|
||||
print(f"All NFT files stored and sorted to the Complete_Collection folder in {refactor_panel_input.save_path}")
|
||||
|
||||
renameMetaData(completeCollPath, completeMetaDataPath, cardanoMetaDataBool, solanaMetaDataBool, erc721MetaData)
|
||||
class rename_MetaData_Variables:
|
||||
completeCollPath = completeCollPath
|
||||
completeMetaDataPath = completeMetaDataPath
|
||||
|
||||
shutil.rmtree(nftBatch_save_path)
|
||||
cardanoMetaDataBool = refactor_panel_input.cardanoMetaDataBool
|
||||
solanaMetaDataBool = refactor_panel_input.solanaMetaDataBool
|
||||
erc721MetaData = refactor_panel_input.erc721MetaData
|
||||
|
||||
custom_Fields_File = refactor_panel_input.custom_Fields_File
|
||||
enableCustomFields = refactor_panel_input.enableCustomFields
|
||||
|
||||
|
||||
cardano_description = refactor_panel_input.cardano_description
|
||||
solana_description = refactor_panel_input.solana_description
|
||||
erc721_description = refactor_panel_input.erc721_description
|
||||
|
||||
|
||||
renameMetaData(rename_MetaData_Variables)
|
||||
|
||||
shutil.rmtree(refactor_panel_input.nftBatch_save_path)
|
||||
|
||||
if __name__ == '__main__':
|
||||
reformatNFTCollection()
|
||||
|
|
|
@ -294,7 +294,7 @@ def generateNFT_DNA(nftName, maxNFTs, nftsPerBatch, save_path, logicFile, enable
|
|||
dnaStrList = []
|
||||
|
||||
for i in listOptionVariant:
|
||||
randomVariantNum = random.choices(i, k = 1)
|
||||
randomVariantNum = random.choices(i, k=1)
|
||||
str1 = ''.join(str(e) for e in randomVariantNum)
|
||||
dnaStrList.append(str1)
|
||||
|
||||
|
|
|
@ -96,6 +96,7 @@ def render_and_save_NFTs(nftName, maxNFTs, batchToGenerate, batch_json_save_path
|
|||
bpy.data.collections[collection].hide_render = False
|
||||
bpy.data.collections[collection].hide_viewport = False
|
||||
|
||||
|
||||
time_start_2 = time.time()
|
||||
|
||||
batchFolder = os.path.join(nftBatch_save_path, "Batch" + str(batchToGenerate))
|
||||
|
@ -131,7 +132,6 @@ def render_and_save_NFTs(nftName, maxNFTs, batchToGenerate, batch_json_save_path
|
|||
bpy.data.collections[collection].hide_render = False
|
||||
bpy.data.collections[collection].hide_viewport = False
|
||||
|
||||
|
||||
if enableImages:
|
||||
print(f"{bcolors.OK}Rendering Image{bcolors.RESET}")
|
||||
|
||||
|
@ -167,7 +167,6 @@ def render_and_save_NFTs(nftName, maxNFTs, batchToGenerate, batch_json_save_path
|
|||
|
||||
for i in dnaDictionary:
|
||||
coll = dnaDictionary[i]
|
||||
|
||||
if coll != '0':
|
||||
for obj in bpy.data.collections[coll].all_objects:
|
||||
obj.select_set(True)
|
||||
|
@ -197,7 +196,7 @@ def render_and_save_NFTs(nftName, maxNFTs, batchToGenerate, batch_json_save_path
|
|||
elif modelFileFormat == 'OBJ':
|
||||
bpy.ops.export_scene.obj(filepath=f"{modelPath}.obj",
|
||||
check_existing=True,
|
||||
use_selection=True)
|
||||
use_selection=True,)
|
||||
elif modelFileFormat == 'X3D':
|
||||
bpy.ops.export_scene.x3d(filepath=f"{modelPath}.x3d",
|
||||
check_existing=True,
|
||||
|
@ -212,6 +211,10 @@ def render_and_save_NFTs(nftName, maxNFTs, batchToGenerate, batch_json_save_path
|
|||
if not os.path.exists(metaDataFolder):
|
||||
os.makedirs(metaDataFolder)
|
||||
|
||||
for b in dnaDictionary:
|
||||
if dnaDictionary[b] == "0":
|
||||
dnaDictionary[b] = "Empty"
|
||||
|
||||
metaDataDict = {"name": name, "NFT_DNA": a, "NFT_Variants": dnaDictionary}
|
||||
|
||||
jsonMetaData = json.dumps(metaDataDict, indent=1, ensure_ascii=True)
|
||||
|
|
|
@ -7,33 +7,31 @@ import sys
|
|||
import json
|
||||
import random
|
||||
import importlib
|
||||
import collections
|
||||
|
||||
from . import metaData
|
||||
|
||||
importlib.reload(metaData)
|
||||
|
||||
removeList = [".gitignore", ".DS_Store"]
|
||||
|
||||
|
||||
# Helper Functions
|
||||
def isAttorVar(hierarchy, items_List):
|
||||
items_returned = {}
|
||||
|
||||
items_returned = collections.defaultdict(list)
|
||||
for i in items_List:
|
||||
for j in hierarchy:
|
||||
if i == j: # If i is an Attribute, add all i Variants to dictionary.
|
||||
items_returned[i] = list(hierarchy[j].keys())
|
||||
items_returned[i].append("Empty")
|
||||
|
||||
for h in hierarchy[j]:
|
||||
if h == i: # If i is a Variant, add i Variant and i's Attribute to dictionary.
|
||||
items_returned[j] = [h]
|
||||
if i in list(hierarchy[j].keys()):
|
||||
items_returned[j].append(i)
|
||||
|
||||
# Check if all variants in an attribute were included, if so, add "Empty" variant.
|
||||
for i in items_returned:
|
||||
if list(items_returned[i]) == list(hierarchy[i].keys()):
|
||||
items_returned[i].append("Empty")
|
||||
|
||||
return items_returned
|
||||
return dict(items_returned)
|
||||
|
||||
def getAttIndex(hierarchy, attribute):
|
||||
attList = list(hierarchy.keys())
|
||||
|
@ -55,39 +53,77 @@ def items_to_num(hierarchy, items_List):
|
|||
for j in items_List[i]:
|
||||
variant_num_list.append(getVarNum(j))
|
||||
|
||||
num_List[getAttIndex(hierarchy, i)] = variant_num_list
|
||||
|
||||
|
||||
num_List[i] = variant_num_list
|
||||
return num_List
|
||||
|
||||
def rar_selectVar(hierarchy, items_List, deconstructed_DNA):
|
||||
|
||||
for attribute in items_List:
|
||||
|
||||
a_attribute_index = getAttIndex(hierarchy, attribute)
|
||||
|
||||
selected_variants = items_List[attribute]
|
||||
hierarchy_selected_variants = list(hierarchy[attribute])
|
||||
|
||||
left_over_variants = [x for x in hierarchy_selected_variants if x not in selected_variants]
|
||||
|
||||
if not left_over_variants:
|
||||
deconstructed_DNA[int(a_attribute_index)] = "0"
|
||||
else:
|
||||
number_List_Of_i = []
|
||||
rarity_List_Of_i = []
|
||||
ifZeroBool = None
|
||||
variantNum = None
|
||||
|
||||
for a in left_over_variants:
|
||||
number = a.split("_")[1]
|
||||
rarity = a.split("_")[2]
|
||||
|
||||
number_List_Of_i.append(int(number))
|
||||
rarity_List_Of_i.append(float(rarity))
|
||||
|
||||
for x in rarity_List_Of_i:
|
||||
if x == 0:
|
||||
ifZeroBool = True
|
||||
elif x != 0:
|
||||
ifZeroBool = False
|
||||
|
||||
if ifZeroBool:
|
||||
variantNum = random.choices(number_List_Of_i, k=1)
|
||||
|
||||
if not ifZeroBool:
|
||||
variantNum = random.choices(number_List_Of_i, weights=rarity_List_Of_i, k=1)
|
||||
|
||||
deconstructed_DNA[int(a_attribute_index)] = str(variantNum[0])
|
||||
|
||||
return deconstructed_DNA
|
||||
|
||||
# Main Function
|
||||
def logicafyDNAList(DNAList, hierarchy, logicFile):
|
||||
logicFile = json.load(open(logicFile))
|
||||
|
||||
LogicDNAList_deconstructed = []
|
||||
items_List1 = []
|
||||
items_List2 = []
|
||||
|
||||
for a in logicFile:
|
||||
items_List1 = isAttorVar(hierarchy, logicFile[a]["Items-1"])
|
||||
items_List2 = isAttorVar(hierarchy, logicFile[a]["Items-2"])
|
||||
|
||||
# Convert String Attributes to DNA Index number, and String Variants to Order number. Variant == 0 if Empty given.
|
||||
num_List1 = items_to_num(hierarchy, items_List1)
|
||||
num_List2 = items_to_num(hierarchy, items_List2)
|
||||
|
||||
for a in DNAList:
|
||||
deconstructed_DNA = a.split("-")
|
||||
for b in logicFile:
|
||||
items_List1 = isAttorVar(hierarchy, logicFile[b]["Items-1"])
|
||||
items_List2 = isAttorVar(hierarchy, logicFile[b]["Items-2"])
|
||||
|
||||
print(items_List1)
|
||||
print(items_List2)
|
||||
|
||||
# Convert String Attributes to DNA Index number, and String Variants to Order number. Variant == 0 if Empty given.
|
||||
num_List1 = items_to_num(hierarchy, items_List1)
|
||||
# ^cannot go with:
|
||||
num_List2 = items_to_num(hierarchy, items_List2)
|
||||
|
||||
if logicFile[b]["Rule"] == "Never with":
|
||||
rand_bool = random.getrandbits(1) == 0
|
||||
if rand_bool == 0:
|
||||
for c in num_List2:
|
||||
deconstructed_DNA[c] = '0'
|
||||
rand_bool = bool(random.getrandbits(1))
|
||||
|
||||
if rand_bool == 1:
|
||||
for c in num_List1:
|
||||
deconstructed_DNA[c] = '0'
|
||||
if rand_bool:
|
||||
deconstructed_DNA = rar_selectVar(hierarchy, items_List2, deconstructed_DNA)
|
||||
|
||||
if not rand_bool:
|
||||
deconstructed_DNA = rar_selectVar(hierarchy, items_List1, deconstructed_DNA)
|
||||
|
||||
if logicFile[b]["Rule"] == "Only with":
|
||||
for c in list(num_List2.keys()):
|
||||
|
@ -98,9 +134,9 @@ def logicafyDNAList(DNAList, hierarchy, logicFile):
|
|||
LogicDNAList_deconstructed.append(deconstructed_DNA)
|
||||
|
||||
LogicDNAList = []
|
||||
|
||||
for a in LogicDNAList_deconstructed:
|
||||
reconstructed_DNA = ""
|
||||
print(a)
|
||||
for b in a:
|
||||
num = "-" + str(b)
|
||||
reconstructed_DNA += num
|
||||
|
|
|
@ -6,20 +6,17 @@
|
|||
# This file returns the specified meta data format to the Exporter.py for a given NFT DNA.
|
||||
|
||||
import bpy
|
||||
import os
|
||||
import sys
|
||||
import importlib
|
||||
import json
|
||||
|
||||
|
||||
def returnCardanoMetaData(name, NFT_DNA, NFT_Variants):
|
||||
# Cardano Template
|
||||
def returnCardanoMetaData(name, NFT_DNA, NFT_Variants, custom_Fields_File, enableCustomFields, cardano_description):
|
||||
metaDataDictCardano = {"721": {
|
||||
"<policy_id>": {
|
||||
name: {
|
||||
"name": name,
|
||||
"image": "",
|
||||
"mediaType": "",
|
||||
"description": "",
|
||||
|
||||
"description": cardano_description,
|
||||
}
|
||||
},
|
||||
"version": "1.0"
|
||||
|
@ -28,10 +25,17 @@ def returnCardanoMetaData(name, NFT_DNA, NFT_Variants):
|
|||
for i in NFT_Variants:
|
||||
metaDataDictCardano["721"]["<policy_id>"][name][i] = NFT_Variants[i]
|
||||
|
||||
# Custom Fields:
|
||||
if enableCustomFields:
|
||||
custom_Fields = json.load(open(custom_Fields_File))
|
||||
for i in custom_Fields:
|
||||
metaDataDictCardano["721"]["<policy_id>"][name][i] = custom_Fields[i]
|
||||
|
||||
return metaDataDictCardano
|
||||
|
||||
def returnSolanaMetaData(name, NFT_DNA, NFT_Variants):
|
||||
metaDataDictSolana = {"name": name, "symbol": "", "description": "", "seller_fee_basis_points": None,
|
||||
# Solana Template
|
||||
def returnSolanaMetaData(name, NFT_DNA, NFT_Variants, custom_Fields_File, enableCustomFields, solana_description):
|
||||
metaDataDictSolana = {"name": name, "symbol": "", "description": solana_description, "seller_fee_basis_points": None,
|
||||
"image": "", "animation_url": "", "external_url": ""}
|
||||
|
||||
attributes = []
|
||||
|
@ -44,6 +48,16 @@ def returnSolanaMetaData(name, NFT_DNA, NFT_Variants):
|
|||
|
||||
attributes.append(dictionary)
|
||||
|
||||
# Custom Fields:
|
||||
if enableCustomFields:
|
||||
custom_Fields = json.load(open(custom_Fields_File))
|
||||
for i in custom_Fields:
|
||||
dictionary = {
|
||||
"trait_type": i,
|
||||
"value": custom_Fields[i]
|
||||
}
|
||||
attributes.append(dictionary)
|
||||
|
||||
metaDataDictSolana["attributes"] = attributes
|
||||
metaDataDictSolana["collection"] = {
|
||||
"name": "",
|
||||
|
@ -57,10 +71,11 @@ def returnSolanaMetaData(name, NFT_DNA, NFT_Variants):
|
|||
}
|
||||
return metaDataDictSolana
|
||||
|
||||
def returnErc721MetaData(name, NFT_DNA, NFT_Variants):
|
||||
# ERC721 Template
|
||||
def returnErc721MetaData(name, NFT_DNA, NFT_Variants, custom_Fields_File, enableCustomFields, erc721_description):
|
||||
metaDataDictErc721 = {
|
||||
"name": name,
|
||||
"description": "",
|
||||
"description": erc721_description,
|
||||
"image": "",
|
||||
"attributes": None,
|
||||
}
|
||||
|
@ -75,6 +90,16 @@ def returnErc721MetaData(name, NFT_DNA, NFT_Variants):
|
|||
|
||||
attributes.append(dictionary)
|
||||
|
||||
# Custom Fields:
|
||||
if enableCustomFields:
|
||||
custom_Fields = json.load(open(custom_Fields_File))
|
||||
for i in custom_Fields:
|
||||
dictionary = {
|
||||
"trait_type": i,
|
||||
"value": custom_Fields[i]
|
||||
}
|
||||
attributes.append(dictionary)
|
||||
|
||||
metaDataDictErc721["attributes"] = attributes
|
||||
|
||||
return metaDataDictErc721
|
||||
|
|
Ładowanie…
Reference in New Issue