Is it Possible to Generate Barcodes in ArcGIS Layout using Python scripts

800
9
03-20-2014 11:36 AM
OLANIYANOLAKUNLE
Occasional Contributor II
Is it Possible to Generate Barcodes in ArcGIS Layout using Python scripts, any thoughts? Thanks
Tags (2)
0 Kudos
9 Replies
JamesCrandall
MVP Frequent Contributor
https://pypi.python.org/pypi/pyBarcode/0.7

Then insert the resulting .png into layout?
0 Kudos
OLANIYANOLAKUNLE
Occasional Contributor II
I have downloaded the pyBarcode-0.7.tar.gz file but I am having issues installing the file, I can't even get my head around unpacking the file? Any thoughts? + do you think the code under the pyBarcode-0.7.tar.gz would work amidst the arcpy script below:

import arcpy
import pythonaddins
import os
import datetime
import time  
arcpy.env.overwriteOutput = True

class FCTSitePlanBatchToolClass(object):
    """Implementation for FCTSitePlanBatchTool_addin.button (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        mxd = arcpy.mapping.MapDocument("Current")
        df = arcpy.mapping.ListDataFrames(mxd)[0]
        arcpy.SelectLayerByAttribute_management("GISMainFabric_Parcels", "CLEAR_SELECTION")
        arcpy.MakeFeatureLayer_management("GISMainFabric_Parcels", "STemp", '"Plot_Status" = \'ALLOCATED\'AND "SitePlan_Status" = \'NOT GENERATED\'')
        fc = "STemp"
        field = "OBJECTID"
        field1 = "Plot_No"
        field2 = "Block_No"
        field3 = "Name_Allottee"
        field4 = "SitePlan_Status"
        field5 = "LGA"
        field6 = "District"
        field7 = "StatedLen"
        field8 = "Cadzone"
        #field9 = "TDP_Status"
        rows = arcpy.SearchCursor(fc)
        #row = rows.next()
        #while row:
        for row in rows:
            val = row.OBJECTID
            val1 = row.Plot_No
            val2 = row.Block_No
            val3 = row.Name_Allottee
            val4 = row.SitePlan_Status
            val5 = row.LGA
            val6 = row.District
            val7 = row.StatedLen
            val8 = row.Cadzone
            #val9 = row.TDP_Status
            whereClause = '"OBJECTID"' + " = '" + str(val) + "'"
            whereClause2 = '"Block_No"' + " = '" + str(val2) + "'"
            whereClause3 = '"District"' + " = '" + str(val6) + "'"
            whereClause4 = '"Cadzone"' + " = '" + str(val8) + "'"
            whereClause5 = '"Plot_No"' + " = '" + str(val1) + "'"
            outName = str(val5) + "_LGA" + "(" + str(val6) + "_Area" + ")"
            outName1 = "Plot_" + str(val1) + "(" "Block_" + str(val2) + ")"
            outName2 = str(val3) + " Block_" + str(val2) + "_Plot_" + str(val1) + "_" + str(val6) + "_Area_of_" + str(val5) + "_LGA" + ".pdf"
            arcpy.SelectLayerByAttribute_management("STemp", "NEW_SELECTION", whereClause)
            arcpy.Buffer_analysis ("STemp", "ClipFeature", "7 meters", "FULL", "ROUND", "LIST")
0 Kudos
JasonScheirer
Occasional Contributor III
If you go to the BitBucket releases page for the project, you can download a .zip of 0.7
0 Kudos
AdamCox1
Occasional Contributor II
There are a few different ways to install python modules, here's the real explanation: http://docs.python.org/2/install/

The steps I just took to install this one:

1. download the .tar.gz from the link above.
2. unzip so you are left with a folder called "pyBarcode-0.7"
3. put it in an easy to reach location, like c:\pyBarcode-0.7
4. open the command prompt (start menu, type "cmd" into the search box)
5. navigate to the pyBarcode-0.7 folder (type "cd c:\pyBarcode-0.7")
6. run the install command on the setup.py (type "setup.py install")

The setup.py script should copy all of the necessary files to you python folder, and you should be able to import and use the module in any scripts.
0 Kudos
OLANIYANOLAKUNLE
Occasional Contributor II
Thanks for all the Nuggets of information, my next question is how can I download the setuptools/distribute? I think it is a very important prerequisite for the pyBarcode-0.7 installation? Thanks for your thoughts
0 Kudos
AdamCox1
Occasional Contributor II
I don't think you need to install anything new prior to following the steps I outlined above.  Give it a shot and let me know how it goes.
0 Kudos
OLANIYANOLAKUNLE
Occasional Contributor II
I've tried a couple of times and the attached screen shot was the error message I got
0 Kudos
AdamCox1
Occasional Contributor II
Ok yeah, sure does look like you need to install setuptools.  This should be helpful: https://pypi.python.org/pypi/setuptools#installation-instructions
0 Kudos
mariahlewis
New Contributor
Is it Possible to   Generate Barcodes in ArcGIS Layout using Python scripts, any thoughts? Thanks


if using a 3rd party barcode generator ?
0 Kudos