I have a model which creates topology with rules and validate itself. But I got used to working with layers in TOC and have a script in Calculate value tool that with a help of Parse path tool make a string output with feature dataset path in. Here is a script:

def GetPath(lyr):
    import os
    return target.dataSource

And here is a part of model I want to be working. enter image description here

Unfortunately, Create topology tool requires path not to some output value or variable, but probably direct file path. That is a reason for crashing of model due to the non-existance of dataset parameter.

Anyway is it possible to make an Input Feature dataset as a variable which records a path from string data? In my case it should be like %FDS%.

  • When you complete the Calculate Value tool what do you set the output type to?
    – Hornbydd
    Commented Nov 1, 2016 at 11:52
  • @Hornbydd Variant. I tried Feature Dataset, but it makes model crashing, because it still finds a path to layer, not dataset. Commented Nov 1, 2016 at 12:23
  • Defining the calculate variable as Feature Dataset and removing parse path, did you try output_value for the topology in dataset?
    – artwork21
    Commented Nov 1, 2016 at 12:36
  • @artwork21 I tried but it calculates a path to layer, not dataset. Commented Nov 1, 2016 at 12:42
  • Is your GetPath(lyr) call lyr variable a string of the layer name in ArcMap?
    – artwork21
    Commented Nov 1, 2016 at 12:50

1 Answer 1

  1. Set Calculate Value output to be FeatureDataset
  2. Remove Parse path tool
  3. Replace you code with the following:
def GetPath(lyr):
    import arcpy,string

    # Get FULL path
    path = featureLayer.dataSource

    # Get FeatureClass name
    fc = featureLayer.datasetName

    # Get index position of featureclass name in full path, -1 strips off \
    idx = string.rfind(path,fc) - 1

    # Return FeatureDataset
    return path[:idx]
  1. Connect tool to create Topology tool
  • everything is ok when I launch this model from model builder window. But when I launch it from the Catalog it crashes. The reason is a feature class, a path to which I calculate also through Calculate Value tool that has Feature class output. Topology is created right in Dataset I need but "Add feature class to topology" doesn't react on Calculate Value tool or something like %Feature dataset%\tline; it wants to add "tline" taken from the last launch of model within ModelBuilder interface. Commented Nov 3, 2016 at 7:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.