This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import machine | |
import time | |
DELAY = 0.01 | |
STEPS = 27 | |
class Motor: | |
def __init__(self, CA1, CA2, CB1, CB2, halfSteps=False): | |
self._coils = (CA1, CA2, CB1, CB2) | |
self._pattern = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _add_field(input_table, field): | |
import arcpy | |
if getattr(field, 'isNullable', True): | |
nullable = 'NULLABLE' | |
else: | |
nullable = 'NON_NULLABLE' | |
# there is a bug in 10.2.1 and lower (sum is 13) that prevents us from adding non_nullable fields, so we have | |
# to protect against that bug. | |
if nullable == 'NON_NULLABLE' and sum([int(i) for i in GetArcpyVersion().split('.') ]) <= 13: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print "Importing arcpy" | |
import arcpy | |
from os.path import join | |
workspace = r"path to .sde connection here" | |
fields_to_remove = ["Shape_STLength__", "Shape_STArea__"] | |
arcpy.env.workspace = workspace | |
print "Listing Feature Classes" | |
layers= arcpy.ListFeatureClasses() | |
for layer in layers: | |
print "Processing {}".format(layer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arcpy.CalculateField_management(TableName, NewColumn, """!OldColumn!.replace("A", "B")""", "PYTHON_9.3", "#") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcpy | |
from os.path import abspath, join, basename, dirname | |
import csv | |
class Toolbox(object): | |
def __init__(self): | |
self.label = "Collect Info to CSV Toolbox" | |
self.alias = "CollectInfoToCSV" | |
# List of tool classes associated with this toolbox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcpy | |
from os.path import abspath, join, basename, dirname | |
import csv | |
class Toolbox(object): | |
def __init__(self): | |
self.label = "Collect Info to CSV Toolbox" | |
self.alias = "CollectInfoToCSV" | |
# List of tool classes associated with this toolbox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcpy | |
from os.path import abspath, join | |
directory = r"C:\Users\cmoravec\Documents\ArcGIS" | |
def walk_directory(directory): | |
output_list = list() | |
for base_dir, child_dirs, filenames in arcpy.da.Walk(directory, datatype='FeatureClass'): | |
for filename in filenames: | |
data = join(abspath(base_dir), filename) | |
output_list.append(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcpy | |
import os.path | |
class Toolbox(object): | |
def __init__(self): | |
self.label = "Simple Export Toolbox" | |
self.alias = "ExportMXD" | |
# List of tool classes associated with this toolbox | |
self.tools = [ExportMXD] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global id_value_dict | |
id_value_dict = dict() | |
def calc_new_id(base_id_value): | |
global id_value_dict | |
if base_id_value in id_value_dict: | |
id_value_dict[base_id_value] += 1 | |
else: | |
id_value_dict[base_id_value] = 1 | |
return str(base_id_value) + "_" + str(id_value_dict[base_id_value]).zfill(3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcpy | |
import os.path | |
base_directory = r"C:\temp" | |
export_type = "PDF" | |
## Ensure that the export_type exists | |
if not hasattr(arcpy.mapping, "ExportTo" + export_type.upper()): | |
print ("*** You must specify an export type of one of: ***") | |
print ("*** AI, BMP, EMF, EPS, GIF, JPEG, PDF, PNG, SVG, TIFF***") |