well... I have been trying to use add-in to make simple button that had a date and current mxd name to features in the fcs in the gdb in use. still not working. I really don't understand how to use making addin.
I decided to give it a go using Arctoolbox as it looks simpler.
In first place with three input variables: date; file location (folder path); and file.
It works.
But I want to reduce the number of input variables. I was thinking to use 'current' and skip the file location and file manual input. The help on this says is that is not possible to use it in the background, therefore I made it run on foreground... however when I tried gave the following error.
I need some guidance on this because maybe it is impossible to use toolbox for this or maybe there is a workaround... anything.
cheers
P
Python errors:
Traceback Info:
File "\\eusc.europa.eu\ATLAS\Home\psoares\Documents\python\filesupporttools\uploadcurrentMXD_vectors_TOOLBOX_version.py", line 93, in <module>
issue_code = os.path.basename(mxdInicio)
Error Info:
<type 'exceptions.TypeError'>: object of type 'MapDocument' has no len()
GP errors:
line 93 code is the following:
# mxd and environment; and gdb sources and targets
mxdInicio = arcpy.mapping.MapDocument('current')
mxdPath = mxdInicio.filePath
issue_code = os.path.basename(mxdInicio) ## line 93
issue_code = issue_code[0:19]
issue_code = issue_code.replace("_"," ")
mxdPathList = mxdPath.split(os.sep)
IssueGDB = "\\".join(mxdPathList[:-1])
print IssueGDB
Solved! Go to Solution.
Hi guys,
thanks for the:
print (arcpy.AddMessage(mxdInicio.filePath))
with that i figure it out the problem:
mxdInicio = arcpy.mapping.MapDocument('current')
arcpy.AddMessage(mxdInicio.filePath)
mxdPath = mxdInicio.filePath
issue_code = os.path.basename(mxdPath) # i figure it out that I was calling the wrong variable...
by the way, I took this time because the question came from the other side of the Atlantic
thanks guys, tool is finished.
cheers
Pedro
It is common practice/courtesy to mark comments "Helpful" if people's comments are, well, helpful. Looking over the discussion now, not a single comment has been marked Helpful. Also, if one comment was particularly helpful, that one can be marked Correct to close out the discussion. Or, the question can be marked "Assumed Answered".
You are right and I apologize
https://community.esri.com/message/918013-re-map-document-has-no-len?commentID=918013#comment-918013
and next time please read the code samples, with the highlights... you could have been done much sooner
ArcGIS Pro has it... you can even open a Jupyter Notebook in your project for quick testing and 'dir' away on objects to find out what they have.
Pro has some nifty features... don't know if they are available in arcmap
i have no arcgis pro
Then add these lines to your script and devolve the project path relative to the running script in the toolbox.
import sys
script = sys.argv[0]
Then you can find the location of the script and if your project is located 'relative' to it, you should be able to construct the project name and location.
script
'C:\\Git_Dan\\npgeom\\_load_sample_.py'