Is automatic seed update possible with Python?

438
2
Jump to solution
07-27-2019 03:32 PM
MikeJane
New Contributor III

  Hello guys, there is something I cant resolve.

  In my project, I randomly determine the horizontal and vertical dimensions of buildings with cga rule.For example between 10-20 meters.

   What I want to do is regenerate shape until BuildingFootprint Area / Parcel Area > 0.3 when BuildingFootprint Area / Parcel Area < 0.3.

   My problem is ;  If the conditions do not occur, the cga rule does not regenerate the seed values.If conditions do not occur, can a python script be written to automatically update seed values and regenerate shapes until the condition occurs?

   If you can, can you help me with this, because I don't know about Python scripting.

Here is my cga rule :

*************************************************************************************

attr BuildingX = rand (8,30)
attr BuildingZ = rand (8,30)


attr GFAR = BuildingX*BuildingZ/geometry.area

Lot-->
split(x) { ~1 : Space | BuildingX : split(z) { ~1 : Space | BuildingZ : Building | ~1 : Space } | ~1 : Space }

Building-->
case GFAR > 0.3 : Building
else:CorrectBuilding

CorrectBuilding-->extrude(8)

***************************************************************************************

0 Kudos
1 Solution

Accepted Solutions
CherylLau
Esri Regular Contributor

The problem is that when Building is recursively called, GFAR is not recalculated.  It is initialized to a value (depending on the seed), and then it stays that same value as the rules are derived.  This creates an endless recursion.  Attributes are initialized at the beginning and don't change during rule derivation (unless they are specifically set).  Changing the seedian with python won't make GFAR change its value during rule derivation.

I would suggest initializing all attributes to valid values independent of the rule derivation.  Perhaps you can initialize GFAR and BuildingX to values in the desired ranges and calculate the appropriate BuildingZ value from them.  It is also possible to use recursive functions to define your attributes before any rule derivation happens.

View solution in original post

2 Replies
CherylLau
Esri Regular Contributor

The problem is that when Building is recursively called, GFAR is not recalculated.  It is initialized to a value (depending on the seed), and then it stays that same value as the rules are derived.  This creates an endless recursion.  Attributes are initialized at the beginning and don't change during rule derivation (unless they are specifically set).  Changing the seedian with python won't make GFAR change its value during rule derivation.

I would suggest initializing all attributes to valid values independent of the rule derivation.  Perhaps you can initialize GFAR and BuildingX to values in the desired ranges and calculate the appropriate BuildingZ value from them.  It is also possible to use recursive functions to define your attributes before any rule derivation happens.

MikeJane
New Contributor III

Thank you for the suggestion. The set function solves the problem.

0 Kudos