AnsweredAssumed Answered

Map document has no len()

Question asked by PSoares on Mar 26, 2020
Latest reply on Mar 27, 2020 by Dan_Patterson

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.




Python errors:
Traceback Info:
File "\\\ATLAS\Home\psoares\Documents\python\filesupporttools\", 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