Hello,
I am using parts of this script at this link Parcel Fabric Active Record Automation - Esri Community suggested by @KenGalliher1 . I've pasted an extract of my script below. The code works when there is an active record set in the map like this
and returns the id as expected, however once I turn off the active record like this
using the toggle and re run this code, the same record_id for the 'TEST' record is still returned. I only want the record_id returned when in fact there is an active record. It appears that the cim properties are somehow being cached.
Is there a better way to check for an active record or is this a bug with the cim properties? And help would be much appreciated. Thank you
current_project = arcpy.mp.ArcGISProject('current')
# Get the active map
target_map = current_project.activeMap
map_layers = target_map.listLayers()
parcel_layer = [lyr for lyr in map_layers if lyr.isParcelFabricLayer][0]
# get parcel fabric cim properties to return active record
parcel_cim_def = parcel_layer.getDefinition("v3")
cim_properties = [v for v in dir(parcel_cim_def.parcelFabricActiveRecord) if not v.startswith("_")]
active_record = parcel_cim_def.parcelFabricActiveRecord.activeRecord
record_id = str.upper(active_record)
Solved! Go to Solution.
Hi Jessica,
Chris here with the parcel team. Thanks for your question.
You're right, it might make more sense if the ActiveRecord CIM properties returned a NULL object if there is no active record in the map. We will do some internal review on this.
But there is a pretty straight forward way to return a record GUID if the record is actually active.
There is a boolean property called enabled that will be True if the record is active and False if it is not.
You can make use of this property to return the GUID, only if the record is active, like so:
current_project = arcpy.mp.ArcGISProject('current')
# Get the active map
target_map = current_project.activeMap
map_layers = target_map.listLayers()
parcel_layer = [lyr for lyr in map_layers if lyr.isParcelFabricLayer][0]
# get parcel fabric cim properties to return active record
parcel_cim_def = parcel_layer.getDefinition("v3")
cim_properties = [v for v in dir(parcel_cim_def.parcelFabricActiveRecord) if not v.startswith("_")]
active_record = parcel_cim_def.parcelFabricActiveRecord.activeRecord
record_id = str.upper(active_record)
# added logic to only return a record GUID if record is enabled (active)
if parcel_cim_def.parcelFabricActiveRecord.enabled:
print("Record is active in current map. The GUID is: ", record_id)
else:
print("There is no active record")
I also made a quick video showing the behavior.
@Jessica_Watson That makes sense.
We will look into it
Hi Jessica,
Chris here with the parcel team. Thanks for your question.
You're right, it might make more sense if the ActiveRecord CIM properties returned a NULL object if there is no active record in the map. We will do some internal review on this.
But there is a pretty straight forward way to return a record GUID if the record is actually active.
There is a boolean property called enabled that will be True if the record is active and False if it is not.
You can make use of this property to return the GUID, only if the record is active, like so:
current_project = arcpy.mp.ArcGISProject('current')
# Get the active map
target_map = current_project.activeMap
map_layers = target_map.listLayers()
parcel_layer = [lyr for lyr in map_layers if lyr.isParcelFabricLayer][0]
# get parcel fabric cim properties to return active record
parcel_cim_def = parcel_layer.getDefinition("v3")
cim_properties = [v for v in dir(parcel_cim_def.parcelFabricActiveRecord) if not v.startswith("_")]
active_record = parcel_cim_def.parcelFabricActiveRecord.activeRecord
record_id = str.upper(active_record)
# added logic to only return a record GUID if record is enabled (active)
if parcel_cim_def.parcelFabricActiveRecord.enabled:
print("Record is active in current map. The GUID is: ", record_id)
else:
print("There is no active record")
I also made a quick video showing the behavior.
Thank you, @Chris-Zemp , this worked.