|
POST
|
I think plain, vanilla JavaScript is preferable, unless you have a specific need for functionality provided by a framework (like React, Vue, Angular, etc.).
... View more
03-14-2023
03:36 PM
|
1
|
0
|
4111
|
|
POST
|
If the field is a date type, then Python will read the value as a datetime object (at least it does with data access cursors). You can use the .year attribute to get only the year portion of a datetime object. my_date_field.year
... View more
02-21-2023
06:59 AM
|
0
|
1
|
8942
|
|
POST
|
Thank you for sharing your thoughts. It does indeed list all versions, including grandchild and replica versions. The version objects include the immediate child (not grandchildren), parent version, and ancestors (parent lineage all the way up to default). So it is possible to break up the versions logically. I did a test where I posted a sample of child versions but only reconciled the rest. The versions were grouped by parent, but that seems unnecessary at the moment. Eventually, we will post all direct children of Default and only reconcile everything else so that's why I have it that way. versions_to_post = [
"QAQC_LIS.QAQC_LIS",
"QAQC_GPS.QAQC_GPS",
"QAQC_UTILITIES.QAQC_UTILITIES"
]
versions = defaultdict(list)
for v in arcpy.da.ListVersions(sde_egdb_conn):
if v.name != "SDE.DEFAULT":
versions[v.parentVersionName].append(v.name)
for version_parent, version_list in versions.items():
v_to_reconcile = [v for v in version_list if v not in versions_to_post]
if v_to_reconcile:
print(f"\nReconcile {len(v_to_reconcile)} versions with {version_parent}")
arcpy.management.ReconcileVersions(
input_database=sde_egdb_conn,
reconcile_mode="ALL_VERSIONS",
target_version=version_parent,
edit_versions=v_to_reconcile,
acquire_locks="NO_LOCK_ACQUIRED",
abort_if_conflicts="NO_ABORT",
conflict_definition="BY_OBJECT",
conflict_resolution="FAVOR_TARGET_VERSION",
with_post="NO_POST",
with_delete="KEEP_VERSION"
)
# Post
v_to_post = [v for v in version_list if v in versions_to_post]
if v_to_post:
print(f"\nPost {len(v_to_post)} versions to {version_parent}")
arcpy.management.ReconcileVersions(
input_database=sde_egdb_conn,
reconcile_mode="ALL_VERSIONS",
target_version=version_parent,
edit_versions=v_to_post,
acquire_locks="LOCK_ACQUIRED",
abort_if_conflicts="ABORT_CONFLICTS",
conflict_definition="BY_OBJECT",
conflict_resolution="FAVOR_TARGET_VERSION",
with_post="POST",
with_delete="KEEP_VERSION"
) This was successful and posted changes in a QAQC version to Default. @Anonymous User, do you have any automated post operations in your organization?
... View more
02-06-2023
06:51 AM
|
0
|
1
|
1109
|
|
POST
|
That is my observation as well. It seems ArcGIS Pro makes some kind of temporary copy of the connection file while the app is open. However, I've been able to do everything I need with this connection file (short of knowing where the original sde file is).
... View more
02-02-2023
12:39 PM
|
0
|
0
|
4465
|
|
POST
|
I haven't tested it with broken data sources. I'm not sure how it would handle that.
... View more
02-02-2023
11:02 AM
|
0
|
0
|
4487
|
|
POST
|
I used Describe import arcpy
import os
def getWorkspaceInfo(map_layer):
"""Takes an input map layer object and returns a dictionary with workspace information.
"""
try:
# Get workspace of input map layer
workspace_path = arcpy.Describe(map_layer).catalogPath
# Walk up the catalogPath until it's at the connection file.
while not workspace_path.endswith('.sde'):
if workspace_path == os.path.dirname(workspace_path):
# You've reached the end (beginning) of the path.
raise OSError("This catalogPath does not have an sde connection file.")
workspace_path = os.path.dirname(workspace_path)
workspace_desc = arcpy.Describe(workspace_path)
workspace_instance = workspace_desc.connectionProperties.instance
workspace_version = workspace_desc.connectionProperties.version
# Get only the portion of the instance after the last colon character.
# This might not be necessary depending on your rdbms.
workspace_instance = workspace_instance.rsplit(":", 1)[1]
if workspace_instance and workspace_version:
return {
"workspace_path": workspace_path,
"workspace_instance": workspace_instance,
"workspace_version": workspace_version
}
else:
# workspace_instance or workspace_version is missing.
raise AttributeError(f"workspace_instance is {workspace_instance}; workspace_version is {workspace_version}")
except Exception as e:
raise arcpy.ExecuteError(
f"Unable to get workspace instance and version from map_layer {map_layer.name}"
) from e
# Get workspace path to .sde file
workspace_info = getWorkspaceInfo(my_map_layer_obj)
workspace_path = workspace_info["workspace_path"]
... View more
02-02-2023
10:58 AM
|
1
|
2
|
4492
|
|
POST
|
Our enterprise geodatabase (10.8.1) on Oracle has a variety of versions. Some children of Default, some are grandchildren. We have a Python script that does reconcile, compress, rebuild indexes, and analyze stats operations. When reconciling the versions, I want to post only a few specified versions; all other versions are only reconciled (no post). Are there any special considerations when doing this? For example, do I need to make sure that the farthest ancestor versions are reconciled first? Do the versions being posted need to be reconciled/posted last, after everything else has been reconciled? Or am I over thinking this and the reconcile tool takes care of all that? The documentation is very simplistic. Before the only example with one reconcile that posts everything, it says that, This tool is a means to achieve an effective compression, as it allows multiple versions to be reconciled and posted at once in an appropriate order. I am running the Python script with ArcGIS Pro 3.0.3
... View more
01-31-2023
02:09 PM
|
0
|
3
|
1337
|
|
POST
|
You could either hard code the path (if it's a shared toolbox) or have an additional input parameter on your tool where the user can browse to the toolbox.
... View more
01-09-2023
01:14 PM
|
0
|
1
|
3441
|
|
POST
|
Double post. See Correct Codeblock Python syntax for CalculateField - Esri Community
... View more
01-09-2023
08:20 AM
|
0
|
1
|
3998
|
|
POST
|
@CCWeedcontrol, there are some gaps in the explanation of your logic there, but here's another take on evaluating your progress field. I organized evaluation of the larger groups separately to make the evaluation of the progress field a little easier to follow. Please correct as needed to clarify logic gaps. # Get arcpy.da cursor rows back as dictionary with field names
# https://arcpy.wordpress.com/2012/07/12/getting-arcpy-da-rows-back-as-dictionaries/
def rows_as_dicts(cursor):
colnames = cursor.fields
for row in cursor:
yield dict(zip(colnames, row))
fields = [
"reviewField1",
"reviewField12",
"reviewField3",
"reviewField4",
"EventField",
"EventRes1",
"Certif",
"CertifDate",
"ProgressFiledField"
]
where = "AppType = 'SFR Active'"
with arcpy.da.UpdateCursor(table1, fields, where) as cursor:
for row in rows_as_dicts(cursor):
# Evaluate Review fields
review_approved_count = [
row["reviewField1"],
row["reviewField12"],
row["reviewField3"],
row["reviewField4"]
].count("Approved")
# Evaluate Event
eventField = row["EventField"]
if eventField in ["Foundation", "Setback", "Shear Panel 1"]:
event_state = "Foundation"
elif eventField in ["Framing" or "BC- Framing"]:
event_state = "Framing"
elif eventField in ["Insulation" or "Stucco"]:
event_state = "Insulation"
elif eventField in ["Final"]:
event_state = "Final"
else:
raise Exception(f"EventField value {eventField} not handled.")
# Evaluate eventRes1
eventRes1 = row["EventRes1"]
if eventRes1 in ["Needs corrections", "In progress", "partial Pass", "Cancelled"]:
eventRes1_state = "Not Passed"
elif eventRes1 == "Pass":
eventRes1_state = "Pass"
else:
raise Exception(f"EventRes1 value {eventRes1} not handled.")
# Evaluate Progress
progress_filed = row["ProgressFiledField"]
if review_approved_count == 4:
if event_state == "Foundation":
# Doesn't matter what EventRes1 is?
progress_filed = "15%"
elif event_state == "Framing":
if eventRes1_state == "Passed":
progress_filed = "50%"
else:
# eventRes1 not passed
progress_filed = "25%"
elif event_state == "Insulation":
if eventRes1_state == "Passed":
progress_filed = "75%"
else:
# eventRes1 not passed
progress_filed = "50%"
elif event_state == "Final":
if eventRes1_state == "Passed":
progress_filed = "100%"
else:
# eventRes1 not passed
progress_filed = "75%"
else:
# review_approved_count < 4 and
# doesn't matter what EventField or EventRes1 are.
progress_filed = "0%"
# These dates override all other logic evaluations?
if row["Certif"] and row["CertifDate"]:
progress_filed = "100%"
# Update row with progress.
row["ProgressFiledField"] = progress_filed
row_values = list(row.values())
cursor.updateRow(row_values)
... View more
01-09-2023
07:45 AM
|
2
|
0
|
4091
|
|
POST
|
@NephtaliChavez wrote: That path is to a folder saved on the cloud(onedrive), which I'm not sure if that's an issue. Is that different from how you run it? Does it work for you with a OneDrive path?
... View more
01-09-2023
06:05 AM
|
0
|
3
|
3457
|
|
POST
|
Installing ArcGIS (ArcMap or Pro) includes a full install of Python (2.x for ArcMap, 3.x for Pro). There's no need to install Python if you've already installed ArcGIS.
... View more
01-04-2023
09:02 AM
|
0
|
0
|
4066
|
|
POST
|
You wouldn't use arcpy, you would use the subprocess module built into Python. https://stackoverflow.com/a/5469427
... View more
01-04-2023
08:13 AM
|
2
|
2
|
4094
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-23-2025 03:53 PM | |
| 1 | 04-28-2026 07:25 AM | |
| 1 | 03-19-2026 08:59 AM | |
| 1 | 02-12-2026 01:37 PM | |
| 1 | 12-01-2025 06:19 AM |