POST
|
First, attributes should be set on shape objects (instead of models): objects = ce.getObjectsFrom(ce.selection, ce.isShape) Second, the rule attribute name should be preceded by "/ce/rule/": h = ce.getAttribute(o, '/ce/rule/height') Lastly, rule attributes only appear in the list returned by ce.getAttributeList() if they are user set. This means we can only set them in Python if we first make them user-set attributes. There are two options for this. The first option (a simple workaround) is good if this is just a one time operation that you'd like to do because it involves manually setting the attribute. The second option is more complicated but will work if you'd like everything to work within the python script without having to set anything manually. In this case, we make the attributes user-set by way of an extra python script that is run from your first python script. Option 1: 1) Select your shapes. 2) Set the height attribute in the Inspector to 10. This is the value it already was set to by the rules, but by resetting it through the Inspector we are making a user-set attribute instead of a rule-set attribute. The number now appears bold indicating that it is a user set attribute. 3) Now you can run the python script (with the two changes above). Option 2: 1) Create an export python script. Right click on the scripts folder -> New -> Python Module -> Select Module:Export (Reporting) and choose a name (e.g. coexport.py). 2) In the finishModel() function, add the following code to make the attribute a user set attribute: ce.setAttributeSource(shape, "/ce/rule/height", "USER") 3) In your first python script, add some lines (after you get the objects but before the for loop) to run the export script you just created: expSettings = ScriptExportModelSettings() expSettings.setScript("coexportscript.py") ce.export(objects, expSettings) 4) Now you can run the first python script (with the two changes above).
... View more
02-15-2016
02:33 AM
|
3
|
5
|
2675
|
POST
|
Just confirming Eric's post. Currently, there is no way to call Python externally without running the CityEngine GUI (in any current version of CE), but this might be something we would look into if there is a demand for it, so thanks for sharing your issues.
... View more
02-09-2016
01:23 AM
|
1
|
0
|
656
|
POST
|
What version of CityEngine are you using? There might have been problems with previous versions of CE. What is the exact filename of your file? We found a bug where the facade wizard had problems opening files with extensions in capital letters (e.g. .JPG). In this case, if you rename the file to a lower case extension (e.g. .jpg), then it should work.
... View more
02-09-2016
01:16 AM
|
0
|
2
|
811
|
POST
|
No, sorry, it is currently not possible to call CE python scripts from outside of the GUI/externally. It's good to know that there's a demand for this though, so we appreciate your post.
... View more
02-04-2016
09:59 AM
|
1
|
3
|
832
|
POST
|
No, sorry, it is currently not possible to call CE python scripts from outside of the GUI/externally. It's good to know that there's a demand for this though, so we appreciate your post.
... View more
02-04-2016
09:58 AM
|
1
|
0
|
811
|
POST
|
I assume you want to set the attributes in the Plant Loader based on values you already have somewhere else. Perhaps you have a set of shapes with object attributes that contain this info. Yes, the names of your object attributes have to be the same as the attribute names in the rules. According to the rules, the attribute Name will be set to "Orange Tree" by default. This is a rule set attribute (because its value is determined by the rules). This can be changed by manually setting the value for this attribute in the Inspector. Then, the attribute becomes a user set value (indicated by bold font for the value of the attribute in the Inspector). Or, another way to set the value of this attribute is to link it to an object attribute so that it gets its value from the object attribute of the same name. I assume this is the option that you are looking for. To do this, select your shapes, click on the icon (square with arrow) between the attribute name and the value field in the Inspector, select "Object Attribute". This will make the attribute get its value from the object attribute of the same name. Note that for this to work, the rule attribute has to have the same exact name as the object attribute.
... View more
02-04-2016
01:22 AM
|
0
|
0
|
418
|
POST
|
According to the rules, the value for the attribute VisCode will be set to the empty string by default. This is a rule set attribute (because its value is determined by the rules). This can be changed by manually setting the value for this attribute in the Inspector. Then, the attribute becomes a user set value (indicated by bold font for the value of the attribute in the Inspector). Or, another way to set the value of this attribute is to link it to an object attribute so that it gets its value from the object attribute of the same name. I assume this is the option that you are looking for. To do this, select all your shapes (that you want to apply the rule to), click on the icon (square with arrow) between the attribute name and the value field in the Inspector, select "Object Attribute". This will make the attribute get its value from the object attribute of the same name. Note that for this to work, the rule attribute has to have the same exact name as the object attribute. So, for the rule attribute VisCode, you will need the shape to have an object attribute called VisCode.
... View more
02-04-2016
12:45 AM
|
0
|
1
|
1060
|
POST
|
Sorry, I misunderstood the situation (I thought you knew the inner and outer boundaries while exporting in Python). No, I don't think you can get the hole using CGA operations on a shape with a hole. However, if you are creating your shape in Python, then you might be able to create a face for the hole. (I don't really know how you are getting your initial shapes, but if you can create a face for everything including the hole, then the following will work.) Then, if there are multiple faces, you can use the comp split to separate the border faces from the inside faces. comp(f) { border = Border | inside = Hole } (Note, the = is used instead of : to keep all the border faces (if there are multiple) together as a single shape, but you can use : if you'd rather separate the faces into different shapes.)
... View more
02-01-2016
07:00 AM
|
0
|
0
|
418
|
POST
|
Maybe you could export the vertices marked on the inner boundary as a separate shape. Then you can apply a rule to that shape.
... View more
02-01-2016
05:00 AM
|
0
|
2
|
418
|
POST
|
The help pages say that occlusion testing should only work on closed geometries: In any case, tests can only be performed against geometries which form a closed surface (i.e. a waterproof mesh which has no boundary edges), other geometries are ignored. Occlusion Query Functions (end of the first paragraph after the table) I'm not sure why the tests worked on the polygons. (I tried to recreate your test 1 with just a rectangular shape and a cube, but I couldn't get the test to detect the occlusion.) In any case, doing the extrude to create some 3D geometry followed by a component split should solve the problem as Matt suggested. This works because the component split creates a ghost model (of the shape before the comp happens) that is used for occlusion testing.
... View more
01-28-2016
02:07 AM
|
0
|
0
|
433
|
POST
|
The code looks ok to me. I would expect all the shapes to be green unless you manually change the VisCode to 1 for some shapes (and these would be magenta). What is the problem you are encountering?
... View more
01-28-2016
01:23 AM
|
0
|
3
|
1060
|
POST
|
Ok, so I was under the assumption that you had one shape with multiple faces. In this case, the split operation would work, but if you had multiple initial shapes, there's no way to combine them in the rules. I would suggest combining all the shapes into a single shape either in CE or in the software you are using to generate the shapefile. You could combine all the shapes into one shape in CityEngine by selecting them -> Shapes -> Combine Shapes. This will give you a single shape with multiple faces. Then you can apply a rule to the single shape. Or, you could combine all the shapes into a single shape before you export your shapefile. It should be a similar procedure as in CityEngine (select all the polygons, then find the menu item to combine the polygons).
... View more
01-28-2016
01:19 AM
|
0
|
1
|
1338
|
POST
|
If the GDB contains a multipatch feature class, then you will get shapes in CityEngine. However, if the GDB contains lines, then you will get a graph network in CityEngine. You can write rules that can be applied to the street shapes generated on the graph network. You cannot directly apply rules to the network, but you can apply the rule to the street shape and make the streetWidth as small as you want and make the sidewalks 0.
... View more
01-27-2016
02:38 AM
|
0
|
5
|
1060
|
POST
|
I'm not sure what you are referring to when you say "grids". Are you referring to each face of your building footprint? What is the shape that you apply the split rule to? What is your initial shape? Is it a single initial shape with many faces? Or, are there many initial shapes? Since I don't fully understand the situation, here are some general examples that might help you determine how to split your shapes to get what you want. If you start with a single initial shape (which contains many faces), then you can use split() to separate it into two parts: Lot --> split(x) { '0.5 : A | '0.5 : B } Then, part A will contain all the faces on the first half, and part B will contain all the faces on the second half. I think this is probably along the lines of what you want to do if you want to keep some faces together. If you use comp(f), then you separate your initial shape into faces where each face becomes a different shape, unless you use the = operator. This code separates the shape into different faces where each face is a Face shape. Lot --> comp(f) { all : Face } This code separates the shape into faces but keeps all the vertical faces together as a single shape VerticalFaces. The non-vertical faces are separated into individual Face shapes. Lot --> comp(f) { vertical = VerticalFaces | all : Face }
... View more
01-27-2016
01:40 AM
|
0
|
3
|
1339
|
POST
|
You can set the building height to whatever you want. I just chose random heights as an example, but you can put in your own calculations. If you want to divide something into parts, then you'll probably want to use the split() operation: split Operation Or, if you want to separate out the individual faces, then you'll probably want to use the comp() operation: Component Split Operation
... View more
01-26-2016
01:00 AM
|
0
|
6
|
1338
|
Title | Kudos | Posted |
---|---|---|
1 | 12-14-2022 07:18 AM | |
1 | 06-22-2020 04:54 AM | |
1 | 02-17-2020 03:10 AM | |
1 | 07-03-2023 03:37 AM | |
1 | 06-07-2023 05:26 AM |
Online Status |
Offline
|
Date Last Visited |
10-19-2023
12:40 PM
|