+ Reply to Thread
Results 1 to 4 of 4

Thread: Map Attributes from rules

  1. #1
    Robert Hexter
    Join Date
    Mar 2012
    Posts
    78
    Points
    5
    Answers Provided
    1


    0

    Default Map Attributes from rules

    How do I have a cga rule attribute retrieve and use a value from a particular source Layer, if I do not want to set a shapes attribute source manually in the Inspector?(I may want to use different image maps (sources) to control a particular attribute under different rule conditions)

    cgaFile - pseudoCode:

    attr value=getValueFromLayer(Layer, Layer_Attribute)
    attr height=getValueFromLayer("map1", "buildingHeight")

    Sorry if this is very obvious, I'm getting lost in the help documentation and the way some of it is written.

  2. #2
    Matthias Buehler

    Join Date
    Oct 2011
    Posts
    1,688
    Points
    441
    Answers Provided
    142


    0

    Default Re: Map Attributes from rules

    hey !

    that's easy to do.



    just create a new Map Layer of the 'mapping type'. choose your image file and create an attribute in the dialog. once the layer has been generated, you can check (and edit) the layer attributes in the Inspector.

    usually, I create mapped attributes based on the image brightness, then create a simple function which maps that value range from 0-1 to a desired range, e.g. 300 x brightness + 20

    once this is created, point your CGA rule via the Attribute Connection Editor to the specific layer's target attr value.

    don't forget to initialize the attr in your rule too ! (e.g. just attr mappedHeight = 0)

    let me know if it works.
    _________________

    CityEngine Machinist

    * YOUTUBE CHANNEL : www.youtube.com/channel/UCNS4TLgToEDQiH9pi06ofOA
    * tutorial videos : http://forums.arcgis.com/threads/648...URCES-FAQ-HELP
    * Please use the rating buttons on the right side !

  3. #3
    Robert Hexter
    Join Date
    Mar 2012
    Posts
    78
    Points
    5
    Answers Provided
    1


    0

    Default Re: Map Attributes from rules

    Thanks for the reply,

    I am confused by this:

    point your CGA rule via the Attribute Connection Editor to the specific layer's target attr value.

    If I have this initialized in my rule:

    attr mappedHeight = 0

    how do I:

    point your CGA rule via the Attribute Connection Editor

    I am currently only understanding this to be a manual process of changing the shapes attribute source input within the Attribute Connection Editor?
    I would like to have the rule tell the shape what its specific layer/map and attribute of interest is, not do it myself.


    I am confused because I want to, within my rule, have the rule determine the connection to which mapLayer:

    //set/connect the shapes "mappedHeight" attribute, to the MapLayers attribute "mappedHeight", where MapLayer is determined by something else..
    set(shape.mappedHeight, MapLayer.mappedHeight)
    Last edited by rhexter; 04-30-2012 at 10:43 AM.

  4. #4
    Matthias Buehler

    Join Date
    Oct 2011
    Posts
    1,688
    Points
    441
    Answers Provided
    142


    0

    Default Re: Map Attributes from rules

    first step : check the following manual page, it shows the Connection Editor basics :

    Help > Manual > Mapping Attributes > Mapping Attributes with Connection Editor

    [ check the attr icon with the black triangle pointing in a rectangle ]


    additionally :
    it is important to understand that CityEngine uses some heuristics to find the right connections automatically when a rule is assigned to a shape :

    If you assign a rule e.g. to a 'Lot' via Drag'n'Drop, CityEngine checks if :
    1st priority] an Object Attr exists for the initialized attrs. If so, the connection automatically is made to the Object Attr
    2nd priority] a Map Layer attribute exists for the initialized attrs. If so, the connection automatically is made to the corresponding Map Layer attr
    3rd priority] the Rule value is used



    I hope this helps you further !

    oh, and also good to know, the @StartRule annotation adapts some behavior : Once drag-n-dropped and a StartRule is defined within a cga rule file, the model generation is directly triggered ( great for demos ! ).



    let me know if questions remain.
    Last edited by matthiasbuehler; 04-30-2012 at 11:29 AM.
    _________________

    CityEngine Machinist

    * YOUTUBE CHANNEL : www.youtube.com/channel/UCNS4TLgToEDQiH9pi06ofOA
    * tutorial videos : http://forums.arcgis.com/threads/648...URCES-FAQ-HELP
    * Please use the rating buttons on the right side !

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts