0

I have two questions: 1. Is the mxd file generated by arcgis10.4 not converted to msd file by this method? 2. If can, my code is like this

import arcpy
mxdPath = "F:/mm.mxd"
msdPath = "F:/test.msd"

mxd = arcpy.mapping.MapDocument(mxdPath)
print "---------------------------mxd open success-----------------------------------"

df = ""
frames = arcpy.mapping.ListDataFrames(mxd, "图层")
if len(frames) == 0:
    frames = arcpy.mapping.ListDataFrames(mxd, "Layers")
df = frames[0]
print "---------------------------------mxd to msd ing-----------------------------"
arcpy.mapping.ConvertToMSD(mxdPath, msdPath, df, "NORMAL", "NORMAL")
print "---------------------------------mxd to msd success-----------------------------"

the error is:

AttributeError: 'str' object has no attribute '_arc_object'

all is this

File "f:/code/pythonTest/demo.py", line 17, in <module>
    arcpy.mapping.ConvertToMSD(mxdPath, msdPath, df, "NORMAL", "NORMAL")
  File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\utils.py", line 182, in fn_
    return fn(*args, **kw)  File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\mapping.py", line 189, in ConvertToMSD
    result = mixins.MapDocumentMixin(map_document).convertToMSD(out_msd, data_frame, msd_anti_aliasing, msd_text_anti_aliasing)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\arcobjects\mixins.py", line 895, in convertToMSD    map = self._mxd._arc_object
AttributeError: 'str' object has no attribute '_arc_object'
  • OK ,OK. I'm so sorry. Method parameter error – Z GQ May 14 at 10:00
  • arcpy.mapping.ConvertToMSD(mxdPath, msdPath, df, "NORMAL", "NORMAL") – Z GQ May 14 at 10:01
  • the first parameter should be mxd – Z GQ May 14 at 10:01
  • Welcome to GIS SE.. As a new user, please take the Tour, which emphasizes the importance of asking One question per Question. Comments exist more for others to request information. As OP, your job is to Edit the question to be as clear as possible. – Vince May 14 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.