When the parameter is feature class I can filter the input to polyline only. How to do this when the input is layer file at CURRENT MXD? I'm looking for something that will operate before the script starts running. I'm using Layer file so the user can choose the input from the data frame at the current MXD.


3 Answers 3


Try this:

  • Set the Data Type for your input feature to be Feature Layer. Then you can apply a Feature Class filter as shown in the image below.

enter image description here

  • If your mxd has polyline features, you will get a drop down list: enter image description here
  • if no polyline features present in mxd, you will get this: enter image description here
  • Thanks Dan, but my data type is Layer file and not feature class. is it possible to do this limitation for Layer file ? I'm using Layer file so the user can choose the input from the data frame at his current MXD Commented Jul 31, 2013 at 11:52
  • Yea, set it up as shown above and it will do what you want!It will filter out layer files from the current mxd based on their geometry type
    – Nxaunxau
    Commented Jul 31, 2013 at 11:57

if you add any description to your layers, you can use following code:

import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
lyrs = arcpy.mapping.ListDataFrames(mxd)[0]
for lyr in arcpy.mapping.ListLayers(mxd, "",lyrs):
    if lyr.description== "polyline":

i hope it helps you...

  • Thanks Aragon for your help, but is it possible to limit the possible of the user to select layers that are not polyline ? as same as the input filter does. Commented Jul 31, 2013 at 8:29

try this bit of code within the python window to limit your processing to polyline features only.

mxd = arcpy.mapping.MapDocument("CURRENT")
lyrs = arcpy.mapping.ListLayers(mxd)

for lyr in lyrs:
    if lyr.supports("DATASOURCE"):
        descLYR = arcpy.Describe(lyr.dataSource)
        if descLYR.shapeType = "Polyline":
            #do stuff here
  • this code does the same thing Aragon suggest, but it doesn't limit the user possible to see only polylines and choose before he insert the input, that is because the check for layer geometry starts after the user press OK and run the script - I'm looking for something that will operate before that Commented Jul 31, 2013 at 9:42
  • try adding tool validation to your script tool resources.arcgis.com/en/help/main/10.1/index.html#/…
    – Nxaunxau
    Commented Jul 31, 2013 at 9:48
  • At script properties, Validation tab, the datatype attribute for parameter doesn't let you choose geometry type, what is the attribute for that ? [Link] (resources.arcgis.com/en/help/main/10.1/index.html#//…) Commented Jul 31, 2013 at 9:55
  • @sepideh Please try to keep comments relevant to the post.
    – Aaron
    Commented Apr 14, 2016 at 0:24

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.