Hi folks, I posted a similar question back in October that has remained unanswered, and have seen this question before on Stack Exchange (arcpy - How to pass only selected features in python toolbox - Geographic Information Systems Stack ...) but found that the answer did not work. I've created a toolbox that will allow a user to select certain polygon features (in this case, grid squares from a LiDAR survey). The selection *should* then be then used to get the selected .LAS files (based on the name, extracted from the polygon feature) from a specified folder, and create an LAS Dataset. I have found that despite my best efforts, the script still does not recognize the user selection and tries to put ALL of the features in the polygon feature class into the LAS Dataset.
From what I've read, if a user has selected features from a feature class, a Search Cursor should just recognize that and will run on solely those features that were selected. For some reason this does not seem to be working for me. Any help appreciated. Also for what it's worth, I've tried doing the syntax highlighting for Python about 5 times and it refuses to post with it, so I apologize for that. Not sure what the deal is.
try
:
import
arcpy, sys, traceback, os.path
from
arcpy.sa
import
*
arcpy.env.overwriteOutput
=
1
arcpy.env.workspace
=
r
"C:\Users\Kate\GIS"
LASGridU
=
sys.argv[
1
]
LASLocationU
=
sys.argv[
2
]
LASDname
=
sys.argv[
3
]
spatialRefU
=
sys.argv[
4
]
count
=
0
sCursor
=
arcpy.SearchCursor(LASGridU)
LASList
=
[]
finalLAS
=
[]
for
row
in
sCursor:
LASList.append(
str
(row.getValue(
"LAS_File"
)))
count
+
=
1
for
las
in
LASList:
finalLAS.append(os.path.join(LASLocationU
+
"/"
+
las))
arcpy.AddMessage(LASList)
arcpy.AddMessage(finalLAS)
arcpy.CreateLasDataset_management(finalLAS, LASDname,"
","
",spatialRefU,"
COMPUTE_STATS
","
RELATIVE_PATHS")
print
count
del
row, sCursor
except
:
tb
=
sys.exc_info()[
2
]
tbinfo
=
traceback.format_tb(tb)[
0
]
pymsg
=
tbinfo
+
"\n"
+
str
(sys.exc_type)
+
": "
+
str
(sys.exc_value)
arcpy.AddError(pymsg)
arcpy.AddError(arcpy.GetMessages(
2
))