Attribute rule in python

2294
7
Jump to solution
02-09-2021 06:22 AM
kirken
by
New Contributor III

Is there any way how to set attribute rule using python expression instead of Arcade???

 

Thanks

0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

Hi @kirken ,

To confirm Dan's suspicion, Attribute Rules will only work with Arcade expressions. You cannot create an attribute rule using Python as the expression. The link shared by @DanPatterson before uses Python to configure the Attribute Rule, but inside it is still using the Arcade expression defined as a string inside the Python script.

In short, if you want to use Attribute Rules you will always need Arcade...

View solution in original post

7 Replies
DanPatterson
MVP Esteemed Contributor

Well yes and no.

You can use a python script to use an Arcade expression.  See the example here

Add Attribute Rule (Data Management)—ArcGIS Pro | Documentation

 


... sort of retired...
JoeBorgione
MVP Emeritus

Is that actually used to fire a rule or just add one?

That should just about do it....
0 Kudos
DanPatterson
MVP Esteemed Contributor

both... python is the delivery... attribute rule is the package 😁 Like Amazon (python home range)


... sort of retired...
0 Kudos
kirken
by
New Contributor III

Ok. I meant more like writing the script expression of the rule in python because it is quite complicated and currently uses some python libraries but I  guess i have to learn that arcade now..

0 Kudos
DanPatterson
MVP Esteemed Contributor

I don't think arcade imports python libraries


... sort of retired...
0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @kirken ,

To confirm Dan's suspicion, Attribute Rules will only work with Arcade expressions. You cannot create an attribute rule using Python as the expression. The link shared by @DanPatterson before uses Python to configure the Attribute Rule, but inside it is still using the Arcade expression defined as a string inside the Python script.

In short, if you want to use Attribute Rules you will always need Arcade...

BrittanyBurson
Occasional Contributor III

@XanderBakker looking for a way to use Attribute Rules to refresh lat/long fields after a point is moved. Right now we must do this manually with Calculate Geometry tool, and I am seeing it is possible to do it with Python, but I can't use Python to calc an Attribute Rule. I also can't use Arcade to translate into lat/long unless it is in Web Mercator... (we are using State Plane).... thoughts anyone?

0 Kudos