-
Notifications
You must be signed in to change notification settings - Fork 20
extrude2
Operator extrude2(...) is used to create complex extrusions. It can be applied to rectangular shapes only.
Operator extrude2(...) is best explained by examples. The original rectangular shape is presented on the image below:
Axis x of the shape coordinate system is oriented along the lower edge of the shape. For extrude2(...) operator the left edge has x coordinate equal to zero and the the right edge has x coordinate equal to 1.
Let's apply extrude2(...) operator with the following signature:
extrude2(
0.2, 3,
0.4, 5,
cap2>>MyRule() # optional
)
The extruded shape consists of a number of rectangular sections and lower and upper caps. By default extrusion is generated along x axis of the shape. By default extrusion is symmetric relative to the coordinate 0.5. The first extruded section always starts at x=0 on the level of the original shape. The last section always finishes at x=1 also on the level of the original shape.
The first section in our example goes till x=0.2 and 3 units from the original shape. This explains the first line of arguments 0.2, 3, in our example. The next section starts where the previous one finishes. So the second section in our example starts at x=0.2 and 3 units from the original shape and finishes at x=0.4 and 5 units from the original shape. This explains the second line of arguments 0.4, 5, in our example. Since the extruded shape is symmetric by default, the last section is the symmetric counterpart of the first one. So the last section starts at x=1-0.2=0.8 and 3 units from the original shape and finishes at x=1 on the level of the original shape. Similarly the penultimate section is the symmetric counterpart of the second one. So the penultimate section starts at x=1-0.4=0.6 and 5 units from the original shape and finishes at x=1-0.2=0.8 and 3 units from the original shape.
The middle section parallel to the original shape and the rest of the sections till x=1 are always generated automatically in the symmetric case.
A coordinate along the original shape can take values beyond 0 and 1. A coordinate perpendicular to the original shape can take negative values. If all those coordinates are negative, a niche is generated.
After coordinates for extrusion are defined, rules or operators for some sections or caps can be optionally set. The special word cap1 sets a rule or an operator for the lower cap. The special word cap2 sets a rule or an operator for the upper cap. The special word cap sets a rule or an operator for both lower and upper caps.
In our example we set a rule MyRule() for the upper cap. That rule applies green color to the upper cap.
It is possible to set a rule or an operator for a specific section in the following way:
extrude2(
0.2, 3 >>MyRule1(),
0.4, 5 >>MyRule2(),
cap2>>MyRule()
)
In the that example the rule MyRule1() is applied to the first section. MyRule1() sets blue color to the first section. Similarly, MyRule2() is applied to the second section. MyRule2() sets yellowish color to the second section. Since the extruded shape is symmetric by default, MyRule1() is also applied to the last section and MyRule2() is also applied to the penultimate one.
After optional rule or operator settings keyword arguments can be optionally set.
All allowed special words to set a rule or an operator and all allowed keyword arguments are listed in the tables below.
Special word | Description |
---|---|
section | A rule or an operator for all rectangular sections. |
middle | A rule or an operator for the middle section parallel to the original shape and coming through x=0.5. Only applicable to the symmetric case symmetric=True. |
last | A rule or an operator for the last (closing) section finishing at x=1 on the level of the original shape. Only applicable to the non-symmetric case symmetric=False. You don't need to specify coordinates 1,0 for the closing shape in the non-symmetric case. |
cap1 | A rule or an operator for the lower cap if axis=x or the left cap if axis=y. |
cap2 | A rule or an operator for the upper cap if axis=x or the right cap if axis=y. |
cap | A rule or an operator for both lower and upper caps if axis=x or both left and right caps if axis=y. |
Keyword | Default value | Description |
---|---|---|
symmetric | True | Is the extruded shape symmetric or non-symmetric? In the symmetric case you need to specify only the half of extruded sections starting from x=0. The middle section parallel to the original shape and the rest of the sections till x=1 are always generated automatically in the symmetric case. You don't need to specify coordinates 1,0 for the closing shape in the non-symmetric case. |
axis | x | Coordinate axis along the original shape. Possible values are x or y. |
inheritMaterialSection | False | All rectangular sections inherit material of the original shape. |
inheritMaterialCap | False | Both caps inherit material of the original shape. |
inheritMaterialAll | False | All rectangular sections and both caps inherit material of the original shape. |
extrude2(
0.2, 3,
0.4, 5,
section>>SectionRule(),
cap1>>delete(),
cap2>>MyRule(),
symmetric=False
)
SectionRule() sets magenta color.
extrude2(
0.2, 3 >>MyRule1(),
0.4, 5 >>MyRule2(),
middle>>MiddleRule(),
cap1>>delete(),
cap2>>MyRule()
)
MiddleRule() sets light blue color.
extrude2(
0.2, 3 >>MyRule1(),
0.4, 5,
section>>SectionRule(),
last>>LastRule(),
cap1>>delete(),
cap2>>MyRule(),
symmetric=False
)
SectionRule() sets magenta color. LastRule() sets light blue color.