Thanks you so much for your help, below is the code I am attempting to run from my VB.Net add-in:
Private Sub radioAddressPinParcel_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles radioAddressPinParcel.CheckedChanged
Try
If radioAddressPinParcel.Checked = True Then
Shell("C:\Python27\arcGIS10.2\python.exe ""C:\GIS\QualityCheck\QAQCComparison.py""", AppWinStyle.MinimizedNoFocus) ' arg1 arg2) ', AppWinStyle.MinimizedFocus, True, -1) ', Nothd:\path\to\your\script.py arg1 arg2")
End If
Catch ex As Exception
GISErrorEMail(Err.Description, Err.Source, Err.Erl, Err.HelpContext, Err.Number, "QualityCheck.QualityCheck.radio_CheckedChanged")
End Try
End Sub
***********************************************************************************
Below is the code I am in my arcpy script. Sorry I have not figured out how to post the code seperately.
***********************************************************************************
#QAQCComparison.py
import arcpy
import time
import csv
import os
try:
arcpy.env.workspace = "C:\Users\Documents\ArcGIS\Default1.gdb"
arcpy.env.overwriteOutput = True
#Remove PinParcelComparison Layer from ArcMap
mxd = arcpy.mapping.MapDocument("CURRENT")
#mxd = arcpy.mapping.MapDocument("C:\Program Files (x86)\ArcGIS\Desktop10.2\bin\ArcMap.exe")
df = arcpy.mapping.ListDataFrames(mxd)[0]
for i in arcpy.mapping.ListLayers(mxd , "PinParcelComparison"):
arcpy.mapping.RemoveLayer(df , i)
#Build Comparison Layer
target_features = "Database Connections\DATA.sde\Buildings\Addresses"
join_features = "Database Connections\PSRCELS.sde\LAND_REC\ParcelRegion"
out_feature_class = "C:\Users\Documents\ArcGIS\Default1.gdb\PinParcelBuild"
arcpy.SpatialJoin_analysis(target_features, join_features, out_feature_class)
#Remove PinParcelBuild Layer from ArcMap
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
for i in arcpy.mapping.ListLayers(mxd , "PinParcelBuild"):
arcpy.mapping.RemoveLayer(df , i)
#Create No match Pin - No match Parcel layer.
in_feature_class = "C:\Users\Documents\ArcGIS\Default1.gdb\PinParcelBuild"
output_feature_class = "C:\Users\Documents\ArcGIS\Default1.gdb\PinParcelComparison"
where_clause = '"PIN" <> "CO_PIN"'
arcpy.Select_analysis(in_feature_class, output_feature_class, where_clause)
#arcpy.RefreshActiveView()
#Create .csv & .txt files (Excel & Notepad)
#---------------------------------------------------------------------
# a = append, appending to the end of the file if it exists
# w = write, truncating the file first
# r = open for reading (default)
# x = open for exclusive creation, failing if the file already exists
# b = binary mode
# t = text mode (default)
# + = open a disk file for updating (reading and writing)
# U = universal newlines mode (deprecated)
#---------------------------------------------------------------------
#Create the search cursor
cursor = arcpy.SearchCursor(output_feature_class)
print "complete"
# Iterate through the rows in the cursor
#In the output feature classes a new ObjectID is created.
#The Target_FID field contains the OBJECTID of the record from the target_features.
field = "OBJECTID"
field1 = "TARGET_FID"
field2 = "PIN"
field3 = "STATUS"
count = 0
# == Conditional Evaluation
# = Assignment of variable
for row in cursor:
OBJECTID = str(row.getValue(field))
TARGET_FID = str(row.getValue(field1))
PIN = str(row.getValue(field2))
STATUS = str(row.getValue(field3))
print "Close"
except arcpy.ExecuteError:
#Geoprocessing error.
print "A geoprocessing error has occured"
print arcpy.GetMessages(2)
except Exception as e:
#Python error.
print "An error has occured"
print e