Add Topology via python to MXD

896
2
Jump to solution
04-19-2017 05:11 AM
TimWitt2
MVP Alum

Hello everybody,

I am creating a Python AddIn, that creates a topology, then adds a feature layer and rules to it. After I run the topology validation, I would like to add the topology to the mxd that is open.

When I set arcpy.env.addOutputsToMap to True, it adds the topology but before I add the rules,  features and validation. Is there any way to add the topology once everything is done?

Thanks,

Tim

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
TimWitt2
MVP Alum

Hey Ian,

I was able to turn addOutput to True before Add rule and Validate, which gave me the desired result. If that wouldn't have worked, I would have used ExportTopologyErrors_management and added the output feature layer to my mxd.

Tim

View solution in original post

2 Replies
IanMurray
Frequent Contributor

According to several older threads, you cannot directly add topology layers to a map using Arcpy.

https://gis.stackexchange.com/questions/116873/is-there-a-a-way-to-add-a-topology-dataset-to-an-mxd-...

https://community.esri.com/thread/93229

This begs the question though, clearly the geoprocessing operation can create a layer file of the Geoprocessing Result object of the geoprocessing operation, and that layer is clearly added to the map when you have the addOutputs to True in the environment variable. 

I wonder if there is a way to turn on the addOutput to True after you add the rules, features and validation, then recall the output or the result object in a way it would add it to the map.

bixb0012

TimWitt2
MVP Alum

Hey Ian,

I was able to turn addOutput to True before Add rule and Validate, which gave me the desired result. If that wouldn't have worked, I would have used ExportTopologyErrors_management and added the output feature layer to my mxd.

Tim