|
POST
|
Yeah, I actually just contacted support via email about 10 minutes ago lol. In this instance, if it's one of the two that you have experienced the problem in, my bet is an environment variable issue. After my scripts weren't working yesterday, all I have been testing with now is the very basic MessageBox that I pasted in a response above. Everything else in the *_addin.py file is the default script that is generated once you create the add-in project. Thanks for your recommendations, though! I appreciate it.
... View more
08-12-2015
10:21 AM
|
0
|
0
|
1720
|
|
POST
|
I'm replying to the original post as I am referencing multiple suggestions here. Ian Broad Doing what you suggested above did indeed allow me to pull "python" and "import" through the command window, but it didn't fix the issue I am having with the add-in. I restarted my machine, re-created/re-installed an add-in with one toolbar that had one button, added a MessageBox command to the onClick function...and I still get a button that says missing whenever I open up ArcMap. Rebecca Strauch I was looking at my XML config file, and I noticed that my target version was set to 10.1. Whenever I was working in the 10.2.2 yesterday, my target version was 10.2, but now that I'm in 10.3.1, my target version says 10.1. Very confusing. I changed the 10.1 to 10.3.1, and in doing so, the add-in will not show up in ArcMap when I open the document. It says it installed correctly, but it just doesn't show up. I changed it back to 10.1 and it shows up again with a missing button. Is there some sort of issue with that version number that could be causing problems?
... View more
08-12-2015
09:53 AM
|
0
|
9
|
1905
|
|
POST
|
I tried the same add-in that I was using before and I got the same results. I created a new project > toolbar > button, added a message box to the button, and I still get a button that says missing on the new toolbar.
... View more
08-12-2015
09:09 AM
|
0
|
0
|
1905
|
|
POST
|
I got the following message. If I open up Start > All Programs I have a Python 3.4 folder, and I also have Python27 and Python34 folders located on my C:, so I'm not really sure why it's not picking up Python.
... View more
08-12-2015
09:05 AM
|
0
|
1
|
3305
|
|
POST
|
I followed you. You can send whenever is convenient for you. All of the tests that I have been doing have been in 10.2.2. I am, however, upgrading to 10.3.1 as we speak, though. We downgraded to 10.2.2 due to compatibility issues whenever we purchased a secondary software extension from a third party to help us document our strand level (fiber optic cable) detail. They have since increased compatibility to 10.3 versions, so I am moving back up. I'll give the Add-In another go as soon as the installs are completed and I'll report my findings at that time.
... View more
08-12-2015
08:45 AM
|
0
|
1
|
1905
|
|
POST
|
Looking at the link you provided, I don't see any differences between your code and what I have tried, or have pasted in my last response using a simple MessageBox to see if the button would actually work without any script reference or long code included in the onClick. Back when I was trying to create a custom toolbar in ArcMap and loading my scripts into the GP tools section of the customize menu for placement on that toolbar, the Map to KML example I've shown above worked just fine. The issue was whenever I was finished editing the toolbar and would close/re-open ArcMap, the button for the tool would still be there, but the designated image that I selected was no longer there and nothing would happen when I clicked the button. Since I couldn't get anything to work with using the easy custom toolbar creation within ArcMap, that's when I decided to try your add-in suggestion. Long story short...the script would run just fine (tested many times) whenever I still had ArcMap open, but I would lose the functionality once I closed that ArcMap document. The toolbar was saved to my Normal document too, because it would display no matter which document I opened. I don't have any images associated with the buttons at this time. I figured I would work that part out once I got the buttons to work. Would that not allow the button to work with simply displaying text on the add-in toolbar, though? You can definitely send me any samples that you may have. I would appreciate taking a look for reference . Is there a way of privately providing a contact email on here?
... View more
08-12-2015
07:30 AM
|
0
|
7
|
3305
|
|
POST
|
Thanks for the suggestions, Rebecca. Modifying the toolbox to have no spaces, as well as moving it to the top of the script, didn't work. On that note, however, shouldn't the tool still run when I use the actual code instead of referencing a script file? I have tried with double and single quotes. Neither has made a difference, so I'm thinking it's the error is related to something else. Just as a test I re-saved the project so that the python script was back to the default that is auto-created. I re-created the add-in and installed it again. The buttons still show up as missing. Why would they show up as missing if I haven't modified the original python add-in script...? I would have thought that they would simply show up and do nothing as apposed to showing as missing. *EDIT* I went back and instead of leaving "pass" after each onClick, I added a simple MessageBox. The below code still gives buttons that show as missing. import arcpy
import pythonaddins
class map_to_kml(object):
"""Implementation for map_to_kml.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
pythonaddins.MessageBox("This is a message box.", "Message Box", 0)
class osp_export(object):
"""Implementation for osp_export.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
pythonaddins.MessageBox("This is a message box.", "Message Box", 1)
... View more
08-11-2015
02:26 PM
|
0
|
14
|
3305
|
|
POST
|
This is the python file with the code within it. Again, it is a direct copy from the working script that we use daily, so I don't think it is a syntax error, unless there is some functionality that needs to change between stand-alone scripts and add-ins. import arcpy
import pythonaddins
import os
import arcpy.mapping as map
from arcpy import env
mxd = map.MapDocument("CURRENT")
class map_to_kml(object):
"""Implementation for map_to_kml.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
# Apply Symbology Layer file
# Set local variables
inputLayer = r'Entire Coverage Area\Fiber Segments'
symbologyLayer = r'\\extenet.local\dfs\Network-Planning-GIS\1)Documentation\ArcGIS_Files\4)Symbology_Layer_Files\Fiber Segments (KMZ).lyr'
# Execute the ApplySymbologyFromLayer tool
arcpy.ApplySymbologyFromLayer_management (inputLayer, symbologyLayer)
# Save the map
mxd.save()
# Map to KML tool
# Set local variables
df = arcpy.mapping.ListDataFrames(mxd)[0].name
mapName = str(mxd.filePath).split('\\')[-1:][0][:-4]
filepath1 = str(mxd.filePath)[:79] + mapName + "/6)Deliverables/"
version = arcpy.GetParameterAsText(0)
outputKML = filepath1 + mapName + " " + version + '.kmz'
extent = 'Same as layer Fiber Segments'
# Execute MapToKML tool
arcpy.MapToKML_conversion(mxd.filePath, df, outputKML, '', '', '', extent,'', '', '')
# Apply Symbology Layer file
# Set local variables
inputLayer = r'Entire Coverage Area\Fiber Segments'
symbologyLayer = r'\\extenet.local\dfs\Network-Planning-GIS\1)Documentation\ArcGIS_Files\4)Symbology_Layer_Files\Fiber Segments.lyr'
# Execute ApplySymbologyFromLayer tool
arcpy.ApplySymbologyFromLayer_management (inputLayer, symbologyLayer) Here is the python file just referencing the existing script: import arcpy
import pythonaddins
import os
relPath = os.path.dirname(__file__)
class map_to_kml(object):
"""Implementation for map_to_kml.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
toolPath = relPath + r'\ExteNet Systems Toolset.tbx'
pythonaddins.GPToolDialog(toolPath, 'Map to KML1') I made sure that the referenced tool is using relative path names, and the toolbox is in the install folder for the add-in. I tried this with just about every variation of the tool name I could think of. I used the no space version, I used the ".py" afterwards. I also tried the os.startfile() method with a direct link to the tool instead of concatenated as shown above.
... View more
08-11-2015
01:44 PM
|
0
|
16
|
3305
|
|
POST
|
@Rebecca Strauch I'm tagging Rebecca because of the conversation here: Custom toolbar that contains Python Scripts I have been playing with the Python Add-In Wizard, and I have created a toolbar with some menus and buttons. I am having trouble getting the buttons to work, though. I've followed Rebecca's instructions (here: Python add-ins vs. .NET add-ins?), as well as the attached PDF to try and use an existing python script within my toolbox, but the button just shows up as missing when I install the add-in and run ArcMap. I've even tried pasting the entire code from the script directly into the onClick function, and that just does the same thing. Is this a common problem? Is this indicative of a common issue, or could it be a vague error that would be harder to diagnose...? I read somewhere that the missing designation could mean that there is some sort of syntax error in the code, but the scripts work on their own...just not whenever I try to associate them with a button on the custom add-in toolbar. Thanks you!
... View more
08-11-2015
01:16 PM
|
2
|
28
|
16107
|
|
POST
|
Converting all UpdateCursors to the newer .da version along with the "with" keyword did the trick. Thanks to everyone for their input on this issue. Each suggestion helped solve the problem or expanded my knowledge and understanding of Python.
... View more
08-10-2015
01:29 PM
|
0
|
0
|
655
|
|
POST
|
Thank you all for the helpful responses. I have been up in the northern tip of Wisconsin with VERY limited internet access this past week, so I haven't gotten to try any of these suggestions yet. I will give them a go on Monday or shortly after. Just giving a heads up to not leave it in limbo.
... View more
08-08-2015
09:37 PM
|
0
|
0
|
655
|
|
POST
|
I actually do use .da in other examples...maybe not in this exact script, though. I don't have access to that script to double check at this time, as it's on a different machine. If I use the .da version of UpdateCursor for every instance of UpdateCursor that I use, it will release the table for edits by other functions, such as CalculateField in my example? If that is indeed the case then there is a conflict between using the two methods together, and it is corrected by using the .da version, correct? Just trying to make sure I am understanding you correctly. Thanks!
... View more
08-01-2015
09:20 PM
|
0
|
1
|
1854
|
|
POST
|
Thanks for the helpful information, Wes. Looking at the link that you provided, I'm not really sure what's going on. From what I can tell the script allows the user to place the points and then the X/Y is auto-generated? The carrier field is derived earlier in the script. I do believe, though, that the dictionary method that you reference above would work nicely instead of the way that I was doing it. Although your method does seem to be a quicker way to do it, the way I am doing it does work...it's the second code that I can't get to work. As I mentioned in the original post, the second script works when used in my script that utilizes ALL calculate field methods. It's only when I try to use it while mixed in with UpdateCursors as well. I'm not sure if there is something between the two that throws one off or what. The theories that I can think of are the fact that I'm using global variables, maybe using UpdateCursors and CalculateField together in the same script creates some sort of conflict, or possibly the mix of the two creates a conflict between 32bit and 64bit processing...not sure. Those theories may not even hold water, but they're the only things I could think of when trying to figure out why it wouldn't run properly.
... View more
08-01-2015
08:33 PM
|
0
|
8
|
1854
|
|
POST
|
I have a script that I recently created an alternate copy of and updated many of the calculate field functions to make use of UpdateCursor. When I run the original script, all runs through just fine, but whenever I try to run the alternate version, the tool gets hung up on any of the parts that are still in CalculateField format. Is there a known issue with mixing UpdateCursors and CalculateField functions within the same script? Is there a common procedure that needs to be followed to do so? Sample code below. Other than changing from CalculateField to UpdateCursor, the only other difference that I see that I made was moving some of the variables into the functions as global variables so I could use them outside of the function (I think I had to anyway...these sections started working after I did so). #########################
# Calculate Region
#########################
# Start message
arcpy.AddMessage("Determining the correct region field to be updated for all node features...")
# Set local variables
inTable = nodeFeatures
cursor = arcpy.UpdateCursor(inTable)
# Determine the correct region field to update
def Get_node_regionField():
global node_regionField
if carrier == "CUST1":
node_regionField = "CUST1Region"
elif carrier == "CUST2":
node_regionField = "CUST2Region"
elif carrier == "CUST3":
node_regionField = "CUST3Region"
elif carrier == "CUST4":
node_regionField = "CUST4Region"
elif carrier == "CUST5":
node_regionField = "CUST5Region"
else:
pass
Get_node_regionField()
# Execute UpdateCursor
for row in cursor:
row.setValue(node_regionField, region)
cursor.updateRow(row)
# End message
arcpy.AddMessage("The " + carrier + " region field has been updated for all node features!")
arcpy.AddMessage("...")
arcpy.AddMessage("...") Each one of these IF statements used to be its own CalculateField (I didn't know how to incorporate them all into one, as I do above using the UpdateCursor method). The above code works just fine. I originally had the "node_regionField" variable as "inField", but there was an issue with doing so since I used inField for multiple other UpdateCursors. I'm assuming it had something to do with the fact that it is a global variable...? Not sure. Comment on that if you know, but the real issue is below: #########################
# Calulate latitude
#########################
# Start message
arcpy.AddMessage("Calculating the latitude values for all node features...")
# Set local variables
inTable = nodeFeatures
inField = "Latitude"
expression = "!Shape.Centroid.Y!"
# Execute CalculateField
arcpy.CalculateField_management(inTable, inField, expression, "PYTHON_9.3")
# End message
arcpy.AddMessage("The latitude values have been calculated for all node features!")
arcpy.AddMessage("...")
arcpy.AddMessage("...") This code will not run, and all it does is return a generic 99999 error code: "Traceback (most recent call last): #my python script filepath# arcpy.CalculateField_management(inTable, inField, expression, "PYTHON_9.3") File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 3354, in CalculateField raise e ExecuteError: ERROR 999999: Error executing function. Failed to execute (CalculateField)." This error code doesn't really tell me much. The weirdest thing is that it still works (copied identically) in the script that utilizes all CalculateField functions. I have 2 sections that calculate longitude, 2 that calculate latitude, 1 that calculates feet, 1 for meters, and 1 for miles. All 7 of them are constructed the same, and all 7 generate the same error message while in the mixed script, and all 7 work just fine in the all CalculateField version. Side note...if the !shape.centroid@y! can be done using the UpdateCursor method (I couldn't figure out how), I would much rather that anyway.
... View more
07-31-2015
07:54 PM
|
0
|
13
|
5364
|
|
POST
|
Rebecca, thanks for your input as well. I'll have to look into following your procedure creating the python add-ins. I think this is my preferred method, simply because I don't currently know a lot about .Net, so I would rather just stick to what I know for now. Thanks!
... View more
07-30-2015
02:42 PM
|
0
|
1
|
1402
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-16-2015 11:55 AM | |
| 1 | 02-04-2015 02:30 PM | |
| 2 | 03-23-2015 11:22 AM | |
| 7 | 03-23-2015 10:09 AM | |
| 3 | 03-23-2016 12:54 PM |
| Online Status |
Offline
|
| Date Last Visited |
03-06-2025
09:05 PM
|