0

I have a modelbuilder parent model with two nested models in it that ouputs a dwg file. I exported the parent model to a python script which is shown below. In modelbuilder, the output dwg file is a parameter so I can define its name and location when I run it. In the python script, it does not let me set the name and location. It shows the message "this model has no parameters" when its run in Python. I would like to be able to define the output name and location but am not sure how to do this in Python. The output file is "OutputFile.dwg" in the code below.

# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# GIStoCAD.py
# Created on: 2014年02月27日 13:15:51.00000
# (generated by ArcGIS/ModelBuilder)
# Usage: GIStoCAD <Output_File_Name> 
# Description: 
# ---------------------------------------------------------------------------
# Import arcpy module
import arcpy
# Load required toolboxes
arcpy.ImportToolbox("/cadd1/gisusers/CADGIS/Version2014/GIStoCADv10_1.tbx")
# Script arguments
Output_File_Name = arcpy.GetParameterAsText(0)
if Output_File_Name == '#' or not Output_File_Name:
Output_File_Name = "E:\\Workspace\OutputFile.dwg" # provide a default value if unspecified
# Local variables:
Delete_succeeded = Output_File_Name
GIStoCAD_gdb__4_ = "C:\\GIStoCAD.gdb"
V_PROP_LINE_PGCO = "C:\\GIStoCAD.gdb\\V_PROP_LINE_PGCO"
V_PROP_LINE_MOCO = "C:\\GIStoCAD.gdb\\V_PROP_LINE_MOCO"
V_BLDG_OUTL_PGCO = "C:\\GIStoCAD.gdb\\V_BLDG_OUTL_PGCO"
V_BLDG_OUTL_MOCO = "C:\\GIStoCAD.gdb\\V_BLDG_OUTL_MOCO"
V_ROAD_ASPH_PGCO = "C:\\GIStoCAD.gdb\\V_ROAD_ASPH_PGCO"
V_ROAD_ASPH_MOCO = "C:\\GIStoCAD.gdb\\V_ROAD_ASPH_MOCO"
V_SSWR_PIPE = "C:\\GIStoCAD.gdb\\V_SSWR_PIPE"
V_WATR_PIPE = "C:\\GIStoCAD.gdb\\V_WATR_PIPE"
V_WATR_STRC = "C:\\GIStoCAD.gdb\\V_WATR_STRC"
V_SSWR_MHOL__3_ = "C:\\GIStoCAD.gdb\\V_SSWR_MHOL"
V_WATR_INST = "C:\\GIStoCAD.gdb\\V_WATR_INST"
# Process: Setup
arcpy.gp.toolbox = "//cadd1/gisusers/CADGIS/Version2014/GIStoCADv10_1.tbx";
# Warning: the toolbox //cadd1/gisusers/CADGIS/Version2014/GIStoCADv10_1.tbx DOES NOT have an alias. 
# Please assign this toolbox an alias to avoid tool name collisions
# And replace arcpy.gp.Setup3(...) with arcpy.Setup3_ALIAS(...)
arcpy.gp.Setup3(GIStoCAD_gdb__4_, V_PROP_LINE_PGCO, V_PROP_LINE_MOCO, V_BLDG_OUTL_PGCO, V_BLDG_OUTL_MOCO, V_ROAD_ASPH_PGCO, V_ROAD_ASPH_MOCO, V_SSWR_PIPE, V_WATR_PIPE, V_WATR_STRC, V_SSWR_MHOL__3_, V_WATR_INST)
# Process: Export
arcpy.gp.toolbox = "//cadd1/gisusers/CADGIS/Version2014/GIStoCADv10_1.tbx";
# Warning: the toolbox //cadd1/gisusers/CADGIS/Version2014/GIStoCADv10_1.tbx DOES NOT have an alias. 
# Please assign this toolbox an alias to avoid tool name collisions
# And replace arcpy.gp.Export3(...) with arcpy.Export3_ALIAS(...)
arcpy.gp.Export3(Output_File_Name, "C:\\GIStoCAD.gdb\\V_PROP_LINE_PGCO;C:\\GIStoCAD.gdb\\V_PROP_LINE_MOCO;C:\\GIStoCAD.gdb\\V_BLDG_OUTL_PGCO;C:\\GIStoCAD.gdb\\V_BLDG_OUTL_MOCO;C:\\GIStoCAD.gdb\\V_ROAD_ASPH_PGCO;C:\\GIStoCAD.gdb\\V_ROAD_ASPH_MOCO;C:\\GIStoCAD.gdb\\V_SSWR_PIPE;C:\\GIStoCAD.gdb\\V_WATR_PIPE;C:\\GIStoCAD.gdb\\V_WATR_STRC;C:\\GIStoCAD.gdb\\V_SSWR_MHOL;C:\\GIStoCAD.gdb\\V_WATR_INST")
# Process: Delete
arcpy.Delete_management(GIStoCAD_gdb__4_, "")
Jason Bellino
4,3211 gold badge28 silver badges35 bronze badges
asked Feb 27, 2014 at 18:45

3 Answers 3

3

It sounds like you have not defined any parameters. Right-click on the tool in your toolbox, go to properties, and go to the Parameters tab. Do you have any parameters defined?

answered Feb 27, 2014 at 19:21
4
  • On the modelbuilder model, I do have the parameter set under properties-->parameters. One the exported python script (which is in the same toolbox), there are no parameters set under properties. Do I need to add one for the python script under parameters? Commented Feb 27, 2014 at 19:26
  • Yes, see the link in @Craig's answer. You'll probably need to use the type "CAD Drawing Dataset" Commented Feb 27, 2014 at 19:30
  • FWIW, the easiest way to add parameter is to add them under properties > parameters. Commented Feb 27, 2014 at 19:35
  • Barbarossa, thank you! The properties-->parameters did the trick :) Commented Feb 27, 2014 at 20:39
1

I believe the first line after the toolbox import statement is what is tripping up your script. It is looking for input parameters from a script tool interface:

Output_File_Name = arcpy.GetParameterAsText(0)

Comment out that line and the following line and you will be good to go:

#Output_File_Name = arcpy.GetParameterAsText(0)
#if Output_File_Name == '#' or not Output_File_Name:
Output_File_Name = "E:\\Workspace\OutputFile.dwg" # provide a default value if unspecified
answered Feb 27, 2014 at 18:56
4
  • Hi Jason, thank you for the response. I commented out those two lines but its still says "This tool has no parameters" Commented Feb 27, 2014 at 19:10
  • Are you running this as a script tool or as a stand-alone script? Commented Feb 27, 2014 at 19:26
  • Its running as a script tool. Commented Feb 27, 2014 at 19:26
  • Ok, in that case my answer is not valid as you'll need the GetParameterAsText() function to fetch user input from the tool. See @Barbarossa's answer instead... Commented Feb 27, 2014 at 19:29
1

This link from the ArcGIS Help on defining parameters in a python toolbox should get you started. Sounds like you'll need to setup a python toolbox and define the parameters within that.

answered Feb 27, 2014 at 19:18
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.