Avenue Script

1973
12
Jump to solution
12-15-2017 09:16 PM
JpersonalLundquist
New Contributor III

This is going back, but it's where I'm from. (a forever young 62 year old who just loves GIS and sometimes fall back to ArcView 3). -Pays off sometimes:)

I've been trying to run a script, my Avenue Book is nowhere to be found, and I'm a newbie.

this is what I'm working with:

Copy and Paste this script to the script window in ArcView (Use CTRL+V to paste):

‘ This script copies over node numbers from nodes.dbf and adds record
‘ numbers to the line theme feature table. It adds fields called RECORD#,
‘ FJUNCTION, and TJUNCTION to the line theme feature table. A network
‘ index directory must exist for the network theme before running this
‘ script.

‘ Get the view and the network theme. Substitute aViewName for the name
‘ of your view, and aThemeName for the name of your network theme.

aView = av.GetProject.FindDoc(“VIEW_NAME_HERE”)

aNetworkTheme = aView.FindTheme(“THEME_NAME_HERE”)
aNetworkThemeFTab = aNetworkTheme.GetFTab

‘ Get the nodes.dbf file, make the VTab object, and get its fields

aNetworkIndexDir = aNetworkTheme.AsString.Substitute(“shp”,”nws”)
aNodeFile = FN.Merge(aNetworkIndexDir, “nodes.dbf”)
aNodeVTab = VTab.Make(aNodeFile, false, false)
aFjunction = aNodeVTab.FindField(“Fjunction”)
aTjunction = aNodeVTab.FindField(“Tjunction”)

‘ Add Record#, Fjunction, Tjunction fields to network theme FTab


aRecordField = Field.Make(“Record#”,#FIELD_LONG,12,0)
aFjunctionField = Field.Make(“Fjunction”,#FIELD_LONG,12,0)
aTjunctionField = Field.Make(“Tjunction”,#FIELD_LONG,12,0)
aFieldList = {aRecordField,aFjunctionField,aTjunctionField}
aNetworkThemeFTab.SetEditable(True)
aNetworkThemeFTab.AddFields(aFieldList)

‘ Use nodes.dbf to populate Rec#, Fjunction, Tjunction

Count = 0
for each r in aNetworkThemeFTab
aFromNodeNumber = aNodeVTab.ReturnValueNumber(aFjunction,Count)

aToNodeNumber = aNodeVTab.ReturnValueNumber(aTjunction,Count)
aNetworkThemeFTab.SetValueNumber(aFjunctionField,r,aFromNodeNumber)
aNetworkThemeFTab.SetValueNumber(aTjunctionField,r,aToNodeNumber)
Count = Count + 1
aNetworkThemeFTab.SetValueNumber(aRecordField,r,Count)
end

aNetworkThemeFTab.SetEditable(False)

Replace
aView = av.GetProject.FindDoc(“aViewName”)
with
aView = av.GetProject.FindDoc(“View1”) or the name that you have given the view.
Replace
aNetworkTheme = aView.FindTheme(“aThemeName”)
with
aNetworkTheme = aView.FindTheme(“nonetwork”) or the name that you have given the theme.

Click Script > Compile; then Script > Run

I have identified (I think) and corrected (I think) what needs to be fixed. e.g. comment lines, quotation marks, names, etc.

Just thought I'd ask. Hope this is appropriate for today and GeoNet.

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Esteemed Contributor

there no xxxactivedoc stuff any more, since arcpy isn't event driven.

You need to read up on the 'dataframe' and if you are planning to run this script in stand-alone mode, and not through a tool in arctoolbox, then you have added a new level of complexity.

My suggestion would be to try to work on a matching pairs list  .... avenue <-> arcpy .... this has nothing to do with python, you need to get the association between the objects names in both environments and how to access the object names and properties. For the most part ...'get'... isn't widely used in any context in arcpy, so try to parse off 'get' from object... ie getActiveDoc   .... ActiveDoc... it would be either a mapdocument, a table or a layout.  Once you get the appropriate object, then the properties and methods can be examined in the arcpy link I posted.  Stitching everything together is the python part.

View solution in original post

12 Replies
DanPatterson_Retired
MVP Esteemed Contributor

some of the functionality can be replicated but there is no direct translation to ArcGIS Pro or ArcMap.  What can be recovered can be found in the arcpy and the tool reference

http://pro.arcgis.com/en/pro-app/arcpy/main/arcgis-pro-arcpy-reference.htm

http://pro.arcgis.com/en/pro-app/tool-reference/main/arcgis-pro-tool-reference.htm 

I am assuming that this is a pet project for now

JpersonalLundquist
New Contributor III

Thank you Dan. Yes pet project. And I'm working with the script in Arcview 3 with Network Analyst. But I bookmarked your links, thanks for those, I have just signed up for a MOOC class for Python. I have attitude,, but aptitude is an issue for me. Have been putting off Python for years, on again and off again attempts at programming. But have never taken a class, that I hope will be the kicker for me.

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

You will find it a relatively easy transition.  I would recommend beginning your venture with python 3.x that is used by ArcGIS Pro.  You might as well transition simultaneously since python 2.7.* is terminal in 2020.  Besides... Pro projects use the *.aprx file extension, so part of your knowledge-base is already familiar

JpersonalLundquist
New Contributor III

Hi Dan,

Python 3 it is. I'm doing https://www.py4e.com/lessons if that doesn't cut it I'll go to Coursera and take that route.

I have ArcView 10 with no maintenance. Pro might be available to me through a school I'm helping implement ESRI's ConnectED though ... But I can't justify the cost of coming up to date personally.

A few years back I wanted to put my ArcView 3 on my Windows 7, you chimed in; you asked if it were legit, license wise.  It was. But, I'm coming clean on this one. I'm really just playing with Network Analyst in ArcView 3, the extension NA came off a cd I had my hands on years ago. My professional use of GIS has fallen off, but I can't stay away from it. So, my hard place between the rocks is that sometimes I would qualify for the $100 version but occasionally qualify for ... the math says about $6500. But, with GeoWizard I can build polygons .. so i'm happy.

So, with this post I will expect officers at the door. But I might be able to plea bargain. I was offered ArcInfo full license once, "Cracked"; didn't do it.

"Easy transition,"? you have me laughing now.

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

62 ehhh  you young pups don't give up... if us old timers can do it, I am sure you can

JpersonalLundquist
New Contributor III

Pups! 'them is fightin words' (sic)

OK, I'll stick to it but in my spare time. But Joshua probably said something I needed to hear. (Python)

So, looks like you guys like GIS and it goes way beyond The Job (judging by time stamps)

Later

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

It never hurts to ask.  That said, I am unclear what exactly are you asking.  Do you want to make the Avenue script work or port the Avenue script to Python/ArcPy?  If the latter, the links that Dan provided are a good start.   If the former, what error or unexpected results are you getting?

0 Kudos
JpersonalLundquist
New Contributor III

Thank you Joshua. Glad its OK to ask an archaic question. I've bookmarked Dan's suggestions. I am trying to run the script in ArcView 3 with Network Analyst.

All I got is: http://www.husdal.com/arc/2008/06/25/08-network-index/

It's the only tutorial/Information I could find. Can't justify purchase for my ArcGIS 10, so I'm basically playing.

In my .apr I got about 20 scripts! Each compile got me one step further. Many errors were brought to my attention with cursor placement after trying to compile. The quote marks, empty spaces, and notation for comments in the script etc. etc. Fixed those and started running into others, I knew enough ... well actually I don't know enough to determine the problem. And after creating 20+ scripts I'm afraid I'm unable to answer your question.

So, I'm going to start from scratch again, really read the script, actually take notes. Perhaps I can glean some Avenue from the script, prior to replacing my Avenue book.

Best regards

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Although it has been a while, I have personally ported some Avenue and AML scripts over to Python, and I have also used contracting at work to have some AML scripts ported over for my unit.  The conclusion I have come to is that porting over isn't worth it.  By porting, I mean a very literal transfer of code focused on using the same steps and finding analogous functions.  There are enough changes in the languages themselves that trying too closely to mimic the steps of old scripts inevitably leads to getting wrapped around the axles.

Python is an amazing language in my mind.  If one steps back and focuses on the desired outcome, not only will it be possible to reproduce the analysis or task, there are sometimes more efficient ways of implementing them.