This question already has an answer here:
I have a Python script for ArcGIS that makes a new feature class. I can add this to ArcGIS as a new Script (without parameters), however the resulting feature class is not automatically added to the map layers. How does this happen? Here is an example of my Python script:
import os import arcgisscripting out_feat_class = 'out.shp' workspace = r'C:\temp' os.chdir(workspace) gp = arcgisscripting.create(9.3) gp.toolbox = 'management' gp.workspace = workspace # Create feature class gp.CreateFeatureclass(workspace, out_feat_class, 'POINT') # Add a field to it gp.AddField(out_feat_class, 'Value', 'DOUBLE') # Get insert cursor rows = gp.InsertCursor(out_feat_class) feat = rows.NewRow() # Set attribute data feat.SetValue('Value', 123.45) # Set geometry ptObj = gp.CreateObject('Point') ptObj.x = 101.224 ptObj.y = 442.440 feat.Shape = ptObj # Add to feature class rows.InsertRow(feat) # Done, clean up del ptObj, feat, rows
There are no errors, a feature class is made, but it does not automatically appear in the map. I'm using ArcGIS 10.0, but I'd like this to be backwards compatible with ArcGIS 9.3.