POST
|
I'm dividing a building into horizontal slices and running an occlusion query, which colors the slices according to the touch results. I'd like to color the last slice touched in a different color. However, I can't figure out how to actually catch the last index. When I print the split.index the results are ordered in the console, suggesting that there does seem to be a way to catch the last split. Is it possible? Rule: version "2015.2"
attr SplitAccuracy = 10
attr BuildingHeight = 200
attr TouchColor = "#AAAAFF"
attr BuildingColor = "#AAFFAA"
attr LineColor = "#FFAAAA"
attr SplitCount = 0
@StartRule
Lot -->
extrude(1)
s(100,BuildingHeight,100) center (xz)
SplitBuildings
SplitBuildings -->
split(y){SplitAccuracy:CompBuildings}*
CompBuildings -->
comp(f) {top : TouchCheck | side : Numbering}
Numbering -->
set(SplitCount, split.index)
texture("assets/no/no_"+SplitCount+".png")
alignScopeToGeometry(zUp, 0, world.lowest)
setupProjection(0, scope.xy, '1.0000, '1.0000)
projectUV(0)
TouchCheck
TouchCheck -->
case touches(inter): TouchedRedlineCase
else : NotTouched
TouchedRedlineCase -->
#"case split.index == last split.index: LineColorColor"
case split.index == 3 : LineColorColor
else: TouchColorColor
NotTouched --> color(BuildingColor)
LineColorColor --> color(LineColor)
TouchColorColor --> color(TouchColor) Result, with manual setting of the split index:
... View more
02-16-2016
03:24 PM
|
0
|
2
|
1842
|
POST
|
Thanks. I think I got it now. I built two layer lists and used them to set the right attributes for the objects in the layer groups. The rule accepts true/false as text because I changed it to do so since I couldn't figure out how to set a boolean true/false . However it still would be nice to set the right attribute type. Deleting the layers isn't feasible, they have to stick around for quick comparisons. Here's the code, maybe someone else will find it useful: from scripting import *
# List of visible Layers
VisibleLayersNames = ["Scene Light", "Panorama", "Layer01", "Layer03", "Touches"]
VisibleLayers = []
InvisibleLayers = []
AllLayerNames = []
ce = CE()
@noUIupdate
def main():
# get visible layers
for i in range(len(VisibleLayersNames)):
VisibleLayer = ce.getObjectsFrom(ce.scene, ce.isLayer, ce.withName(VisibleLayersNames))
VisibleLayers.extend(VisibleLayer)
# get all layers
AllLayers = ce.getObjectsFrom(ce.scene, ce.isLayer)
#get all layer names
for j in range(len(AllLayers)):
LayerName = ce.getName(AllLayers )
AllLayerNames.append(LayerName)
# set layer visibility
for Layer in AllLayers:
if str(Layer) in VisibleLayersNames:
Layer.setVisible(True)
else:
Layer.setVisible(False)
# get invisible layer names
InvisibleLayersNames = list(set(AllLayerNames).difference(set(VisibleLayersNames)))
# get invisible layers
for k in range(len(InvisibleLayersNames)):
InvisibleLayer = ce.getObjectsFrom(ce.scene, ce.isLayer, ce.withName(InvisibleLayersNames ))
InvisibleLayers.extend(InvisibleLayer)
# set generate attribute for visible layers
for VisibleLayer in VisibleLayers:
VisibleObjects=ce.getObjectsFrom(VisibleLayer)
for VisibleObject in VisibleObjects:
ce.setAttribute(VisibleObject, 'generate', 'true')
# set generate attribute for invisible layers
for InvisibleLayer in InvisibleLayers:
InvisibleObjects=ce.getObjectsFrom(InvisibleLayer)
for InvisibleObject in InvisibleObjects:
ce.setAttribute(InvisibleObject, 'generate', 'false')
if __name__ == '__main__':
main()
... View more
01-30-2016
07:08 AM
|
1
|
6
|
1250
|
POST
|
Ah no, I want to prevent touches() from triggering when the object is invisible. I'm almost there (?) however I have a little problem. How do I select the appropriate objects? The current code sets the visibility properly but also every object's "generate" to true. I figured there'd be a "select objects by layer name" but I can't find anything. Also how do I set a boolean value as attribute? My true/false isn't a "real" true/false, so I'm not getting a on/off slider. Here's a screenshot for clarification. Larger cubes: contents of Layer01-04. The cubes have a case for extrusion or NIL, depending on their "generate" attribute. The purple cubes use a rule with the touches() query. The idea is that invisible cubes don't trigger the purple ones. script: from scripting import *
# List of visible layers
LayerName = ["Layer01", "Layer02", "Touches"]
ce = CE()
@noUIupdate
def main():
layers = ce.getObjectsFrom(ce.scene, ce.isLayer)
shapes = ce.getObjectsFrom(ce.scene, ce.isShape)
for layer in layers:
if str(layer) in LayerName:
layer.setVisible(True)
for shape in shapes:
ce.setAttribute(shape, 'generate', 'true')
#ce.setAttribute(shape, 'generate', 'false')
else:
for shape in shapes:
ce.setAttribute(shape, 'generate', 'false')
layer.setVisible(False)
#ce.generateModels(shapes)
#ce.waitForUIIdle()
if __name__ == '__main__':
main()
... View more
01-29-2016
07:27 AM
|
0
|
10
|
1250
|
POST
|
The example works for the layers, thanks. However I'm trying to use the visibility in conjunction with an occlusion query. Turning layer visibility off or deleting the model doesn't keep the touches() function from triggering. Only when I don't generate a model through its rule (like case visible == true: extrude(5), else: NIL) does the query work as expected. Should I just give all the objects from the layer a visibility attribute (ce.setAttribute) and change that to false with python before generating or is there a proper way?
... View more
01-27-2016
04:38 AM
|
0
|
12
|
1250
|
POST
|
Hi, thanks, I already did that. The problem were the shape's multipart features - changing them to singlepart fixed the problem.
... View more
01-27-2016
03:14 AM
|
0
|
1
|
403
|
POST
|
I can fetch a layer list, and I can fetch the objects from a certain layer. However, I can't find anything that changes their visibility. Is that not implemented? If it is, is it possible to run a script that I could use for toggling visibility based on a variable within the script? AFAIK the whole script is always run, so if I define switch variables and change them, they're reset every time I run the script again.
... View more
10-07-2015
06:31 AM
|
2
|
18
|
5350
|
POST
|
Inserting doesn't put an object onto the wall, it replaces that bit of wall.
... View more
10-07-2015
06:24 AM
|
1
|
0
|
582
|
POST
|
I'm using the touches() function with multiple layers containing models of different heights (think flood scenarios). However I've ran into a problem: the touches() function triggers even when models from invisible layers are touching a visible model. Can I prevent that somehow? Image for clarification, building is being moved into the invisible blue block:
... View more
10-07-2015
05:59 AM
|
0
|
0
|
1805
|
POST
|
Going by face index (as opposed to front, etc) gives you full control but also requires more work since you, AFAIK, can't mix top/bottom/front/etc and face indexes. Try this on a T-shape: Lot -->
extrude(200)
comp(f){
0: zero | 1: one | 2: two | 3: rc
| 4: rc | 5: rc | 5: rc | 6:rc |
7: rc | 8: rc | 9:rc }
zero -->
split(x){~0.5: rc | ~0.5: rc}
one --> color(rand,rand,rand)
two --> color(rand,rand,rand)
rc --> color(rand,rand,rand)
... View more
09-29-2015
01:05 PM
|
2
|
0
|
1525
|
POST
|
I have a rather large and complex shape I created from a flood raster in ArcMap*. When I imported it into CE and tried to test it with touches(), the function didn't trigger. I then simplified the shape in ArcMap and tried again, but that did nothing. I then created a few similar shapes manually in CE and they worked. What could be the problem here? Is there a limit on the shape size, geometry or complexity? Screenshot: 1: Shape created in CE, 40 vertices 2: Shape created in CE, 78 vertices 3: Shape created in Arcmap which reports 117 vertices (according to CE's geometry.nVertices(): 101) 4: Shape created in ArcMap from the above one (simplified), ArcMap: 54, CE: 37 vertices 5: Shape created in ArcMap, 4 vertices The cubes are the "touch-tester", with yellow indicating a touch. *I tried two ways, "raster to polygon" and "raster domain", but both lead to the same results.
... View more
09-29-2015
12:36 PM
|
0
|
3
|
2782
|
POST
|
I guess that's the best currently available solution for the problem. Thanks.
... View more
07-24-2015
08:58 AM
|
0
|
0
|
385
|
POST
|
I can right-click on a building in the viewport and select other objects which use the same rule file as it. Is there any way to do this using a rule file? Basically, I want to select a rule and see where (or if!) it’s been assigned. Right now I’m checking this by giving the rule a large extrusion so it’s easy to spot corresponding objects visually in the viewport, but I wonder if there’s a better way.
... View more
07-24-2015
03:44 AM
|
0
|
2
|
3026
|
POST
|
I used some shp files containing Umlauts in their attributes. I checked them beforehand in ArcMap and the characters displayed properly. The cpg file tells me the encoding is UTF-8. However the attributes don't display right in CE (2014, but I had someone who uses 2015.1 check too). Example: "Gebäude", which should be "Gebäude". I experimented a bit trying to fix this: I changed (right-click -> properties) the project folder's encoding, the data folder's encoding, the shp file's encoding (and all of the accompanying files: cpg, dbf, prj, sbn, sbx) and the scene's encoding. I also tried adding the shp again as new layer in the old scene and in a new scene but that brought no results. I also tried to create a completely new project, changed its encoding to UTF-8 from Cp1252 (Windows default - "inherited from container", although I'm not sure which container it's referring to since the project folder is the topmost container), before adding any data. I then added some new shp files to the project (their encoding was left at default which is now also "Inherited from container (UTF-8")) and tried to use them in a new scene but that didn't work either. Is this encoding reassignment simply not supported?
... View more
07-24-2015
03:30 AM
|
0
|
1
|
5305
|
POST
|
As far as I can tell, the cube is easier to manipulate. innerRect would produce a rectangle somewhere inside the lot and I'd need to translate, rotate and scale it.
... View more
02-05-2015
03:14 PM
|
0
|
1
|
572
|
POST
|
Here's how I do it. Lot -->
extrude(5)
#comp(f){all: Texture} #this would texture everything;
#the stuff below addresses every side on its own. side: also works, to address all sides.
comp(f){
left: rc |
right: rc |
top: Texture |
bottom: rc |
front: rc |
back: rc
}
Texture -->
setupProjection(0, scope.xy, 1, 1)
texture("images/bricks.jpg")
projectUV(0)
rc --> color(rand,rand,rand)
... View more
02-05-2015
01:17 PM
|
2
|
1
|
617
|
Title | Kudos | Posted |
---|---|---|
1 | 07-13-2018 02:05 AM | |
1 | 08-08-2016 06:59 AM | |
1 | 07-12-2018 09:08 AM | |
3 | 04-12-2019 08:20 AM | |
1 | 12-14-2017 07:12 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|