Tim,
I had a question along this line. I have a model that creates a points table. I wanted to add the Make Route Event Layer tool to the model to create a segment from the points. the problem is when I create the GP service and run it, the points table is in "GPInMemoryWorkspace" so the "Make Route Event" does not see the point event to generate the segment. Can you think of a way around this? Can I point the tool to the in memory location? I exported the model to python. I have searched ESRI help but have not found anything on this subject.
# -*- coding: utf-8 -*- # --------------------------------------------------------------------------- # seg.py # Created on: 2015-10-22 10:41:12.00000 # (generated by ArcGIS/ModelBuilder) # Usage: seg <first_point> <end_point> <merge__3_> <points> <points_Events> # Description: # --------------------------------------------------------------------------- # Import arcpy module import arcpy # Load required toolboxes arcpy.ImportToolbox("E:/MDTAPPS/terry/ref segment.tbx") # Script arguments first_point = arcpy.GetParameterAsText(0) if first_point == '#' or not first_point: first_point = "E:\\MDTAPPS\\terry\\Default.gdb\\first_point" # provide a default value if unspecified end_point = arcpy.GetParameterAsText(1) if end_point == '#' or not end_point: end_point = "E:\\MDTAPPS\\terry\\Default.gdb\\end_point" # provide a default value if unspecified merge__3_ = arcpy.GetParameterAsText(2) if merge__3_ == '#' or not merge__3_: merge__3_ = "E:\\MDTAPPS\\terry\\Default.gdb\\merge" # provide a default value if unspecified points = arcpy.GetParameterAsText(3) if points == '#' or not points: points = "E:\\MDTAPPS\\terry\\Default.gdb\\points" # provide a default value if unspecified points_Events = arcpy.GetParameterAsText(4) if points_Events == '#' or not points_Events: points_Events = "points Events3" # provide a default value if unspecified # Local variables: first_point__2_ = first_point first_point_Event = first_point__2_ first_point_ev = first_point_Event Output_Event_Table_Properties = first_point_Event end_point__2_ = end_point end_point_Event = end_point__2_ end_point_ev = end_point_Event end_point_ev_View = end_point_ev Output_Event_Table_Properties__2_ = end_point_Event MDTGIS_ROUTES_LRM_RM = "MDTGIS.ROUTES_LRM_RM" MDTGIS_ROUTES_LRM_DC_MI = "MDTGIS.ROUTES_LRM_DC_MI" MDTGIS_ROUTES_LRM_DC_MI__2_ = "MDTGIS.ROUTES_LRM_DC_MI" Default_gdb = "E:\\MDTAPPS\\terry\\Default.gdb" MDTGIS_ROUTES_LRM_DC_MI__3_ = "MDTGIS.ROUTES_LRM_DC_MI" # Process: Calculate Field arcpy.CalculateField_management(first_point, "Corridor", "str(!Corridor!) + \"_\" + str(!RM!)", "PYTHON_9.3", "") # Process: Make Route Event Layer arcpy.MakeRouteEventLayer_lr(MDTGIS_ROUTES_LRM_RM, "ROUTE_ID", first_point__2_, "Corridor POINT beg_offset", first_point_Event, "", "ERROR_FIELD", "NO_ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT", "POINT") # Process: Locate Features Along Routes arcpy.LocateFeaturesAlongRoutes_lr(first_point_Event, MDTGIS_ROUTES_LRM_DC_MI, "CORRIDOR", "0 Meters", first_point_ev, Output_Event_Table_Properties, "FIRST", "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON") # Process: Calculate Field (2) arcpy.CalculateField_management(end_point, "Corridor", "str(!Corridor!) + \"_\" + str(!RM!)", "PYTHON_9.3", "") # Process: Make Route Event Layer (2) arcpy.MakeRouteEventLayer_lr(MDTGIS_ROUTES_LRM_RM, "ROUTE_ID", end_point__2_, "Corridor POINT end_offset", end_point_Event, "", "ERROR_FIELD", "NO_ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT", "POINT") # Process: Locate Features Along Routes (2) arcpy.LocateFeaturesAlongRoutes_lr(end_point_Event, MDTGIS_ROUTES_LRM_DC_MI__2_, "CORRIDOR", "0 Meters", end_point_ev, Output_Event_Table_Properties__2_, "FIRST", "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON") # Process: Make Table View arcpy.MakeTableView_management(end_point_ev, end_point_ev_View, "", "", "OBJECTID OBJECTID VISIBLE NONE;RID RID VISIBLE NONE;to_MEAS to_MEAS VISIBLE NONE;Distance Distance VISIBLE NONE;RM RM VISIBLE NONE") # Process: Merge arcpy.Merge_management("E:\\MDTAPPS\\terry\\Default.gdb\\first_point_ev;end_point_ev_View", merge__3_, "RID \"CORRIDOR\" true true false 10 Text 0 0 ,First,#,E:\\MDTAPPS\\terry\\Default.gdb\\first_point_ev,RID,-1,-1,end_point_ev_View,RID,-1,-1;from_MEAS \"from_MEAS\" true true false 0 Double 0 0 ,First,#,E:\\MDTAPPS\\terry\\Default.gdb\\first_point_ev,from_MEAS,-1,-1;to_MEAS \"to_MEAS\" true true false 0 Double 0 0 ,First,#,end_point_ev_View,to_MEAS,-1,-1") # Process: Table to Table arcpy.TableToTable_conversion(merge__3_, Default_gdb, "points", "", "RID \"CORRIDOR\" true true false 10 Text 0 0 ,First,#,E:\\MDTAPPS\\terry\\Default.gdb\\merge,RID,-1,-1;from_MEAS \"from_MEAS\" true true false 0 Double 0 0 ,First,#,E:\\MDTAPPS\\terry\\Default.gdb\\merge,from_MEAS,-1,-1;to_MEAS \"to_MEAS\" true true false 0 Double 0 0 ,First,#,E:\\MDTAPPS\\terry\\Default.gdb\\merge,to_MEAS,-1,-1", "") # Process: Make Route Event Layer (3) arcpy.MakeRouteEventLayer_lr(MDTGIS_ROUTES_LRM_DC_MI__3_, "CORRIDOR", points, "rid LINE from_MEAS to_MEAS", points_Events, "", "ERROR_FIELD", "NO_ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT", "POINT") # Process: Script1 arcpy.gp.toolbox = "E:/MDTAPPS/terry/ref segment.tbx"; # Warning: the toolbox E:/MDTAPPS/terry/ref segment.tbx DOES NOT have an alias. # Please assign this toolbox an alias to avoid tool name collisions # And replace arcpy.gp.Script1(...) with arcpy.Script1_ALIAS(...) arcpy.gp.Script1()
Sometimes, even though the tool works properly, the temporary feature class is not added into the TOC. Is there some way to connect to and add data from the In_memory location?
Michael,
Are you using in_memory for convenience or for performance reasons?
If the tool isn't supporting in_memory input, you can always use %scratchGDB% instead of in_memory. %scratchGDB% maps to arcpy.env.scratchGDB which is guaranteed to be writable no matter the environment settings.