2

I'm very new to python so please bear with me. I am trying to run a model that exports a .wm feature to a geodatabase feature class. The .wm file extension is for software that is used to update electrical utility data. The model has to be run in an .mxd because the .mxd contains an add-on that allows arcmap to read the .wm files. I'm having a problem getting the script to run successfully because it is not recognizing the .wm file even though the .mxd is open with the add-on enabled. Is there a way to prompt the model to run from the mxd rather than separately? Below is my script. Any insights?

Script:

import os
import arcpy
mxd = (r"D:\Milsoft\WindMilMap\WindmilMapExport\WindmilMapExport.mxd")
os.startfile(mxd)

import time
time.sleep(50)

import arcpy
arcpy.ImportToolbox(r"D:\Milsoft\WindMilMap\WindmilMapExport\WindmilAutomation.tbx", "WindmilAutomation")
arcpy.ElectricWMtoGDB_WindmilAutomation()

Traceback:

Traceback (most recent call last):  
  File "D:\Milsoft\WindMilMap\WindMilMapExport\WindmillExportAutomation.py", line 11, in <module>
    arcpy.ElectricWMtoGDB_WindMilAutomation()
  File "D:\Milsoft\WindMilMap\WindMilMapExport\WindmilAutomation.tbx", line 21, in ElectricWMtoGDB
       F e a t u r e   L a y e r
ExecuteError: Failed to execute. Parameters not valid.
The value does not exist.
WARNING 000258: Output D:\Milsoft\WindMilMap\WindMilMapExport\Electric.gdb already exists
ERROR 000732: Input Features: Dataset 'D:\Milsoft\WindMilMap\WindMilMapExport\WindMilMap LLM E-CMS.wm\Capacitor' does not exist or is not supported
Failed to execute (ElectricWMtoGDB).
  • 1
    Please include all diagnostic output in ASCII, indented as code; a red-on-white image is not nearly so legible. – Vince Feb 8 '16 at 17:39
  • Transcribed your traceback, but this is difficult without access to the code of arcpy.ElectricWMtoGDB_WindmilAutomation(), especially D:\Milsoft\WindMilMap\WindMilMapExport\WindmillExportAutomation.py. Apparently there is a way to access the add-in's functionality from a stand-alone script, but it is hard to tell (does the add-in require licensing?) – blord-castillo Feb 8 '16 at 18:01
  • There's an issue inside the script/model arcpy.ElectricWMtoGDB_WindmilAutomation() - looks like it's trying to create a gdb that already exists, but will be hard to tell without seeing that script. – Midavalo Feb 8 '16 at 19:39
  • The traceback tells you that there are invalid parameters on line 11 of windmillexportautomation.py. All the other error messages can be ignored since they come after. Why are you thinking "because it is not recognizing the .wm file"? It is unlikely anybody will to be able to help you unless you show the lines of code actually causing the error. – RHB Feb 9 '16 at 17:24
1

Assuming ArcMap is relying on an installed add-in/extension to read the .wm format and you are running your script from a Python prompt/IDE (e.g IDLE or PyScripter) you can try:

  • Don't open the MXD from within your script. Even though ArcMap is open, it is a separate process to your python process, so python will not have access to the add-in/extension
  • Run the script from the Python window within ArcMap, not from a Python prompt/IDE

enter image description here

0

You can run the process against the mxd, something like the following:

# Define the mxd/path
mxd = arcpy.mapping.MapDocument("whatevermxdpath")

# Create a list of data frames (this specifically selects the top frame)
dframe = arcpy.mapping.ListDataFrames(mxd)[0]

# Define the layer to process
layer = arcpy.mapping.Layer("whateverlayername")

# Add your layer
arcpy.mapping.AddLayer(dframe, layer, "AUTO_ARRANGE")

# Generate list of layers and select the appropriate one
layrList = arcpy.mapping.ListLayers(mxd, outName, dframe)[0}

mxd.save()

# Here you run whatever process with the lyrLst arg and your output

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.