I'm using 2016.1 and when I try to connect an attribute to my rule file, I am unable to make the connection unless my parameter has an identical name to the attribute that I am trying to map. From my understanding, I should be able to select any alternate layer and attribute name and map it to my shape. Does anybody know why this is happening, or how to get around this issue? Is this a bug? See images attached:
Here I'm creating a basic extrusion with attr height, and I want to connect attribute Z_Max, but I don't have the ability to do so:
I've now changed my rule file to name the attribute Z_Max, which matches my object attribute that I've imported in the shapefile. Now I have the ability to map Z_Max, as well as any other attribute that's available in my scene.
Solved! Go to Solution.
Hi David,
Users do not and should not need to change CGA code for it to map. Another thing I would suggest is the following.
1. Use Import Data- Grab any aerial image tile. Check if import options exist.
2. Add an image. Check if the mapping options exist.
This is likely a bug with the layer mapping, but I have found I can do mappings pretty easily once there is an image and a map layer to reference. Let me know if this fixes it. I don't usually encounter this issue if I start by adding an image map to the scene (Get Map Data).
David
I have had this problem before and know it well.
CityEngine really only maps directly to shape attributes if they share object attributes names with rule parameters. This means a shapefile must have field names that match the rule parameters for an automatic mapping with a single layer.
The connection feature requires another copy of the same layer to "map to", and can thus feel a little strange to work with if you have only one layer in the scene.
To use the connect to layer feature you do the following:
1. Import a layer via Shape/FGDB etc.
2. Copy the layer in the scene.
3. Rename it "Map Layer"
3b. Import an image into CE or use Get Map Data (Resolved Bug see below). EDIT
4. Open up Connection Editor- Choose Map Layer,then the attribute.
Let me know if this does not work, there are other things to try.
David
Thanks for the response David. Unfortunately this still didn't work for me. I duplicated the layer and then tried to make an attribute connection but the options are still all greyed out.
From your suggestions I figured out a workaround here but it doesn't really make sense for an efficient workflow:
Here I have attr height with no height object attribute, so the connection editor is disabled.
I clicked the "add new object attribute" button and added value "height" with a 0 value. Then I was able to open the connection editor and map my layer to the proper height layer, Z_Max.
It just doesn't make sense that a connection editor can only become enabled if it detects a matching object attribute, even if that object attribute isn't the one that actually needs to be mapped. It creates a lot of issues if we are trying to create user-friendly CGA scripts. If I make a "universal" script to extrude building heights, I would expect that a user could choose to make a connection to their own height feature attribute, whether the attribute is called "height", "HEIGHT", "bldgHeight", etc... The user shouldn't need to go into the CGA and manually update the code to work with their own imported features.
Hi David,
Users do not and should not need to change CGA code for it to map. Another thing I would suggest is the following.
1. Use Import Data- Grab any aerial image tile. Check if import options exist.
2. Add an image. Check if the mapping options exist.
This is likely a bug with the layer mapping, but I have found I can do mappings pretty easily once there is an image and a map layer to reference. Let me know if this fixes it. I don't usually encounter this issue if I start by adding an image map to the scene (Get Map Data).
David
I just tried adding an aerial from Get Map Data and my exact same CGA script works and height can now be mapped to my object attributes.... that's so weird.
Thanks so much for your help - it's greatly appreciated!
Hopefully this will be fixed up in the next release of CE as it's clearly a bug.
Yeah glad that worked. I was not sure if this bug was just me for a while, and I am glad I am not the only one who can replicate it. 😃
Chris Wilkins is this a known bug? Who should we check with?
Hi David and David,
I've reported it. I'll post back here with results. Or they might.
Thanks for your bug identification skills!
It seems like this is a bug. Thanks for posting and helping us find this one. Yes, you should be able to link to the layer attributes with different names than your rule attribute names.
I also found another workaround. You don't have to import any image data. In fact, if you just create an object or layer attribute with the name height (to match the rule attribute name), then this seems to open up access to the layer attribute linking in the connection editor (as you found out). Then, you can link the rule attribute to any attribute even if it doesn't have the same name (as you also wrote). But, you can also go and delete the original height attribute, and the attribute will continue to be linked to the layer attribute with the different name. I'm not sure if this helps your workflow or not though.
Interesting. That might explain why adding another layer worked one time for me. I don't recall if it had a same attribute name for it however. Thanks for the find.
Another bug I found is that the get map data function is not in the python API, but that might be a feature request though...