@Gorgious
Although I would try and uncouple the dataframe creation more from Blender's shenanigans so you could do :
https://blender.stackexchange.com/questions/191098/blender-python-how-to-call-a-class-or-function
I found this unanswered question on SO, I have class now I called:
class ConstructDataFrame(bpy.types.Operator):
"""Construct Dataframe"""
bl_idname = "object.construct_dataframe"
bl_label = "Object Operator Construct Dataframe"
def execute(self, context):
print("Construct DataFrame")
""" Does a lot of things like checking which buttons are checked to construct the dictionary"""
df = pd.DataFrame(ifc_dictionary)
df.to_csv(IfcStore.path.replace('.ifc','_blenderbim.csv'),sep=';')
print (IfcStore.path.replace('.ifc','_blenderbim.csv'))
return {'FINISHED'}
This class should be called in other class, should I register and unregister this class? Because when I try to call this class I do the following:
class WriteToXLSX(bpy.types.Operator):
"""Write IFC data to .xlsx"""
bl_idname = "object.write_to_xlsx"
bl_label = "Simple Object Operator"
def execute(self, context):
print("Write to .xlsx")
construct_data_frame = ConstructDataFrame(context)
#construct_data_frame.write_to_csv
for i in dir(construct_data_frame):
print (i)
I can see it finds all the methods with dir, but no csv is made.
When I try
construct_data_frame.execute
or any other method
I get this error
location: <unknown location>:-1
Error: Python: Traceback (most recent call last):
File "\BlenderBIMOpenOfficeXML.py", line 345, in execute
if not custom_pset_list:
File "C:\Program Files\Blender Foundation\Blender 3.0\3.0\scripts\modules\bpy_types.py", line 734, in __getattribute__
properties = StructRNA.path_resolve(self, "properties")
ValueError: Context.path_resolve("properties") could not be resolved
location: <unknown location>:-1