For a project I have to extract the rgb data in a file which is defined as following:
#98=IFCCOLOURRGB($,0.26,0.22,0.18);
I've been using regex and with help from here I came up with this;
IfcColourData = re.compile("IFCCOLOURRGB\(\$,([\d\.]+),([\d\.]+),([\d\.]+)")
It outputs:
('0.26', '0.22', '0.18')
Now how do I get rid of the parentheses and apostrophes when writing to a file or printing to the console?
I want to output it like this:
0.26 0.22 0.18
Edit:
This is the code:
import re
IfcFile = open('IfcOpenHouse.ifc', 'r')
IfcColourData = re.compile("IFCCOLOURRGB\(\$,([\d\.]+),([\d\.]+),([\d\.]+)")
RadFile = open('IFC2RAD.rad', 'w')
for RadColourData in IfcFile:
RGB_Data = IfcColourData.search(RadColourData)
if RGB_Data:
print(RGB_Data.groups())
RadFile.write('mod material name' + '\n')
RadFile.write('0' + '\n')
RadFile.write('0' + '\n')
RadFile.write(str(RGB_Data.groups()) + '\n' + '\n')
#Closing IFC and RAD files
IfcFile.close()
RadFile.close()