Select to view content in your preferred language

Wanting to assign IDS to Asssets automatically

188
1
06-05-2024 12:01 PM
DevarsiMajumder
New Contributor II

We have an emergency GRID that is comprised of  250  squares each with its labeling feature and naming ID.  we have some Assets that fall within each grid and we would like to generate or make a script that would automatically recognize which grid square it is in and assign it an ID number.  Is there something like this that anyone knows of that we can use or plug and play?   Or is there a specific tool that we can use in Pro that does it? Thank you.

0 Kudos
1 Reply
ZachBodenner
MVP Regular Contributor

Most definitely! Here is an example of something similar I set up:

 

// Make the parcels layer available
var parks = FeatureSetByName($datastore, "epgdb.PARKS.Parks",['PARKNAME']);
 
// Determine if a newly created point falls within the boundary of any parcels
var inter = Intersects($Feature, parks);
 
// Identify the first parcel that the point falls within. This is necessary because some of our parcels are stacked on top of each other, but we only want to access a single PID
var inPark = first(inter);
 
// If the point falls within a parcel, write that parcel's PID into the new point's attribute. Otherwise, the attribute value remains <Null>
if (!IsEmpty(inPark)){
return proper(inPark.PARKNAME)
}

 

Basically, when a new tree gets created, this Attribute Rule code will

Step1: search our geodatabase for the feature class "Parks"

Step2 and 3: do a spatial intersect and get the park the tree falls within,

Step 4: return the park name. 

 

You can sub in any variable you need to in that return, plus if you need any other text elements, incrementing numbers, etc.

0 Kudos