Jump to content

 
Photo

addruletopology scripting syntax

- - - - -

  • Please log in to reply
5 replies to this topic

#1
ktulu

ktulu

    Newbie

  • Validated Member
  • Pip
  • 8 posts
  • Location:Madrid
  • Spain

Hello.

I'm trying to make a python script to add a rule to a topology. I run it and this error occurs:

Traceback (most recent call last):

File "C:\Mis documentos\arcgis\scripts\creatopologia.py", line 30, in ?

gp.AddRuleToTopology_management(capaTopologia, "Must Not Intersect (Line)", featureDataSet + "TRAMO", "", "", "")

RuntimeError:

The topology rule is invalid/malformed.
Failed to execute (AddRuleToTopology).

-capaTopologia is a variable, it contains "C:\Mis documentos\baleares.mdb\Datos\Topologia_tramos_y_cruces"

-featureDataSet is a variable too, it contains "C:\Mis documentos\baleares.mdb\Datos\"

- and TRAMO is a Feature Class in the feature dataset "C:\Mis documentos\baleares.mdb\Datos\"

┬┐Where is the problem? I think that the expression is well-formed, it's like the examples of arcgis.

#2
supercooper

supercooper

    Contributor

  • Validated Member
  • PipPip
  • 45 posts
  • Location:Fayetteville, AR
  • United States

Looks like you need to either escape the whacks or use forward slashes in your variables:

C:\Mis documentos\baleares.mdb\Datos\Topologia_tramos_y_cruces

should be:

var = 'C:/Mis documentos/baleares.mdb/Datos/Topologia_tramos_y_cruces'

or

var = 'C:\\Mis documentos\\baleares.mdb\\Datos\\Topologia_tramos_y_cruces'

You may also want to post your issue (including your code) to the ESRI Python forum at:

http://forums.esri.c...=93&s=1729#1729

HTH

chad

#3
frax

frax

    Hall of Fame

  • Associate Admin
  • PipPipPipPipPipPipPip
  • 2,320 posts
  • Gender:Male
  • Location:Stockholm, Sweden
  • Interests:music, hiking, friends, nature, photography, traveling. and maps!
  • Sweden

see what happens when you try to run the exact same command using the toolbox, I bet you get the same error...
Hugo Ahlenius
Nordpil - custom maps and GIS
http://nordpil.com/
Twitter

#4
Charlie Frye

Charlie Frye

    Master Contributor

  • Validated Member
  • PipPipPipPip
  • 112 posts
  • Gender:Male
  • Location:Redlands, CA
  • Interests:Base map design/data model, political/election maps; use of historical maps for modern GIS analysis
  • United States

Put a lower case r in front of your strings when you define the variables. This tells Python to process them as "raw". For example:

capaTopologia = r"C:\Mis documentos\baleares.mdb\Datos\Topologia_tramos_y_cruces"
Charlie Frye
Chief Cartographer
Software Products Department
ESRI, Redlands, California

#5
Charlie Frye

Charlie Frye

    Master Contributor

  • Validated Member
  • PipPipPipPip
  • 112 posts
  • Gender:Male
  • Location:Redlands, CA
  • Interests:Base map design/data model, political/election maps; use of historical maps for modern GIS analysis
  • United States

Also,

You also need to set the in_featureclass2 variable because the rule you're adding requires two feature classes. If you really mean "Must Not Self-Intersect (Line)" then change the rule parameter.

Another tip is to try doing the task using the user interface as that will tell you which parameters will need to be used.
Charlie Frye
Chief Cartographer
Software Products Department
ESRI, Redlands, California

#6
ktulu

ktulu

    Newbie

  • Validated Member
  • Pip
  • 8 posts
  • Location:Madrid
  • Spain

There is no problem with the paths, I wrote '\\' in the scripts. The problem is, it's necessary to execute the AddFeatureClassToTopology command with the feature class TRAMO before executing the AddRule Topology.

Thank you for your comments.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

-->