Merged hierarchy and variantMetaData together to form hierarchy and to simplify the data stored of each batch.

pull/1/head
Torrin Leonard 2021-10-21 22:38:00 -04:00
rodzic b86496abfb
commit d328067444
7 zmienionych plików z 195 dodań i 65 usunięć

Wyświetl plik

@ -46,15 +46,48 @@ def returnData():
attributeVariants = [x for x in listAllCollections if x not in attributeCollections]
attributeCollections1 = copy.deepcopy(attributeCollections)
def attributeData(attributeVariants):
allAttDataList = {}
for i in attributeVariants:
def getStr(i):
name_1 = re.sub(r'[^a-zA-Z]', "", i)
return name_1
def getOrder_rarity(i):
x = re.sub(r'[a-zA-Z]', "", i)
a = x.split("_")
del a[0]
return list(a)
name = getStr(i)
orderRarity = getOrder_rarity(i)
number = orderRarity[0]
rarity = orderRarity[1]
eachObject = {"name": name, "number": number, "rarity": rarity}
allAttDataList[i] = eachObject
return allAttDataList
variantMetaData = attributeData(attributeVariants)
def getChildren():
parentDictionary = {}
hierarchy = {}
for i in attributeCollections1:
colParLong = list(bpy.data.collections[str(i)].children)
colParShort =[]
colParShort = {}
for x in colParLong:
colParShort.append(x.name)
parentDictionary[i] = colParShort
return parentDictionary
colParShort[x.name] = None
hierarchy[i] = colParShort
for a in hierarchy:
for b in hierarchy[a]:
for x in variantMetaData:
if str(x) == str(b):
(hierarchy[a])[b] = variantMetaData[x]
return hierarchy
hierarchy = getChildren()
@ -69,56 +102,18 @@ def returnData():
possibleCombinations = numOfCombinations(hierarchy)
def attributeData(attributeVariants):
allAttDataList = {}
for i in attributeVariants:
def getParent(i):
parent = ""
for w in hierarchy:
listChild = hierarchy[w]
if i in listChild:
parent = w
return parent
def getStr(i):
name_1 = re.sub(r'[^a-zA-Z]', "", i)
return name_1
def getOrder_rarity(i):
x = re.sub(r'[a-zA-Z]', "", i)
a = x.split("_")
del a[0]
return list(a)
fullName = i
name = getStr(i)
orderRarity = getOrder_rarity(i)
number = orderRarity[0]
rarity = orderRarity[1]
parentCollection = getParent(i)
eachObject = {"fullName": fullName, "name": name, "number": number, "rarity": rarity, "parentCollection": parentCollection}
allAttDataList[fullName] = eachObject
return allAttDataList
variantMetaData = attributeData(attributeVariants)
for i in variantMetaData:
def cameraToggle(i,toggle = True):
bpy.data.collections[i].hide_render = toggle
bpy.data.collections[i].hide_viewport = toggle
cameraToggle(i)
return listAllCollections, attributeCollections, attributeCollections1, hierarchy, variantMetaData, possibleCombinations
listAllCollections, attributeCollections, attributeCollections1, hierarchy, variantMetaData, possibleCombinations = returnData()
return listAllCollections, attributeCollections, attributeCollections1, hierarchy, possibleCombinations
listAllCollections, attributeCollections, attributeCollections1, hierarchy, possibleCombinations = returnData()
def generateNFT_DNA(variantMetaData, possibleCombinations):
def generateNFT_DNA(possibleCombinations):
'''
:param variantMetaData: The variantMetaData
:return: the batch dictionary of the NFT's being created, there dna, and attributes
'''
batchDataDictionary = {}
@ -149,28 +144,23 @@ def generateNFT_DNA(variantMetaData, possibleCombinations):
#Data stored in batchDataDictionary:
batchDataDictionary["numNFTsGenerated"] = possibleCombinations
batchDataDictionary["hierarchy"] = hierarchy
batchDataDictionary["variantMetaData"] = variantMetaData
batchDataDictionary["DNAList"] = allDNAstr
return batchDataDictionary
DataDictionary = generateNFT_DNA(variantMetaData, possibleCombinations)
DataDictionary = generateNFT_DNA(possibleCombinations)
def sendToJSON():
print(DataDictionary)
def send_To_Record_JSON():
'''
Sends 'batchDataDictionary' dictionary to the NFTRecord.json file.
'''
file_name = os.path.join(save_path, "NFTRecord.json")
ledger = json.load(open(file_name))
num = 1
for i in ledger:
num += 1
ledger[num] = DataDictionary
ledger = json.dumps(DataDictionary, indent=1, ensure_ascii=True)
ledger = json.dumps(ledger, indent=1, ensure_ascii=True)
with open(file_name, 'w') as outfile:
with open(os.path.join(save_path, "NFTRecord.json"), 'w') as outfile:
outfile.write(ledger + '\n')
print("")
print("All possible combinations of DNA sent to NFTRecord.json with " + str(possibleCombinations) + "\nNFT DNA sequences generated in %.4f seconds" % (time.time() - time_start))
print("")
@ -179,7 +169,7 @@ def sendToJSON():
print("༼ ºل͟º ༼ ºل͟º ༼ ºل͟º ༽ ºل͟º ༽ ºل͟º ༽")
print("")
#sendToJSON()
send_To_Record_JSON()
'''Utility functions:'''

BIN
NFTCozy.blend 100644

Plik binarny nie jest wyświetlany.

143
NFTRecord.json 100644
Wyświetl plik

@ -0,0 +1,143 @@
{
"numNFTsGenerated": 64,
"hierarchy": {
"AreaLight": {
"BobisAlive_1_0": {
"name": "BobisAlive",
"number": "1",
"rarity": "0"
},
"AreaLight_2_0": {
"name": "AreaLight",
"number": "2",
"rarity": "0"
}
},
"Cube": {
"Cube_1_0": {
"name": "Cube",
"number": "1",
"rarity": "0"
},
"Cube_2_0": {
"name": "Cube",
"number": "2",
"rarity": "0"
}
},
"Curve": {
"Curve_1_0": {
"name": "Curve",
"number": "1",
"rarity": "0"
},
"Curve_2_0": {
"name": "Curve",
"number": "2",
"rarity": "0"
}
},
"PointLight": {
"PointLight_1_0": {
"name": "PointLight",
"number": "1",
"rarity": "0"
},
"PointLight_2_0": {
"name": "PointLight",
"number": "2",
"rarity": "0"
}
},
"Sphere": {
"Sphere_1_0": {
"name": "Sphere",
"number": "1",
"rarity": "0"
},
"Sphere_2_0": {
"name": "Sphere",
"number": "2",
"rarity": "0"
}
},
"Text": {
"Text_1_0": {
"name": "Text",
"number": "1",
"rarity": "0"
},
"Text_2_0": {
"name": "Text",
"number": "2",
"rarity": "0"
}
}
},
"DNAList": [
"1-1-1-1-1-1",
"1-1-1-1-1-2",
"1-1-1-1-2-1",
"1-1-1-1-2-2",
"1-1-1-2-1-1",
"1-1-1-2-1-2",
"1-1-1-2-2-1",
"1-1-1-2-2-2",
"1-1-2-1-1-1",
"1-1-2-1-1-2",
"1-1-2-1-2-1",
"1-1-2-1-2-2",
"1-1-2-2-1-1",
"1-1-2-2-1-2",
"1-1-2-2-2-1",
"1-1-2-2-2-2",
"1-2-1-1-1-1",
"1-2-1-1-1-2",
"1-2-1-1-2-1",
"1-2-1-1-2-2",
"1-2-1-2-1-1",
"1-2-1-2-1-2",
"1-2-1-2-2-1",
"1-2-1-2-2-2",
"1-2-2-1-1-1",
"1-2-2-1-1-2",
"1-2-2-1-2-1",
"1-2-2-1-2-2",
"1-2-2-2-1-1",
"1-2-2-2-1-2",
"1-2-2-2-2-1",
"1-2-2-2-2-2",
"2-1-1-1-1-1",
"2-1-1-1-1-2",
"2-1-1-1-2-1",
"2-1-1-1-2-2",
"2-1-1-2-1-1",
"2-1-1-2-1-2",
"2-1-1-2-2-1",
"2-1-1-2-2-2",
"2-1-2-1-1-1",
"2-1-2-1-1-2",
"2-1-2-1-2-1",
"2-1-2-1-2-2",
"2-1-2-2-1-1",
"2-1-2-2-1-2",
"2-1-2-2-2-1",
"2-1-2-2-2-2",
"2-2-1-1-1-1",
"2-2-1-1-1-2",
"2-2-1-1-2-1",
"2-2-1-1-2-2",
"2-2-1-2-1-1",
"2-2-1-2-1-2",
"2-2-1-2-2-1",
"2-2-1-2-2-2",
"2-2-2-1-1-1",
"2-2-2-1-1-2",
"2-2-2-1-2-1",
"2-2-2-1-2-2",
"2-2-2-2-1-1",
"2-2-2-2-1-2",
"2-2-2-2-2-1",
"2-2-2-2-2-2"
]
}

Wyświetl plik

@ -4,11 +4,10 @@
# The number of NFTs desired to be minted:
numNFTs = 96
batch_file_name = 'Batch1'
nftsPerBatch = None
# The path to the "Blender_Image_Generator" file
save_path = '/Users/torrinleonard/Desktop/Blender_Image_Generator'
json_save_path = '/Users/torrinleonard/Desktop/Blender_Image_Generator/Json-folder'
batch_path = '/Users/torrinleonard/Desktop/Blender_Image_Generator/Json-folder/{}'.format(batch_file_name)
save_path = '/Users/torrinleonard/Desktop/Blend_My_NFTs'
batch_path = '/Users/torrinleonard/Desktop/Blend_My_NFTs/Batch_Json_files'
images_path = '/Users/torrinleonard/Desktop/Blend_My_NFTs/Images from PNG Generator'

Wyświetl plik

@ -1,2 +0,0 @@
{
}