Closed vvoovv closed 2 years ago
Scope modificator (_perbuilding(..), etc) can be applied to any part of the alternative expression or to the whole alternative expression.
See the attached PML file.
Scope modificator (per_building(..), etc) can be applied to any part of the alternative expression or to the whole alternative expression.
Should work now. per_building() was the only function that takes another function as argument within alternatives.
It outputs
claddingColor = Value(Alternatives(
FromAttr("building:colour", FromAttr.Color)PerBuilding(,
FromBldgAttr("building:colour", FromAttr.Color)),
Conditional(
lambda item: item.getStyleBlockAttr("claddingMaterial") == "brick"PerBuilding(,
RandomWeighted( (((0.482, 0.259, 0.184, 1.0),1),((0.773, 0.463, 0.365, 1.0),1),((0.592, 0.424, 0.42, 1.0),1)) ))
)PerBuilding(,
RandomWeighted( (((0.482, 0.259, 0.184, 1.0),1),((0.773, 0.463, 0.365, 1.0),1),((0.592, 0.424, 0.42, 1.0),1)) ))
))
That raises a syntax error.
The output should be:
claddingColor = Value(Alternatives(
PerBuilding(FromAttr("building:colour", FromAttr.Color)),
FromBldgAttr("building:colour", FromAttr.Color)),
Conditional(
lambda item: item.getStyleBlockAttr("claddingMaterial") == "brick",
PerBuilding(RandomWeighted( (((0.482, 0.259, 0.184, 1.0),1),((0.773, 0.463, 0.365, 1.0),1),((0.592, 0.424, 0.42, 1.0),1)) ))(
),
PerBuilding(RandomWeighted( (((0.482, 0.259, 0.184, 1.0),1),((0.773, 0.463, 0.365, 1.0),1),((0.592, 0.424, 0.42, 1.0),1)) )))
))
That's weird? Using the code I commited yesterday, I get
claddingColor = Value(Alternatives(
FromAttr("building:colour", FromAttr.Color),
PerBuilding(
FromBldgAttr("building:colour", FromAttr.Color)
),
Conditional(
lambda item: item.getStyleBlockAttr("claddingMaterial") == "brick",
PerBuilding(
RandomWeighted( (((0.482, 0.259, 0.184, 1.0),1),((0.773, 0.463, 0.365, 1.0),1),((0.592, 0.424, 0.42, 1.0),1)) )
)
),
PerBuilding(
RandomWeighted( (((0.482, 0.259, 0.184, 1.0),1),((0.773, 0.463, 0.365, 1.0),1),((0.592, 0.424, 0.42, 1.0),1)) )
)
))
Did you get the changes of the two methods of PythonCoder.py starting here?
@polarkernel Sorry for the confusion. I used the old version of the pml repo in the blender-osm addon. Yes, it works.
The following PML file gives a Python syntax error.
What is more important, the output is incorrect.
It should be
claddingColor = (1.0, 0.0, 0.0, 1.0)
intead of
claddingColor = Value(Constant((1.0, 0.0, 0.0, 1.0))
The following PML file gives a Python syntax error.
Fixed.
It works now. Thanks.
Parsing of empty markup fails
Fixed. What sense does that make? Couldn't the markup just get omitted?
I wanted to test something with and without markup and promptly switching between those two cases. That's how I encountered that bug.
It works now.
The first part is here