0

I have an invalid syntax error and the space is highlighted at the asterisk

"* modifier macrodetails/Caucasian ' + str(CaucasianQuotient) + '\n\"

I went through the whole thing multiple times, but I still don't know what is going wrong

ListOfBodyShape = ['Round', 'RoundBottom', 'RoundTop', 'RoundMuscular', 'MuscularBottom', 'MuscularTop', 'Muscular', 'TopBottom']
ListOfHeight = ['Medium', 'MediumShort', 'TallMedium', 'TallShort', 'Tall', 'Short']
ListOfHairStyle = ['Short', 'Long', 'CurlyShort', 'CurlyLong']
Gender = ['Male', 'Female']
ListOfAges = ['Child', 'Teen', 'Adult', 'Elder']

MuscleQuotient = 0
AfricanQuotient = 0
ProportionQuotient = 0
GenderQuotientQuotient = 0
HeightQuotient = 0
BreastSizeQuotient = 0
AgeQuotient = 0
BreastFirmnessQuotient = 0
AsianQuotient = 0
CaucasianQuotient = 0
WeightQuotient = 0

for a in range(len(ListOfBodyShape)):
    for b in range(len(ListOfHeight)):
        for c in range(len(ListOfHairStyle)):
            for d in range(len(Gender)):
                for e in range(len(ListOfAges)):
                    f = open(ListOfBodyShape[a] + ' ' + ListOfHeight[b] + ' ' + ListOfHairStyle[c] + ' ' + Gender[d] + ' ' + ListOfAges[e]  + '.mhm', 'w')

                    f.write('version v1.1.0\n\
                    tags untitled\n\
                    camera 6.0 347.5 -0.113847193662 0.694580827356 -0.399507358182 0.6375\n\
                    modifier macrodetails-universal/Muscle ' + str(MuscleQuotient) + '\n\
                    modifier macrodetails/African ' + str(AfricanQuotient) + '\n\
                    modifier macrodetails-proportions/BodyProportions '+ str(ProportionQuotient) +'\n\
                    modifier macrodetails/Gender ' str(GenderQuotient) + '\n\
                    modifier macrodetails-height/Height ' + str(HeightQuotient) + '\n\
                    modifier breast/BreastSize' + str(BreastSizeQuotient) + '\n\
                    modifier macrodetails/Age ' + str(AgeQuotient) + '\n\
                    modifier breast/BreastFirmness ' + str(BreastFirmnessQuotient) + '\n\
                    modifier macrodetails/Asian ' + str(AsianQuotient) + '\n\
                    modifier macrodetails/Caucasian ' + str(CaucasianQuotient) + '\n\
                    modifier macrodetails-universal/Weight ' + str(WeightQuotient) + '\n\
                    eyes HighPolyEyes 2c12f43b-1303-432c-b7ce-d78346baf2e6\n\
                    clothesHideFaces True\n\
                    skinMaterial skins/default.mhmat\n\
                    material HighPolyEyes 2c12f43b-1303-432c-b7ce-d78346baf2e6 eyes/materials/brown.mhmat\n\
                    subdivide False\n')
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

2 Answers2

2

A "+" sign is missing before the str in this line:

'modifier macrodetails/Gender ' str(GenderQuotient) + '\n\ "

Also use f.close() at the end.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
1

First, you should understand that you don't need ranges on your loops.

for a in range(len(ListOfBodyShape)): # a range
    x = ListOfBodyShape[a]  # get value with index

Is the exact same as

for x in ListOfBodyShape:  # get value

Sidenote: Python naming-conventions say not to start variables with capital letters


I would suggest not trying to write one large chunk of text.

I don't know what your output needs to look like, but Python has multiline strings, so you shouldn't write the \n yourself unless you need to.

Plus, \n\ isn't just a new line.

So start with this

f.write("""version v1.1.0
tags untitled
camera 6.0 347.5 -0.113847193662 0.694580827356 -0.399507358182 0.6375\n""")

And then I would recommend you use string formatting.

f.write("modifier macrodetails-universal/Muscle {}\n".format(MuscleQuotient))

And don't forget to use f.close()

Or you can do this

filename = "{} {} {} {} {}.mhm".format(ListOfBodyShape[a], ListOfHeight[b], ListOfHairStyle[c], Gender[d], ListOfAges[e])
with open(filename), 'w') as f:
    f.write(...)
# f.close() automatically
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245