How to set the right terminal when creating connectivity associations with attribute rules

506
3
Jump to solution
08-03-2022 12:22 PM
PeterStampfl
New Contributor II

Hi,

this is my attribute rule. It seems to work fine, but i can not set the right terminal. I tried different things but I get always errors.

Expression

if ($feature.assetgroup == 1001) {
var update_class = 'ElectricDevice'
var filterDevice = "ASSETGROUP = 854 And DIRECTION = 'Voeding OV'"

var boundaries = FeatureSetByName($datastore, "FLUVIUS_109_DESIGN2.UTARC.StructureBoundary", ["globalid"], true);
if(isempty(boundaries)){
return;
//{"errorMessage": "Error 1"};
};

var intersectBoundaries = Intersects(boundaries, $feature);
if(isempty(intersectBoundaries)){
return;
//{"errorMessage": "Error 2"};
};

var structureBoundary = First(intersectBoundaries);
if(isempty(structureBoundary)){
return;
//{"errorMessage": "Error 3"};
}

var AllDevices = FeatureSetByName($datastore, "FLUVIUS_109_DESIGN2.UTARC.ElectricDevice", ["assetgroup", "globalid"], true);
if(isempty(AllDevices)){
return;
//{"errorMessage": "Error 4"};
}

var XYDevice = Filter(AllDevices, filterDevice)
if(isempty(XYDevice)){
return;
//{"errorMessage": "Error 5"};
};

var intersectDevice = Intersects(XYDevice, structureBoundary);
if(isempty(intersectBoundaries)){
return;
//{"errorMessage": "Error 6"};
};

var DeviceGeo = First(intersectDevice)
if(isempty(DeviceGeo)){
return;
//{"errorMessage": "Error 7"};
}


return {
"edit":
[
{"className": update_class,
"updates":[{"globalid": DeviceGeo.globalid,
"FROMTERMINALID": 13,
"associationType":"connected"}]}
]
}
}

 

 

I have tried:

-"fromTerminal": "13"

PeterStampfl_1-1659553935836.png

- "fromTerminal": 13

PeterStampfl_2-1659553960114.png

- "FROMTERMINALID": 13

I get a association without error but, I have topology errors and the terminal is set FromTerminalID 1 ToTerminalID 1

PeterStampfl_3-1659554294320.png

 

The association rule looks like this:

PeterStampfl_4-1659554326519.png

 

Thank you for your help!

 

0 Kudos
1 Solution

Accepted Solutions
HusseinNasser2
Esri Contributor

Think of the dictionary you are authoring as creating an association from $feature to whatever feature you specified in the update_class. Specifying FROMTERMINAL means here you are trying to create an association from the $feature so that terminal should exist on that feature. 

 

If the terminal you are connecting to is at the device then use ToTerminal. and you can safely use the string name 

A blog detailing this can be found here. 

https://www.esri.com/arcgis-blog/products/utility-network/electric-gas/advanced-attribute-rules-crea...

 

As Mike said, you can also use  ^UN_Association if you want more control. (create associations between two assets other than $feature. 

 

Hope that helps

View solution in original post

0 Kudos
3 Replies
MikeMillerGIS
Esri Frequent Contributor

The terminal id needs to be set on the line class, not the device.  If you are trying to create an association, you need to use ^UN_Association

https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/attribute-rule-dictionary-k...

0 Kudos
HusseinNasser2
Esri Contributor

Think of the dictionary you are authoring as creating an association from $feature to whatever feature you specified in the update_class. Specifying FROMTERMINAL means here you are trying to create an association from the $feature so that terminal should exist on that feature. 

 

If the terminal you are connecting to is at the device then use ToTerminal. and you can safely use the string name 

A blog detailing this can be found here. 

https://www.esri.com/arcgis-blog/products/utility-network/electric-gas/advanced-attribute-rules-crea...

 

As Mike said, you can also use  ^UN_Association if you want more control. (create associations between two assets other than $feature. 

 

Hope that helps

0 Kudos
PeterStampfl
New Contributor II

It worked with that retun statement:

return {
"edit":
[
{"className": UpdateClass,
"updates":[{
"globalid": DeviceGeo.globalid,
"fromTerminal": fromTerm,
"toTerminal": toTerm,
"associationType":"connected"}]
}
]
}

0 Kudos