Hello, I am playing around on getting the events of changed elements. I successfully captured the Ids, Category, Families of wall, doors and windows, but on floor, instead of getting the floor itself as one entitiy, i am getting the individual line on sketch mode. Does anyone have a solid advise on how to do this? Here’s the output in question:
Here’s my code:
def add_element_log(custom_path):
""" added element log """
if doc.IsFamilyDocument:
sys.exit()
else:
# ✅ main code
add_filepath = custom_path
username = os.environ['USERNAME']
computer_name = os.environ['COMPUTERNAME']
cur_time = datetime.now()
date = str(cur_time.strftime("%d-%m-%y"))
time = str(cur_time.strftime("%H:%M:%S"))
model = EXEC_PARAMS.event_args.GetDocument().Title
added_element_ids = EXEC_PARAMS.event_args.GetAddedElementIds() # ICollection of element ids
coll_elements = [doc.GetElement(el) for el in added_element_ids]
trans_name = list(EXEC_PARAMS.event_args.GetTransactionNames())
with open(add_filepath, 'a') as f:
writer = csv.writer(f)
if not os.path.isfile(add_filepath) or os.stat(add_filepath).st_size == 0:
headings = [
'Model',
'Element',
'Element Type',
'Family',
'Category',
'Element Id',
'Added by',
'Computer Number',
'Date',
'Time',
'Transaction Name'
]
writer.writerow(headings)
try:
for el in coll_elements:
if el:
el_id = el.GetTypeId()
el_type = doc.GetElement(el_id)
el_type = el_type.get_Parameter(BuiltInParameter.ALL_MODEL_FAMILY_NAME)
el_cat = el.get_Parameter(BuiltInParameter.ELEM_CATEGORY_PARAM)
el_fam = el.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM)
for trans in trans_name:
row_data = [
model,
el.Name,
el_type.AsValueString() if el_type else '',
el_fam.AsValueString() if el_fam else '',
el_cat.AsValueString() if el_cat else '',
el.Id,
username,
computer_name,
date,
time,
trans
]
writer.writerow(row_data)
except:
pass
thanks in advance!