Need help converting ArcMap attribute assistant rule to ArcGIS Pro Attribute Rules

768
4
Jump to solution
02-02-2023 02:48 PM
Keith_McKinnon
New Contributor III

I have two attribute assistant rules that extract a unique ID from a point feature class that intersects with either the starting point (SP) or end point (EP) of a line and fill that value into a field in the line feature class.  I am not able to find any documentation about an Attribute Rule in ArcGIS Pro that replicates this functionality.  Any help would be appreciated.

Attribute assistant rules:

https://solutions.arcgis.com/shared/help/attribute-assistant/documentation/methods-intersecting-feat...

wwManhole,wwCleanOut,wwNetworkStructure,wwValve|uniqueid|SP|False

wwManhole,wwCleanOut,wwNetworkStructure,wwValve|uniqueid|EP|False

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

OK.

For the start point:

// Calculation Attribute Rule on the line fc
// field: upstreammanhole
// triggers: insert(, update)

// load the manholes
var manholes = FeaturesetByName($datastore, "Database.DataOwner.Manholes", ["uniqueID"], false)

// get the line's start point
var p = Geometry($feature).paths[0][0]

// find the intersecting manhole
var manhole = First(Intersects(p, manholes))

// return a default value if no manhole intersects, else return the manhole's uniqueID
return IIf(manhole == null, null, manhole.uniqueID)

 

 

For the end point, copy the rule and replace line 9:

var p = Geometry($feature).paths[-1][-1]

 

 

You can also do both points in one rule. To do that, leave the field parameter of the Attribute RUle empty.

// Calculation Attribute Rule on the line fc
// field: empty!
// triggers: insert(, update)

// load the manholes
var manholes = FeaturesetByName($datastore, "Database.DataOwner.Manholes", ["uniqueID"], false)

// get the line's start and end points
var start = Geometry($feature).paths[0][0]
var end = Geometry($feature).paths[-1][-1]

// find the intersecting manholes
var start_manhole = First(Intersects(start, manholes))
var end_manhole = First(Intersects(end, manholes))

// instead of returning a value, return a dictionary
return {
    result: {
        attributes: {
            upstreammanhole: IIf(start_manhole == null, null, start_manhole.uniqueID),
            downstreammanhole: IIf(end_manhole == null, null, end_manhole.uniqueID),
            }
        }
    }

Have a great day!
Johannes

View solution in original post

4 Replies
JohannesLindner
MVP Frequent Contributor

Can points intersect the line only at the end vertices or anywhere else, too?

If both start and end vertex intersect a point, which point's value do you want to return?


Have a great day!
Johannes
0 Kudos
Keith_McKinnon
New Contributor III

Points will intersect at both ends.  One rule should grab the point at the starting point.  Then other rule should grab the end point.

 

We want to grab data from [uniqueID] of the point and populate [upstreammanhole] (starting vertex) and [downstreammanhole] (end vertex) in the line.

 

Thanks,

Keith

0 Kudos
JohannesLindner
MVP Frequent Contributor

OK.

For the start point:

// Calculation Attribute Rule on the line fc
// field: upstreammanhole
// triggers: insert(, update)

// load the manholes
var manholes = FeaturesetByName($datastore, "Database.DataOwner.Manholes", ["uniqueID"], false)

// get the line's start point
var p = Geometry($feature).paths[0][0]

// find the intersecting manhole
var manhole = First(Intersects(p, manholes))

// return a default value if no manhole intersects, else return the manhole's uniqueID
return IIf(manhole == null, null, manhole.uniqueID)

 

 

For the end point, copy the rule and replace line 9:

var p = Geometry($feature).paths[-1][-1]

 

 

You can also do both points in one rule. To do that, leave the field parameter of the Attribute RUle empty.

// Calculation Attribute Rule on the line fc
// field: empty!
// triggers: insert(, update)

// load the manholes
var manholes = FeaturesetByName($datastore, "Database.DataOwner.Manholes", ["uniqueID"], false)

// get the line's start and end points
var start = Geometry($feature).paths[0][0]
var end = Geometry($feature).paths[-1][-1]

// find the intersecting manholes
var start_manhole = First(Intersects(start, manholes))
var end_manhole = First(Intersects(end, manholes))

// instead of returning a value, return a dictionary
return {
    result: {
        attributes: {
            upstreammanhole: IIf(start_manhole == null, null, start_manhole.uniqueID),
            downstreammanhole: IIf(end_manhole == null, null, end_manhole.uniqueID),
            }
        }
    }

Have a great day!
Johannes
Keith_McKinnon
New Contributor III

Much obliged, Johannes.

0 Kudos