Select to view content in your preferred language

Custom Python tool parameters

264
3
Jump to solution
4 weeks ago
JohnEbbers
Occasional Contributor

Hello,

I am making a custom python tool but am having problems finding the correct parameter type to use:

JohnEbbers_0-1763391653537.png

I wish to make in_fc and in_fields equal to param0 and out_fc and out_fields equal to param1, both param0 and param1 have a 'File Geodatabase Table' data type.

JohnEbbers_1-1763391863032.png

Furthermore, if I want the output table to be created when the tool runs, where should I add the code to create a new table? I'm assuming it should be right before what I currently have in the execution code block.

 

Thanks,

 

John

0 Kudos
1 Solution

Accepted Solutions
AlfredBaldenweck
MVP Regular Contributor

Oops, sorry.

It's just "Table" in an atbx, but DETable in a python toolbox.

AlfredBaldenweck_0-1763565401856.png

Use the dependency box for the fields parameter to make it so it draws from the input table parameter. Also note that I set the data type for the fields parameter to Field and set it as multivalue.

AlfredBaldenweck_1-1763565487540.png

 

View solution in original post

3 Replies
AlfredBaldenweck
MVP Regular Contributor

Easiest to just make threeparameters:

in_fc and out_fc: DETable

in_fields: Field

The reason I say only three is because it looks like you're using the same fields for both tables. If you're not, i'd suggest making a tool to make the second table with the fields you want and another tool to do the appending, since you'll need to use a fieldmap to make it work correctly.

You'll also want to add a dependency to the in_field so they pull from the input tables.

You're correct, make the out_fc before doing your cursor and use addfield or addfields (harder, imo) to get the right ones. (Or copy the schema of the in_table)

JohnEbbers
Occasional Contributor

Hi Alfred,

Thanks for your suggestions, I couldn't find the DETable in the parameter data types here:

JohnEbbers_0-1763563002582.png

Also, is there a way to generate the Field parameter dynamically?

Thanks,

John

 

0 Kudos
AlfredBaldenweck
MVP Regular Contributor

Oops, sorry.

It's just "Table" in an atbx, but DETable in a python toolbox.

AlfredBaldenweck_0-1763565401856.png

Use the dependency box for the fields parameter to make it so it draws from the input table parameter. Also note that I set the data type for the fields parameter to Field and set it as multivalue.

AlfredBaldenweck_1-1763565487540.png