Phsion Posted April 29 Share Posted April 29 I'm looping over every lighting device and trying to pull all the data. Everything works except getting parameters added via the "File> Document Settings> Spotlight Preferences" menu. If I add "User Field 7" it doesn't show up in my info. Can anyone point me in the right direction? Currently running something like: vs.ForEachObject( load_data, "( (PON='LIGHTING DEVICE') & (V) )") def load_data(h): phandle = vs.GetParametricRecord(h) recname = vs.GetName(phandle) record = vs.GetObject(recname) field_count = vs.NumFields(phandle) this_data = {} for x in range(0, field_count): fname = vs.GetFldName(record,x) data = vs.GetRField(h, recname, fname) this_data[fname.lower()] = data Thanks! Quote Link to comment
Letti R Posted April 30 Share Posted April 30 Hello, maybe the data is stored in another record that is also attached to the object. If i want an overview of all the records (as far as i know) that are attached to an object i use the function below (im not sure if this function works with "ForEachObject", but i think you are going to modify this code anyways): def get_all_record_fields(object_handle) -> list: number_of_records_attached_to_object = vs.NumRecords(object_handle) all_record_fields = [] for i in range(number_of_records_attached_to_object): temp_record_handle = vs.GetRecord(object_handle, i + 1) temp_record_name = vs.GetName(temp_record_handle) temp_number_of_fields_in_record = vs.NumFields(temp_record_handle) for j in range(temp_number_of_fields_in_record): temp_field_name = vs.GetFldName(temp_record_handle, j + 1) temp_field_accuracy = vs.GetFldFlag(temp_record_handle, j + 1) temp_field_type = vs.GetFldType(temp_record_handle, j + 1) temp_is_field_empty, temp_is_data_linked = vs.GetRFieldOpt(object_handle, temp_record_name, temp_field_name) temp_field_value = vs.GetRField(object_handle, temp_record_name, temp_field_name) temp_record_field_dict = { "object_handle" : object_handle, "record_name" : temp_record_name, "record_handle" : temp_record_handle, "field_name" : temp_field_name, "field_accuracy" : temp_field_accuracy, "field_type" : temp_field_type, "is_field_empty" : temp_is_field_empty, "is_data_linked" : temp_is_data_linked, "field_value" : temp_field_value } all_record_fields.append(temp_record_field_dict) return(all_record_fields) Regards, Letti Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.