Avenue Script

3033
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
12 Replies
JpersonalLundquist
New Contributor III

Point well taken. I'll stop procrastinating and attempt Python again.

You asked "what error or unexpected results are you getting?" I should have been able to answer that.

So, today I started from scratch, oddly enough I was stumped at an even earlier part in the script. Don't remember how I got further:(

The lines were

aView = av.GetProject.FindDoc('View1')
            'Unrecognized object: aNetworkTheme
aNetworkTheme = aView.FindTheme("nonetworkroads.shp")
aNetworkThemeFTab = aNetworkTheme.GetFTab

To me this looks like a new thing is created, aNetworkTheme from the nonetworkroads and builds a table for it. 

I'm guessing that when you run compile The marvelous ArcView 3 and Network Analyst put the cursor in the script where you need to address something.

So, you think I should give this up and move on? 

0 Kudos
DanPatterson_Retired
MVP Emeritus

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.

JpersonalLundquist
New Contributor III

Thanks Dan. Joshua asked what it was exactly I was doing. I was attempting to use the Script in ArcView 3, having nothing to do with Python. Sorry for any confusion. 

But I'm thinking after this conversation I should just forget Avenue for now and get caught up.

0 Kudos