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.
- 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.
- If your mxd has polyline features, you will get a drop down list:
- if no polyline features present in mxd, you will get this:
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) for lyr in arcpy.mapping.ListLayers(mxd, "",lyrs): if lyr.description== "polyline": ....
i hope it helps you...
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