kopia lustrzana https://github.com/torrinworx/Blend_My_NFTs
Deprecated "slash" variable
rodzic
8e4f45647c
commit
c4bd40ae19
|
@ -57,7 +57,7 @@ def makeBatches():
|
|||
|
||||
batchDictionaryObject = json.dumps(batchDictionary, indent=1, ensure_ascii=True)
|
||||
|
||||
with open(config.batch_json_save_path + config.slash + ("Batch{}.json".format(i + 1)), "w") as outfile:
|
||||
with open(os.path.join(config.batch_json_save_path, ("Batch{}.json".format(i + 1))), "w") as outfile:
|
||||
outfile.write(batchDictionaryObject)
|
||||
|
||||
i += 1
|
||||
|
@ -74,7 +74,7 @@ def makeBatches():
|
|||
|
||||
incompleteBatch = json.dumps(incompleteBatch, indent=1, ensure_ascii=True)
|
||||
|
||||
with open(config.batch_json_save_path + config.slash + ("Batch{}.json".format(i + 1)), "w") as outfile2:
|
||||
with open(os.path.join(config.batch_json_save_path, ("Batch{}.json".format(i + 1))), "w") as outfile2:
|
||||
outfile2.write(incompleteBatch)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -63,7 +63,7 @@ def generate3DModels():
|
|||
hierarchy = {}
|
||||
|
||||
for i in attributeList:
|
||||
file_unfiltered = os.listdir(config.modelAssetPath + config.slash + i)
|
||||
file_unfiltered = os.listdir(os.path.join(config.modelAssetPath, i))
|
||||
add_to_hierarchy = [x for x in file_unfiltered if x not in removeList]
|
||||
hierarchy[i] = add_to_hierarchy
|
||||
|
||||
|
@ -103,13 +103,13 @@ def generate3DModels():
|
|||
for h in Script_Ignore_Folder:
|
||||
fileName, fileExtension = os.path.splitext(h)
|
||||
if fileExtension == ".glb":
|
||||
bpy.ops.import_scene.gltf(filepath=config.model_Script_Ignore_Path + config.slash + h)
|
||||
bpy.ops.import_scene.gltf(filepath=os.path.join(config.model_Script_Ignore_Path, h))
|
||||
elif fileExtension == ".fbx":
|
||||
bpy.ops.import_scene.fbx(filepath=config.model_Script_Ignore_Path + config.slash + h)
|
||||
bpy.ops.import_scene.fbx(filepath=os.path.join(config.model_Script_Ignore_Path, h))
|
||||
elif fileExtension == ".obj":
|
||||
bpy.ops.import_scene.obj(filepath=config.model_Script_Ignore_Path + config.slash + h)
|
||||
bpy.ops.import_scene.obj(filepath=os.path.join(config.model_Script_Ignore_Path, h))
|
||||
elif fileExtension == ".x3d":
|
||||
bpy.ops.import_scene.obj(filepath=config.model_Script_Ignore_Path + config.slash + h)
|
||||
bpy.ops.import_scene.obj(filepath=os.path.join(config.model_Script_Ignore_Path, h))
|
||||
|
||||
for j in i:
|
||||
def getParent(hierarchy):
|
||||
|
@ -119,7 +119,7 @@ def generate3DModels():
|
|||
return x
|
||||
|
||||
parent = getParent(hierarchy)
|
||||
path2 = config.modelAssetPath + config.slash + parent + config.slash + j
|
||||
path2 = os.path.join(config.modelAssetPath, parent, j)
|
||||
fileName, fileExtension = os.path.splitext(j)
|
||||
|
||||
if fileExtension == ".glb":
|
||||
|
@ -132,16 +132,16 @@ def generate3DModels():
|
|||
bpy.ops.import_scene.obj(filepath=path2)
|
||||
|
||||
if config.modelFileFormat == 'glb':
|
||||
bpy.ops.export_scene.gltf(filepath=config.model_save_path + config.slash + config.nftName + str(count),
|
||||
bpy.ops.export_scene.gltf(filepath=os.path.join(config.model_save_path, config.nftName + str(count)),
|
||||
check_existing=True, export_format='GLB')
|
||||
elif config.modelFileFormat == 'fbx':
|
||||
bpy.ops.export_scene.fbx(filepath=config.model_save_path + config.slash + config.nftName + str(count),
|
||||
bpy.ops.export_scene.fbx(filepath=os.path.join(config.model_save_path, config.nftName + str(count)),
|
||||
check_existing=True)
|
||||
elif config.modelFileFormat == 'obj':
|
||||
bpy.ops.export_scene.obj(filepath=config.model_save_path + config.slash + config.nftName + str(count),
|
||||
bpy.ops.export_scene.obj(filepath=os.path.join(config.model_save_path, config.nftName + str(count)),
|
||||
check_existing=True)
|
||||
elif config.modelFileFormat == 'x3d':
|
||||
bpy.ops.export_scene.x3d(filepath=config.model_save_path + config.slash + config.nftName + str(count),
|
||||
bpy.ops.export_scene.x3d(filepath=os.path.join(config.model_save_path, config.nftName + str(count)),
|
||||
check_existing=True)
|
||||
deleteAllObjects()
|
||||
count += 1
|
||||
|
|
|
@ -63,9 +63,10 @@ def imageRenderTest():
|
|||
|
||||
print(renderMaxTime)
|
||||
|
||||
os.remove(config.batch_json_save_path + config.slash + "Batch1.json")
|
||||
os.remove(config.save_path + config.slash + "NFTRecord.json")
|
||||
shutil.rmtree(config.nft_save_path + config.slash + "Batch1")
|
||||
os.remove(os.path.join(config.batch_json_save_path, "Batch1.json"))
|
||||
os.remove(os.path.join(config.save_path, "NFTRecord.json"))
|
||||
shutil.rmtree(os.path.join(config.nft_save_path, "Batch1"))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
imageRenderTest()
|
||||
|
|
|
@ -2,9 +2,13 @@
|
|||
# This file determines the settings of your NFT collection. Please read the README.md file to understand how to run this
|
||||
# program.
|
||||
|
||||
nftName = '' # The name of the NFT image produces by PNG-Generator
|
||||
nftName = 'Test' # The name of the NFT image produces by PNG-Generator
|
||||
|
||||
imageFileFormat = '' # Dictate the image extension when Blender renders the images
|
||||
maxNFTs = 10 # The maximum number of NFTs you want to generate.
|
||||
nftsPerBatch = 10 # Number of NFTs per batch (Batches split maxNFTs into smaller manageable chunks)
|
||||
renderBatch = 1 # The batch number to render in Exporter.py
|
||||
|
||||
imageFileFormat = 'PNG' # Dictate the image extension when Blender renders the images
|
||||
# Type the exact name provided below in the '' above:
|
||||
# JPEG - Exports the .jpeg format
|
||||
# PNG - Exports the .png format
|
||||
|
@ -31,7 +35,7 @@ modelFileFormat = '' # The file format of the objects you would like to export
|
|||
# for a complete list of object formats supported by Blender.
|
||||
|
||||
# The path to Blend_My_NFTs folder:
|
||||
save_path_mac = ''
|
||||
save_path_mac = '/Users/torrinleonard/Desktop/ThisCozyStudio/Blend_My_NFTs'
|
||||
save_path_linux = ''
|
||||
save_path_windows = r''
|
||||
# Place the path in the '', e.g: save_path_mac = '/Users/Path/to/Blend_My_NFTs'
|
||||
|
@ -39,10 +43,6 @@ save_path_windows = r''
|
|||
# Example linux: /Users/Path/to/Blend_My_NFTs
|
||||
# Example windows: C:\Users\Path\to\Blend_My_NFTs
|
||||
|
||||
maxNFTs = 0 # The maximum number of NFTs you want to generate.
|
||||
nftsPerBatch = 0 # Number of NFTs per batch (Batches split maxNFTs into smaller manageable chunks)
|
||||
renderBatch = 0 # The batch number to render in Exporter.py
|
||||
|
||||
# Set to True to generate images or 3D models depending on your settings below when main.py is run in Blender. Only works
|
||||
# if you have already generated NFTRecord.json and all batches.
|
||||
enableExporter = False
|
||||
|
@ -142,30 +142,27 @@ checkRarity = False
|
|||
|
||||
# Utilities - DO NOT TOUCH:
|
||||
import platform
|
||||
import os
|
||||
|
||||
# Save_path utilities and os compatibility
|
||||
mac = 'Darwin'
|
||||
linux = 'Linux'
|
||||
windows = 'Windows'
|
||||
slash = ''
|
||||
save_path = None
|
||||
|
||||
# Save_path utilities and os compatibility
|
||||
if platform.system() == mac:
|
||||
save_path = save_path_mac
|
||||
slash = '/'
|
||||
elif platform.system() == linux:
|
||||
save_path = save_path_linux
|
||||
slash = '/'
|
||||
elif platform.system() == windows:
|
||||
save_path = save_path_windows
|
||||
slash = '\\'
|
||||
|
||||
# Paths to folders
|
||||
batch_json_save_path = save_path + slash + 'Batch_Json_files' # The output path for batches generated by Batch_Sorter.py
|
||||
nft_save_path = save_path + slash + 'NFT_Output' # The output path for images generated by Exporter.py
|
||||
modelAssetPath = save_path + slash + "3D_Model_Input" # The input path for 3D models
|
||||
model_save_path = save_path + slash + "3D_Model_Output" # The output path for 3D models generated by Model_Generator.py
|
||||
model_Script_Ignore_Path = modelAssetPath + slash + "Script_Ignore_Folder" # The path to the Script_Ignore_Folder for 3D models
|
||||
batch_json_save_path = os.path.join(save_path, 'Batch_Json_files') # The output path for batches generated by Batch_Sorter.py
|
||||
nft_save_path = os.path.join(save_path, 'NFT_Output') # The output path for images generated by Exporter.py
|
||||
modelAssetPath = os.path.join(save_path, "3D_Model_Input") # The input path for 3D models
|
||||
model_save_path = os.path.join(save_path, "3D_Model_Output") # The output path for 3D models generated by Model_Generator.py
|
||||
model_Script_Ignore_Path = os.path.join(modelAssetPath, "Script_Ignore_Folder") # The path to the Script_Ignore_Folder for 3D models
|
||||
|
||||
# error handling #
|
||||
if modelFileFormat not in ['fbx', 'glb', 'obj', 'x3d'] and enable3DModels:
|
||||
|
|
Ładowanie…
Reference in New Issue