2

I have created a relationship class in arc catalog using the same arguments I'm using below, however if I try and create it using the script below I get:

arcgisscripting.ExecuteError: ERROR 000622: Failed to execute (Create Relationship Class). Parameters are not valid. ERROR 000628: Cannot set input into parameter attributed.

Following is the script I'm using:

import arcpy
from arcpy import env
env.workspace = "C:\a.gdb"
origin_table = "a.gdb\Trail_meta"
destination_table = "a.gdb\trails_mfg"
out_relationship_class = "a.gdb\t3meta"
relationship_type = "SIMPLE"
forward_label = "Attributes from meta"
backward_label = "Attributes from trail"
message_direction = "NONE"
cardinality = "ONE_TO_MANY"
attributed = "NONE"
origin_primary_key = "OBJECTID"
origin_foreign_key = "TRAIL_NAME"
arcpy.CreateRelationshipClass_management(origin_table,destination_table,out_relationship_class,forward_label,backward_label,message_direction,cardinality,attributed,origin_primary_key,origin_foreign_key)
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Mar 6, 2012 at 20:51
5
  • 2
    At a quick glance, since you're setting your environment variable env.workspace, I think you may be misleading the script by re-stating the name of the database in your variables origin_table,destination_table, and relationship_type. Try removing "a.gdb\" from these strings and see what happens. Commented Mar 6, 2012 at 21:05
  • Added an answer below based on the comment above. Commented Mar 6, 2012 at 21:34
  • yeah, tried that. Didn't help (I only put that in because of this sample code) help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//… Commented Mar 6, 2012 at 21:39
  • 2
    When I see env.workspace = "C:\a.gdb" my first thought is "shouldn't that be one of the following:" env.workspace = "C:\\a.gdb", env.workspace = "C:/a.gdb" or env.workspace = r"C:\a.gdb" Commented Mar 8, 2012 at 6:33
  • 2
    Yep, backslash is an escape character in Python. Gotta look out for that especially on Windows where your filesystem paths almost always contain backslashes. Commented May 6, 2012 at 0:10

2 Answers 2

2

Since you're setting your environment variable env.workspace, I think you may be misleading the tool by re-stating the name of the database in your variables: origin_table,destination_table, and relationship_type.

What the tool sees this:

origin_table = "a.gdb\a.gdb\Trail_meta"
destination_table = "a.gdb\a.gdb\trails_mfg"
out_relationship_class = "a.gdb\a.gdb\t3meta"

Redefine your variables to this:

origin_table = "Trail_meta"
destination_table = "trails_mfg"
out_relationship_class = "t3meta"

Also, it looks like all you want to import is the env module from arcpy, you can do that by simply using the from arcpy import env command instead of importing the entire arcpy module first. This may save you a bit of time when running the script.

answered Mar 6, 2012 at 21:33
0
0

Thanks this post actually helped me get this working. Sorry this is probably long since too late.

I believe the problem in the original post is that the relationship_type parameter is missing in the function call, thus causing an invalid parameter to be associated with the "attributed" parameter. Just change the function call to the following:

arcpy.CreateRelationshipClass_management(origin_table,destination_table,out_relationship_class,relationship_type,forward_label,backward_label,message_direction,cardinality,attributed,origin_primary_key,origin_foreign_key)
answered Mar 6, 2014 at 6:56

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.