0
$\begingroup$

I am trying to generate a list of global lDs and the material that is attached.

To get the global IDs I have tried:

objects_with_ID = [ob for ob in bpy.context.scene.objects if ob.IFC Object.GlobalId[1]]

enter image description here

$\endgroup$
3
  • $\begingroup$ I have tried the following but I receive a syntax error: 'code' import bpy for o in bpy.data.objects: if o.type=='MESH': material = o.active_material guid = o.GlobalId break 'code' $\endgroup$
    – Bedson
    Jun 9, 2020 at 9:48
  • $\begingroup$ I have also tried the following that returns the 'Name' of the property but not its 'Value': import bpy for o in bpy.data.objects: if o.type=='MESH': material = o.active_material.name Guid = o.BIMObjectProperties.attributes[1].name print(material) print(Guid) $\endgroup$
    – Bedson
    Jun 9, 2020 at 11:31
  • $\begingroup$ please copy and paste your error in your post. $\endgroup$ Jun 9, 2020 at 19:42

1 Answer 1

1
$\begingroup$

I managed to get it working:

import bpy
import csv
import os

outputFile = 'C:/Temp/0_IFCGuid_IFCMaterial.csv'
f = open(outputFile,'w')

for o in bpy.context.scene.objects:
    if o.type=='MESH':
        material = o.active_material.name
        global_id_index = o.BIMObjectProperties.attributes.find('GlobalId')
        guid = o.BIMObjectProperties.attributes[global_id_index].string_value
        print(guid)
        print(material)
        f.writelines(guid)
        f.writelines('\n')
        f.writelines(material)
        f.writelines('\n')
f.close()
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .