Set built in attributes within rule file

405
1
03-26-2012 10:04 PM
DanSmith3
New Contributor II
Hi, I am having a mind blank today - Is it possible to access and change a built in attribute via the set() function? Considering street networks; I am wanting to set the builtin streetWidth attribute based on the number of lanes and lane width given in the rule file, for an ideal outcome see:

set(streetWidth, (nLanes * laneWidth)

Cheers!
0 Kudos
1 Reply
MatthiasBuehler1
Frequent Contributor
hey !


the attr streetWidth is not inherited to the shapes as opposed to e.g. the connectionEnd Object Attributes. (the graph segments inherit some attributes down to their shapes).

if you select a street shape and have a look at it's Object Attributes, you see that they're inherited since they're written in italic (inherited = updates of the graph segment widths will be reflected in the shapes's OA). If you create a new Object Attr on this shape via RMB in the OA tab, you see that the new OA is written normal (not italic).

I know, it's tricky. 🙂

* * *

NOW.
since there's no attr called streetWidth on Street Shapes, you can of course create one manually, but the trick is to map 'scope.sz' to this new attr since it represents the actual width of the shape. The initial scope orientation of Street Shapes is always that scope.sx is 'along' the street and scope.sz is it's width.


Example :

attr myStreetShapeWidth = 0 # initialize the new attr

@StartRule
Street -->
    set(myStreetShapeWidth, scope.sz)
    PrinterRule

PrinterRule -->
    print (myStreetShapeWidth)
    Done.


ok ?
0 Kudos