@CobraLAD The following script will not in any way disparage your accomplishment. Scripting in Excel is a world that I never worked with. So hats off to you.
Some weeks ago I wrote for my own purpose a python script with a similar destination. And because not all people like macros in MS Office or LibreOffice I decided to show the script here. I adapted it to @CobraLAD's destination in this thread. In my eyes the script is self explanatory with the additional comments. Set the variables to your need or adapt the script to your need.
There is no special license to it, but telling the source of the original would be nice.
The script works in blender python scripting workspace as well as in other Python installations.
The resulting textfile looks like follows
"]
Of course I try to answer any question to it.
Some weeks ago I wrote for my own purpose a python script with a similar destination. And because not all people like macros in MS Office or LibreOffice I decided to show the script here. I adapted it to @CobraLAD's destination in this thread. In my eyes the script is self explanatory with the additional comments. Set the variables to your need or adapt the script to your need.
There is no special license to it, but telling the source of the original would be nice.
The script works in blender python scripting workspace as well as in other Python installations.
Code:
import sys,os
# ==============================================================================================
# For https://forums.auran.com/threads/tool-to-create-tables-in-config-file.176963 by ek.skirl
# ==============================================================================================
filepath = os.path.expanduser("~/Desktop/") # Here the file is stored at the desktop
filename = "queue_container_list.txt" # with the name queue_container_list.txt
queuebasename = "queue" # Used for queue tag name followed by a running number
# ----------------------------------------------------------------------------------------------
# The delimiter symbol is here '?' but may be setted in the variable.
# One or more blanks before and after the delimiter possible
# List entry format 1: "<kuid...>?name?queuesize",
# List entry format 2: "<kuid...>?queuesize?name",
# List entry format 3: "<kuid...>?queuesize",
# List entry format 4: "<kuid...>?name", with setted queuesize
# List entry format 5: "<kuid...>", with setted queuesize
# ----------------------------------------------------------------------------------------------
queuesize = 256
delimiter = " "
format = 4
withkuidlist = True # The sub container "allowed-products" contains the kuids? (False/True)
# ----------------------------------------------------------------------------------------------
assetlist = [ # --------------------------------------------------------------------------------
"<kuid2:215489:110001:1> aCTS PRODUCT CATEGORY Container 10ft sc",
"<kuid:215489:100065> New Route",
"<kuid2:215489:110002:2> aCTS PRODUCT CATEGORY Container 10ft hc",
"<kuid:215489:100066> New Route - Default",
"<kuid:215489:100054> REGISTERING ROUTE",
"<kuid:215489:100055> REGISTERING SESSION - Empty",
"<kuid2:215489:1100200:1> aCTS CONTAINER Texture Group V1",
] # --------------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------
tagnamesize = "size "
tagnameprod = "product-kuid "
tagnameicnt = "inital-count 0"
allprod = "allowed-products"
# ----------------------------------------------------------------------------------------------
indent = " "
# ==============================================================================================
cr ="""
"""
cr1indent =cr+indent
cr2indent =cr1indent+indent
cr3indent =cr2indent+indent
# ----------------------------------------------------------------------------------------------
rnr = 0
allowedproductslist = ""
for s in assetlist:
pos1 = s.find(">")
allowedproductslist += cr3indent+str(rnr)+indent+indent+s[:pos1+1].strip()
rnr += 1
rnr = 0
file = open(filepath+filename, "w")
sys.stdout = file # Set standard stdout to file
for s in assetlist:
pos1 = s.find(">")
trainzkuid = s[:pos1+1].strip()
size = queuesize
if format == 1: # List entry format 1: "<kuid...>?name?queuesize",
pos2 = s.rfind(" ")
size = int(s[pos2:])
# name = s[pos1+1:pos2].strip()
elif format == 2: # List entry format 2: "<kuid...>?queuesize?name",
pos2 = s.find(" ",pos1)
size = int(s[pos2:])
# name = s[pos2:].strip()
elif format == 3: # List entry format 3: "<kuid...>?queuesize",
size = int(s[pos1:])
elif format == 4: # List entry format 4: "<kuid...>?name", with setted queuesize
# name = s[pos1+1:].strip()
xxx = 123 # Dummy instruction for syntax purpose only
rnr += 1
text = indent+queuebasename+str(rnr)+cr1indent+"{"+cr2indent
text += tagnamesize+str(size)+cr2indent
text += tagnameprod+trainzkuid+cr2indent
text += tagnameicnt+cr2indent
text += allprod+cr2indent+"{"
if withkuidlist: text += allowedproductslist
text += cr2indent+"}"
text += cr1indent+"}"+cr
print(text)
file.close()
sys.stdout = sys.__stdout__ # Reset to standard stdout
# ==============================================================================================
Code:
queue1
{
size 256
product-kuid <kuid2:215489:110001:1>
inital-count 0
allowed-products
{
0 <kuid2:215489:110001:1>
1 <kuid:215489:100065>
2 <kuid2:215489:110002:2>
3 <kuid:215489:100066>
4 <kuid:215489:100054>
5 <kuid:215489:100055>
6 <kuid2:215489:1100200:1>
}
}
queue2
{
size 256
product-kuid <kuid:215489:100065>
inital-count 0
allowed-products
{
0 <kuid2:215489:110001:1>
1 <kuid:215489:100065>
2 <kuid2:215489:110002:2>
3 <kuid:215489:100066>
4 <kuid:215489:100054>
5 <kuid:215489:100055>
6 <kuid2:215489:1100200:1>
}
}
queue3
{
size 256
product-kuid <kuid2:215489:110002:2>
inital-count 0
allowed-products
{
0 <kuid2:215489:110001:1>
1 <kuid:215489:100065>
2 <kuid2:215489:110002:2>
3 <kuid:215489:100066>
4 <kuid:215489:100054>
5 <kuid:215489:100055>
6 <kuid2:215489:1100200:1>
}
}
queue4
{
size 256
product-kuid <kuid:215489:100066>
inital-count 0
allowed-products
{
0 <kuid2:215489:110001:1>
1 <kuid:215489:100065>
2 <kuid2:215489:110002:2>
3 <kuid:215489:100066>
4 <kuid:215489:100054>
5 <kuid:215489:100055>
6 <kuid2:215489:1100200:1>
}
}
queue5
{
size 256
product-kuid <kuid:215489:100054>
inital-count 0
allowed-products
{
0 <kuid2:215489:110001:1>
1 <kuid:215489:100065>
2 <kuid2:215489:110002:2>
3 <kuid:215489:100066>
4 <kuid:215489:100054>
5 <kuid:215489:100055>
6 <kuid2:215489:1100200:1>
}
}
queue6
{
size 256
product-kuid <kuid:215489:100055>
inital-count 0
allowed-products
{
0 <kuid2:215489:110001:1>
1 <kuid:215489:100065>
2 <kuid2:215489:110002:2>
3 <kuid:215489:100066>
4 <kuid:215489:100054>
5 <kuid:215489:100055>
6 <kuid2:215489:1100200:1>
}
}
queue7
{
size 256
product-kuid <kuid2:215489:1100200:1>
inital-count 0
allowed-products
{
0 <kuid2:215489:110001:1>
1 <kuid:215489:100065>
2 <kuid2:215489:110002:2>
3 <kuid:215489:100066>
4 <kuid:215489:100054>
5 <kuid:215489:100055>
6 <kuid2:215489:1100200:1>
}
}
Last edited: