Skip to content

Commit

Permalink
Fixed parsing materials in Mesh2Rad
Browse files Browse the repository at this point in the history
  • Loading branch information
mostaphaRoudsari committed Jun 30, 2018
1 parent b5eb2b7 commit 34dfe34
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/Honeybee_Honeybee.py
Expand Up @@ -47,7 +47,7 @@

ghenv.Component.Name = "Honeybee_Honeybee"
ghenv.Component.NickName = 'Honeybee'
ghenv.Component.Message = 'VER 0.0.63\nJUN_02_2018'
ghenv.Component.Message = 'VER 0.0.63\nJUN_29_2018'
ghenv.Component.IconDisplayMode = ghenv.Component.IconDisplayMode.icon
ghenv.Component.Category = "Honeybee"
ghenv.Component.SubCategory = "00 | Honeybee"
Expand Down Expand Up @@ -1127,16 +1127,16 @@ def getRadianceObjectsFromString(radFileString):
Returns:
A list of strings. Each string represents a differnt Rdiance Object
"""

raw_rad_objects = re.findall(
r'^\s*([^0-9].*(\s*[\d|.]+.*)*)',
radFileString,
re.MULTILINE)

radObjects = (' '.join(radiance_object[0].split())
for radiance_object in raw_rad_objects)

radObjects = tuple(obj for obj in radObjects if obj and obj[0] != '#')

return radObjects

def getRadianceObjectsFromFile(self, radFilePath):
Expand Down Expand Up @@ -1438,17 +1438,15 @@ def __init__(self, mesh, fileName = None, workingDir = None, bitmap = None, radM
pass
else:
self.matName = "radMaterial"

if radMaterial != None:
radMaterial = RADMaterialAux.getRadianceObjectsFromString(radMaterial)[0]

try:
self.matName = radMaterial.split("\n")[0].split(" ")[-1].rstrip()
assert self.matName != ""
except:
raise Exception("Failed to import %s. Double check the material definition."%radMaterial)
self.RADMaterial = radMaterial

self.RADMaterial = " ".join(radMaterial.split())

def meshToObj(self):
objFilePath = os.path.join(self.workingDir, self.name + ".obj")
Expand Down Expand Up @@ -1551,13 +1549,13 @@ def objToRAD(self, objFile):
matFile = os.path.join(path, "material_" + fileName)

try:
materialType = self.RADMaterial.split("\n")[0].split(" ")[1]
materialTale = "\n".join(self.RADMaterial.split("\n")[1:])
materialType = self.RADMaterial.split()[1]
materialTale = " ".join(self.RADMaterial.split()[3:])
except Exception, e:
# to be added here: if material is not full string then get it from the library
print "material error..." + `e`
return

errmsg = "Failed to parse material:\n%s" % e
print errmsg
raise ValueError(errmsg)
# create material file
if self.pattern != None:

Expand All @@ -1578,7 +1576,7 @@ def objToRAD(self, objFile):
patternName + "_pattern " + materialType + " " + patternName + "\n" + \
materialTale
else:
materialStr = "void " + materialType + " " + self.matName + "\n" + \
materialStr = "void " + materialType + " " + self.matName + " " + \
materialTale

# write material to file
Expand Down
Binary file modified userObjects/Honeybee_Honeybee.ghuser
Binary file not shown.

0 comments on commit 34dfe34

Please sign in to comment.