Fix #105067: Node Wrangler: cannot preview multi-user material group
[blender-addons.git] / add_mesh_extra_objects / Wallfactory.py
blob61c13f68281dea6fba2c08a536ab01d5cb6abaf9
1 # SPDX-FileCopyrightText: 2016-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 # authors: dudecon, jambay
7 # This module contains the UI definition, display,
8 # and processing (create mesh) functions.
9 # The routines to generate the vertices for the wall
10 # are found in the "Blocks" module.
13 import bpy
14 from bpy.types import Operator
15 from bpy.props import (
16 BoolProperty,
17 FloatProperty,
18 StringProperty,
20 from .Blocks import (
21 NOTZERO, PI,
22 dims,
23 settings,
24 shelfSpecs,
25 stepSpecs,
26 createWall,
27 radialized,
28 slope,
29 openingSpecs,
30 bigBlock,
31 shelfExt,
32 stepMod,
33 stepLeft,
34 shelfBack,
35 stepOnly,
36 stepBack,
38 from bpy_extras import object_utils
40 class add_mesh_wallb(Operator, object_utils.AddObjectHelper):
41 bl_idname = "mesh.wall_add"
42 bl_label = "Add a Masonry Wall"
43 bl_description = "Create a block (masonry) wall mesh"
44 bl_options = {'REGISTER', 'UNDO'}
46 # UI items - API for properties - User accessible variables...
47 # not all options are via UI, and some operations just don't work yet
49 Wall : BoolProperty(name = "Wall",
50 default = True,
51 description = "Wall")
53 #### change properties
54 name : StringProperty(name = "Name",
55 description = "Name")
57 change : BoolProperty(name = "Change",
58 default = False,
59 description = "change Wall")
61 # only create object when True
62 # False allows modifying several parameters without creating object
63 ConstructTog: BoolProperty(
64 name="Construct",
65 description="Generate the object",
66 default=True
68 # need to modify so radial makes a tower (normal);
69 # want "flat" setting to make disk (alternate)
70 # make the wall circular - if not sloped it's a flat disc
71 RadialTog: BoolProperty(
72 name="Radial",
73 description="Make masonry radial",
74 default=False
76 # curve the wall - if radial creates dome.
77 SlopeTog: BoolProperty(
78 name="Curved",
79 description="Make masonry sloped, or curved",
80 default=False
82 # need to review defaults and limits for all of these UI objects
84 # wall area/size
85 WallStart: FloatProperty(
86 name="Start",
87 description="Left side, or start angle",
88 default=-10.0,
89 min=-100, max=100.0
91 WallEnd: FloatProperty(
92 name="End",
93 description="Right side, or end angle",
94 default=10.0,
95 min=0.0, max=100.0
97 WallBottom: FloatProperty(
98 name="Bottom",
99 description="Lower height or radius",
100 default=0.0,
101 min=-100, max=100
103 WallTop: FloatProperty(
104 name="Top",
105 description="Upper height or radius",
106 default=15.0,
107 min=0.0, max=100.0
109 EdgeOffset: FloatProperty(
110 name="Edging",
111 description="Block staggering on wall sides",
112 default=0.6, min=0.0, max=100.0
114 # block sizing
115 Width: FloatProperty(
116 name="Width",
117 description="Average width of each block",
118 default=1.5,
119 min=0.01, max=100.0
121 WidthVariance: FloatProperty(
122 name="Variance",
123 description="Random variance of block width",
124 default=0.5,
125 min=0.0, max=100.0
127 WidthMinimum: FloatProperty(
128 name="Minimum",
129 description="Absolute minimum block width",
130 default=0.5,
131 min=0.01, max=100.0
133 Height: FloatProperty(
134 name="Height",
135 description="Average Height of each block",
136 default=0.7,
137 min=0.01, max=100.0
139 HeightVariance: FloatProperty(
140 name="Variance",
141 description="Random variance of block Height",
142 default=0.3,
143 min=0.0, max=100.0
145 HeightMinimum: FloatProperty(
146 name="Minimum",
147 description="Absolute minimum block Height",
148 default=0.25,
149 min=0.01, max=100.0
151 Depth: FloatProperty(
152 name="Depth",
153 description="Average Depth of each block",
154 default=2.0,
155 min=0.01, max=100.0
157 DepthVariance: FloatProperty(
158 name="Variance",
159 description="Random variance of block Depth",
160 default=0.1,
161 min=0.0, max=100.0
163 DepthMinimum: FloatProperty(
164 name="Minimum",
165 description="Absolute minimum block Depth",
166 default=1.0,
167 min=0.01, max=100.0
169 MergeBlock: BoolProperty(
170 name="Merge Blocks",
171 description="Make big blocks (merge closely adjoining blocks)",
172 default=False
174 # edging for blocks
175 Grout: FloatProperty(
176 name="Thickness",
177 description="Distance between blocks",
178 default=0.1,
179 min=-10.0, max=10.0
181 GroutVariance: FloatProperty(
182 name="Variance",
183 description="Random variance of block Grout",
184 default=0.03,
185 min=0.0, max=100.0
187 GroutDepth: FloatProperty(
188 name="Depth",
189 description="Grout Depth from the face of the blocks",
190 default=0.1,
191 min=0.0001, max=10.0
193 GroutDepthVariance: FloatProperty(
194 name="Variance",
195 description="Random variance of block Grout Depth",
196 default=0.03,
197 min=0.0, max=100.0
199 GroutEdge: BoolProperty(
200 name="Edging",
201 description="Grout perimiter",
202 default=False
204 # properties for openings
205 Opening1Tog: BoolProperty(
206 name="Opening(s)",
207 description="Make windows or doors",
208 default=True
210 Opening1Width: FloatProperty(
211 name="Width",
212 description="The Width of the first opening",
213 default=2.5,
214 min=0.01, max=100.0
216 Opening1Height: FloatProperty(
217 name="Height",
218 description="The Height of the first opening",
219 default=3.5,
220 min=0.01, max=100.0
222 Opening1X: FloatProperty(
223 name="Indent",
224 description="The x position or spacing of the first opening",
225 default=5.0,
226 min=-100, max=100.0
228 Opening1Z: FloatProperty(
229 name="Bottom",
230 description="The z position of the First opening",
231 default=5.0,
232 min=-100, max=100.0
234 Opening1Repeat: BoolProperty(
235 name="Repeat",
236 description="make multiple openings, with spacing X1",
237 default=False
239 Opening1TopArchTog: BoolProperty(
240 name="Top Arch",
241 description="Add an arch to the top of the first opening",
242 default=True
244 Opening1TopArch: FloatProperty(
245 name="Curve",
246 description="Height of the arch on the top of the opening",
247 default=2.5,
248 min=0.001, max=100.0
250 Opening1TopArchThickness: FloatProperty(
251 name="Thickness",
252 description="Thickness of the arch on the top of the opening",
253 default=0.75,
254 min=0.001, max=100.0
256 Opening1BtmArchTog: BoolProperty(
257 name="Bottom Arch",
258 description="Add an arch to the bottom of opening 1",
259 default=False
261 Opening1BtmArch: FloatProperty(
262 name="Curve",
263 description="Height of the arch on the bottom of the opening",
264 default=1.0,
265 min=0.01, max=100.0
267 Opening1BtmArchThickness: FloatProperty(
268 name="Thickness",
269 description="Thickness of the arch on the bottom of the opening",
270 default=0.5,
271 min=0.01, max=100.0
273 Opening1Bevel: FloatProperty(
274 name="Bevel",
275 description="Angle block face",
276 default=0.25,
277 min=-10.0, max=10.0
279 # openings on top of wall
280 CrenelTog: BoolProperty(
281 name="Crenels",
282 description="Make openings along top of wall",
283 default=False
285 CrenelXP: FloatProperty(
286 name="Width",
287 description="Gap width in wall based the percentage of wall width",
288 default=0.25,
289 min=0.10, max=1.0,
290 subtype="PERCENTAGE"
292 CrenelZP: FloatProperty(
293 name="Height",
294 description="Crenel Height as the percentage of wall height",
295 default=0.10,
296 min=0.10, max=1.0,
297 subtype="PERCENTAGE"
299 # narrow openings in wall.
300 # need to prevent overlap with arch openings - though inversion is an interesting effect.
301 SlotTog: BoolProperty(
302 name="Slots",
303 description="Make narrow openings in wall",
304 default=False
306 SlotRpt: BoolProperty(
307 name="Repeat",
308 description="Repeat slots along wall",
309 default=False
311 SlotWdg: BoolProperty(
312 name="Wedged (n/a)",
313 description="Bevel edges of slots",
314 default=False
316 SlotX: FloatProperty(
317 name="Indent",
318 description="The x position or spacing of slots",
319 default=0.0, min=-100, max=100.0
321 SlotGap: FloatProperty(
322 name="Opening",
323 description="The opening size of slots",
324 default=0.5, min=0.10, max=100.0
326 SlotV: BoolProperty(
327 name="Vertical",
328 description="Vertical slots",
329 default=True
331 SlotVH: FloatProperty(
332 name="Height",
333 description="Height of vertical slot",
334 default=3.5,
335 min=0.10, max=100.0
337 SlotVBtm: FloatProperty(
338 name="Bottom",
339 description="Z position for slot",
340 default=5.00,
341 min=-100.0, max=100.0
343 SlotH: BoolProperty(
344 name="Horizontal",
345 description="Horizontal slots",
346 default=False
348 SlotHW: FloatProperty(
349 name="Width",
350 description="Width of horizontal slot",
351 default=2.5,
352 min=0.10, max=100.0
354 # this should offset from VBtm... maybe make a % like crenels?
355 SlotHBtm: FloatProperty(
356 name="Bottom",
357 description="Z position for horizontal slot",
358 default=5.50,
359 min=-100.0, max=100.0
361 # properties for shelf (extend blocks in area)
362 ShelfTog: BoolProperty(
363 name="Shelf",
364 description="Add blocks in area by depth to make shelf/platform",
365 default=False
367 ShelfX: FloatProperty(
368 name="Left",
369 description="The x position of Shelf",
370 default=-5.00,
371 min=-100, max=100.0
373 ShelfZ: FloatProperty(
374 name="Bottom",
375 description="The z position of Shelf",
376 default=10.0,
377 min=-100, max=100.0
379 ShelfH: FloatProperty(
380 name="Height",
381 description="The Height of Shelf area",
382 default=1.0,
383 min=0.01, max=100.0
385 ShelfW: FloatProperty(
386 name="Width",
387 description="The Width of shelf area",
388 default=5.0,
389 min=0.01, max=100.0
391 ShelfD: FloatProperty(
392 name="Depth",
393 description="Depth of each block for shelf (from cursor + 1/2 wall depth)",
394 default=2.0,
395 min=0.01, max=100.0
397 ShelfBack: BoolProperty(
398 name="Backside",
399 description="Shelf on backside of wall",
400 default=False
402 # properties for steps (extend blocks in area, progressive width)
403 StepTog: BoolProperty(
404 name="Steps",
405 description="Add blocks in area by depth with progressive width to make steps",
406 default=False
408 StepX: FloatProperty(
409 name="Left",
410 description="The x position of steps",
411 default=-9.00,
412 min=-100, max=100.0
414 StepZ: FloatProperty(
415 name="Bottom",
416 description="The z position of steps",
417 default=0.0,
418 min=-100, max=100.0
420 StepH: FloatProperty(
421 name="Height",
422 description="The Height of step area",
423 default=10.0,
424 min=0.01, max=100.0
426 StepW: FloatProperty(
427 name="Width",
428 description="The Width of step area",
429 default=8.0,
430 min=0.01, max=100.0
432 StepD: FloatProperty(
433 name="Depth",
434 description="Depth of each block for steps (from cursor + 1/2 wall depth)",
435 default=1.0,
436 min=0.01, max=100.0
438 StepV: FloatProperty(
439 name="Riser",
440 description="Height of each step",
441 default=0.70,
442 min=0.01, max=100.0
444 StepT: FloatProperty(
445 name="Tread",
446 description="Width of each step",
447 default=1.0,
448 min=0.01, max=100.0
450 StepLeft: BoolProperty(
451 name="Direction",
452 description="If checked, flip steps direction towards the -X axis",
453 default=False
455 StepOnly: BoolProperty(
456 name="Steps Only",
457 description="Steps only, no supporting blocks",
458 default=False
460 StepBack: BoolProperty(
461 name="Backside",
462 description="Steps on backside of wall",
463 default=False
466 # Display the toolbox options
467 def draw(self, context):
468 layout = self.layout
470 box = layout.box()
471 box.prop(self, 'ConstructTog')
473 # Wall area (size/position)
474 box = layout.box()
475 box.label(text="Wall Size (area)")
477 col = box.column(align=True)
478 col.prop(self, "WallStart")
479 col.prop(self, "WallEnd")
481 col = box.column(align=True)
482 col.prop(self, "WallBottom")
483 col.prop(self, "WallTop")
484 box.prop(self, "EdgeOffset")
486 # Wall block sizing
487 box = layout.box()
488 box.label(text="Block Sizing")
489 box.prop(self, "MergeBlock")
491 # add checkbox for "fixed" sizing (ignore variance) a.k.a. bricks
492 col = box.column(align=True)
493 col.prop(self, "Width")
494 col.prop(self, "WidthVariance")
495 col.prop(self, "WidthMinimum")
497 col = box.column(align=True)
498 col.prop(self, "Height")
499 col.prop(self, "HeightVariance")
500 col.prop(self, "HeightMinimum")
502 col = box.column(align=True)
503 col.prop(self, "Depth")
504 col.prop(self, "DepthVariance")
505 col.prop(self, "DepthMinimum")
507 # grout settings
508 box = layout.box()
509 box.label(text="Grout")
511 col = box.column(align=True)
512 col.prop(self, "Grout")
513 col.prop(self, "GroutVariance")
515 col = box.column(align=True)
516 col.prop(self, "GroutDepth")
517 col.prop(self, "GroutDepthVariance")
519 # Wall shape modifiers
520 box = layout.box()
521 box.label(text="Wall Shape")
522 row = box.row(align=True)
523 row.prop(self, "RadialTog", toggle=True)
524 row.prop(self, "SlopeTog", toggle=True)
526 # Openings (doors, windows; arched)
527 box = layout.box()
528 box.prop(self, 'Opening1Tog')
529 if self.Opening1Tog:
530 col = box.column(align=True)
531 col.prop(self, "Opening1Width")
532 col.prop(self, "Opening1Height")
533 col.prop(self, "Opening1X")
534 col.prop(self, "Opening1Z")
535 col.prop(self, "Opening1Bevel")
537 box.prop(self, "Opening1Repeat", toggle=True)
539 sub_box = box.box()
540 sub_box.prop(self, "Opening1TopArchTog")
541 if self.Opening1TopArchTog:
542 col = sub_box.column(align=True)
543 col.prop(self, "Opening1TopArch")
544 col.prop(self, "Opening1TopArchThickness")
546 sub_box = box.box()
547 sub_box.prop(self, "Opening1BtmArchTog")
548 if self.Opening1BtmArchTog:
549 col = sub_box.column(align=True)
550 col.prop(self, "Opening1BtmArch")
551 col.prop(self, "Opening1BtmArchThickness")
553 # Slots (narrow openings)
554 box = layout.box()
555 box.prop(self, "SlotTog")
556 if self.SlotTog:
557 col = box.column(align=True)
558 col.prop(self, "SlotX")
559 col.prop(self, "SlotGap")
561 box.prop(self, "SlotRpt", toggle=True)
563 sub_box = box.box()
564 sub_box.prop(self, "SlotV")
565 if self.SlotV:
566 col = sub_box.column(align=True)
567 col.prop(self, "SlotVH")
568 col.prop(self, "SlotVBtm")
570 sub_box = box.box()
571 sub_box.prop(self, "SlotH")
572 if self.SlotH:
573 col = sub_box.column(align=True)
574 col.prop(self, "SlotHW")
575 col.prop(self, "SlotHBtm")
577 # Crenels, gaps in top of wall
578 box = layout.box()
579 box.prop(self, "CrenelTog")
580 if self.CrenelTog:
581 col = box.column(align=True)
582 col.prop(self, "CrenelXP")
583 col.prop(self, "CrenelZP")
585 # Shelfing (protrusions)
586 box = layout.box()
587 box.prop(self, 'ShelfTog')
588 if self.ShelfTog:
589 col = box.column(align=True)
590 col.prop(self, "ShelfX")
591 col.prop(self, "ShelfZ")
593 col = box.column(align=True)
594 col.prop(self, "ShelfW")
595 col.prop(self, "ShelfH")
596 col.prop(self, "ShelfD")
598 box.prop(self, "ShelfBack")
600 # Steps
601 box = layout.box()
602 box.prop(self, 'StepTog')
603 if self.StepTog:
604 col = box.column(align=True)
605 col.prop(self, "StepX")
606 col.prop(self, "StepZ")
608 col = box.column(align=True)
609 col.prop(self, "StepH")
610 col.prop(self, "StepW")
611 col.prop(self, "StepD")
613 col = box.column(align=True)
614 col.prop(self, "StepV")
615 col.prop(self, "StepT")
617 col = box.column(align=True)
618 row = col.row(align=True)
619 row.prop(self, "StepLeft", toggle=True)
620 row.prop(self, "StepOnly", toggle=True)
621 col.prop(self, "StepBack", toggle=True)
623 if self.change == False:
624 # generic transform props
625 box = layout.box()
626 box.prop(self, 'align', expand=True)
627 box.prop(self, 'location', expand=True)
628 box.prop(self, 'rotation', expand=True)
630 # Respond to UI - get the properties set by user.
631 # Check and process UI settings to generate masonry
633 def execute(self, context):
634 global radialized
635 global slope
636 global openingSpecs
637 global bigBlock
638 global shelfExt
639 global stepMod
640 global stepLeft
641 global shelfBack
642 global stepOnly
643 global stepBack
645 # Create the wall when enabled (skip regen iterations when off)
646 if not self.ConstructTog:
647 return {'FINISHED'}
649 # turn off 'Enter Edit Mode'
650 use_enter_edit_mode = bpy.context.preferences.edit.use_enter_edit_mode
651 bpy.context.preferences.edit.use_enter_edit_mode = False
653 # enter the settings for the wall dimensions (area)
654 # start can't be zero - min/max don't matter [if max less than end] but zero don't workie.
655 # start can't exceed end.
656 if not self.WallStart or self.WallStart >= self.WallEnd:
657 self.WallStart = NOTZERO # Reset UI if input out of bounds...
659 dims['s'] = self.WallStart
660 dims['e'] = self.WallEnd
661 dims['b'] = self.WallBottom
662 dims['t'] = self.WallTop
664 settings['eoff'] = self.EdgeOffset
666 # retrieve the settings for the wall block properties
667 settings['w'] = self.Width
668 settings['wv'] = self.WidthVariance
669 settings['wm'] = self.WidthMinimum
671 if not radialized:
672 settings['sdv'] = settings['w']
673 else:
674 settings['sdv'] = 0.12
676 settings['h'] = self.Height
677 settings['hv'] = self.HeightVariance
678 settings['hm'] = self.HeightMinimum
680 settings['d'] = self.Depth
681 settings['dv'] = self.DepthVariance
682 settings['dm'] = self.DepthMinimum
684 if self.MergeBlock:
685 bigBlock = 1
686 else:
687 bigBlock = 0
689 settings['g'] = self.Grout
690 settings['gv'] = self.GroutVariance
691 settings['gd'] = self.GroutDepth
692 settings['gdv'] = self.GroutDepthVariance
694 if self.GroutEdge:
695 settings['ge'] = 1
696 else:
697 settings['ge'] = 0
699 # set wall shape modifiers
700 if self.RadialTog:
701 radialized = 1
702 # eliminate to allow user control for start/completion?
703 dims['s'] = 0.0 # complete radial
704 if dims['e'] > PI * 2:
705 dims['e'] = PI * 2 # max end for circle
706 if dims['b'] < settings['g']:
707 dims['b'] = settings['g'] # min bottom for grout extension
708 else:
709 radialized = 0
711 if self.SlopeTog:
712 slope = 1
713 else:
714 slope = 0
716 shelfExt = 0
717 shelfBack = 0
719 # Add shelf if enabled
720 if self.ShelfTog:
721 shelfExt = 1
722 shelfSpecs['h'] = self.ShelfH
723 shelfSpecs['w'] = self.ShelfW
724 shelfSpecs['d'] = self.ShelfD
725 shelfSpecs['x'] = self.ShelfX
726 shelfSpecs['z'] = self.ShelfZ
728 if self.ShelfBack:
729 shelfBack = 1
730 stepMod = 0
731 stepLeft = 0
732 stepOnly = 0
733 stepBack = 0
735 # Make steps if enabled
736 if self.StepTog:
737 stepMod = 1
738 stepSpecs['x'] = self.StepX
739 stepSpecs['z'] = self.StepZ
740 stepSpecs['h'] = self.StepH
741 stepSpecs['w'] = self.StepW
742 stepSpecs['d'] = self.StepD
743 stepSpecs['v'] = self.StepV
744 stepSpecs['t'] = self.StepT
746 if self.StepLeft:
747 stepLeft = 1
749 if self.StepOnly:
750 stepOnly = 1
752 if self.StepBack:
753 stepBack = 1
755 # enter the settings for the openings
756 # when openings overlap they create inverse stonework - interesting but not the desired effect :)
757 # if opening width == indent * 2 the edge blocks fail (row of blocks cross opening) - bug.
758 openingSpecs = []
759 openingIdx = 0 # track opening array references for multiple uses
761 # general openings with arch options - can be windows or doors.
762 if self.Opening1Tog:
763 # set defaults...
764 openingSpecs += [{'w': 0.5, 'h': 0.5, 'x': 0.8, 'z': 2.7, 'rp': 1,
765 'b': 0.0, 'v': 0, 'vl': 0, 't': 0, 'tl': 0}]
767 openingSpecs[openingIdx]['w'] = self.Opening1Width
768 openingSpecs[openingIdx]['h'] = self.Opening1Height
769 openingSpecs[openingIdx]['x'] = self.Opening1X
770 openingSpecs[openingIdx]['z'] = self.Opening1Z
771 openingSpecs[openingIdx]['rp'] = self.Opening1Repeat
773 if self.Opening1TopArchTog:
774 openingSpecs[openingIdx]['v'] = self.Opening1TopArch
775 openingSpecs[openingIdx]['t'] = self.Opening1TopArchThickness
777 if self.Opening1BtmArchTog:
778 openingSpecs[openingIdx]['vl'] = self.Opening1BtmArch
779 openingSpecs[openingIdx]['tl'] = self.Opening1BtmArchThickness
781 openingSpecs[openingIdx]['b'] = self.Opening1Bevel
783 openingIdx += 1 # count window/door/arch openings
785 # Slots (narrow openings)
786 if self.SlotTog:
788 if self.SlotV: # vertical slots
789 # set defaults...
790 openingSpecs += [{'w': 0.5, 'h': 0.5, 'x': 0.0, 'z': 2.7, 'rp': 0,
791 'b': 0.0, 'v': 0, 'vl': 0, 't': 0, 'tl': 0}]
793 openingSpecs[openingIdx]['w'] = self.SlotGap
794 openingSpecs[openingIdx]['h'] = self.SlotVH
795 openingSpecs[openingIdx]['x'] = self.SlotX
796 openingSpecs[openingIdx]['z'] = self.SlotVBtm
797 openingSpecs[openingIdx]['rp'] = self.SlotRpt
799 # make them pointy...
800 openingSpecs[openingIdx]['v'] = self.SlotGap
801 openingSpecs[openingIdx]['t'] = self.SlotGap / 2
802 openingSpecs[openingIdx]['vl'] = self.SlotGap
803 openingSpecs[openingIdx]['tl'] = self.SlotGap / 2
805 openingIdx += 1 # count vertical slot openings
807 # need to handle overlap of H and V slots...
809 if self.SlotH: # Horizontal slots
810 # set defaults...
811 openingSpecs += [{'w': 0.5, 'h': 0.5, 'x': 0.0, 'z': 2.7, 'rp': 0,
812 'b': 0.0, 'v': 0, 'vl': 0, 't': 0, 'tl': 0}]
814 openingSpecs[openingIdx]['w'] = self.SlotHW
815 openingSpecs[openingIdx]['h'] = self.SlotGap
816 openingSpecs[openingIdx]['x'] = self.SlotX
817 openingSpecs[openingIdx]['z'] = self.SlotHBtm
818 # horizontal repeat isn't same spacing as vertical...
819 openingSpecs[openingIdx]['rp'] = self.SlotRpt
821 # make them pointy...
822 openingIdx += 1 # count horizontal slot openings
824 # Crenellations (top row openings)
825 if self.CrenelTog:
827 # add bottom arch option?
828 # perhaps a repeat toggle...
829 # if crenel opening overlaps with arch opening it fills with blocks...
831 # set defaults...
832 openingSpecs += [{'w': 0.5, 'h': 0.5, 'x': 0.0, 'z': 2.7, 'rp': 1,
833 'b': 0.0, 'v': 0, 'vl': 0, 't': 0, 'tl': 0}]
835 wallW = self.WallEnd - self.WallStart
836 crenelW = wallW * self.CrenelXP # Width % opening.
838 wallH = self.WallTop - self.WallBottom
839 crenelH = wallH * self.CrenelZP # % proportional height.
841 openingSpecs[openingIdx]['w'] = crenelW
842 openingSpecs[openingIdx]['h'] = crenelH
844 # calculate the spacing between openings.
845 # this isn't the absolute start (left),
846 # it's opening center offset relative to cursor (space between openings)...
847 openingSpecs[openingIdx]['x'] = crenelW * 2 - 1 # assume standard spacing
849 if not radialized: # normal wall?
850 # set indent 0 (center) if opening is 50% or more of wall width, no repeat.
851 if crenelW * 2 >= wallW:
852 openingSpecs[openingIdx]['x'] = 0
853 openingSpecs[openingIdx]['rp'] = 0
854 # set bottom of opening (center of hole)
855 openingSpecs[openingIdx]['z'] = self.WallTop - (crenelH / 2)
857 openingIdx += 1 # count crenel openings
859 # Process the user settings to generate a wall
860 # generate the list of vertices for the wall...
861 verts_array, faces_array = createWall(
862 radialized, slope, openingSpecs, bigBlock,
863 shelfExt, shelfBack, stepMod, stepLeft, stepOnly,
864 stepBack
867 if bpy.context.mode == "OBJECT":
868 if context.selected_objects != [] and context.active_object and \
869 (context.active_object.data is not None) and ('Wall' in context.active_object.data.keys()) and \
870 (self.change == True):
871 obj = context.active_object
872 oldmesh = obj.data
873 oldmeshname = obj.data.name
874 mesh = bpy.data.meshes.new("Wall")
875 mesh.from_pydata(verts_array, [], faces_array)
876 obj.data = mesh
877 for material in oldmesh.materials:
878 obj.data.materials.append(material)
879 bpy.data.meshes.remove(oldmesh)
880 obj.data.name = oldmeshname
881 else:
882 mesh = bpy.data.meshes.new("Wall")
883 mesh.from_pydata(verts_array, [], faces_array)
884 obj = object_utils.object_data_add(context, mesh, operator=self)
886 mesh.update()
888 obj.data["Wall"] = True
889 obj.data["change"] = False
890 for prm in WallParameters():
891 obj.data[prm] = getattr(self, prm)
893 if bpy.context.mode == "EDIT_MESH":
894 active_object = context.active_object
895 name_active_object = active_object.name
896 bpy.ops.object.mode_set(mode='OBJECT')
897 mesh = bpy.data.meshes.new("TMP")
898 mesh.from_pydata(verts_array, [], faces_array)
899 obj = object_utils.object_data_add(context, mesh, operator=self)
900 obj.select_set(True)
901 active_object.select_set(True)
902 bpy.context.view_layer.objects.active = active_object
903 bpy.ops.object.join()
904 context.active_object.name = name_active_object
905 bpy.ops.object.mode_set(mode='EDIT')
907 if use_enter_edit_mode:
908 bpy.ops.object.mode_set(mode = 'EDIT')
910 # restore pre operator state
911 bpy.context.preferences.edit.use_enter_edit_mode = use_enter_edit_mode
913 return {'FINISHED'}
915 def WallParameters():
916 WallParameters = [
917 "ConstructTog",
918 "RadialTog",
919 "SlopeTog",
920 "WallStart",
921 "WallEnd",
922 "WallBottom",
923 "WallTop",
924 "EdgeOffset",
925 "Width",
926 "WidthVariance",
927 "WidthMinimum",
928 "Height",
929 "HeightVariance",
930 "HeightMinimum",
931 "Depth",
932 "DepthVariance",
933 "DepthMinimum",
934 "MergeBlock",
935 "Grout",
936 "GroutVariance",
937 "GroutDepth",
938 "GroutDepthVariance",
939 "GroutEdge",
940 "Opening1Tog",
941 "Opening1Width",
942 "Opening1Height",
943 "Opening1X",
944 "Opening1Z",
945 "Opening1Repeat",
946 "Opening1TopArchTog",
947 "Opening1TopArch",
948 "Opening1TopArchThickness",
949 "Opening1BtmArchTog",
950 "Opening1BtmArch",
951 "Opening1BtmArchThickness",
952 "CrenelTog",
953 "CrenelXP",
954 "CrenelZP",
955 "SlotTog",
956 "SlotRpt",
957 "SlotWdg",
958 "SlotX",
959 "SlotGap",
960 "SlotV",
961 "SlotVH",
962 "SlotVBtm",
963 "SlotH",
964 "SlotHW",
965 "SlotHBtm",
966 "ShelfTog",
967 "ShelfX",
968 "ShelfZ",
969 "ShelfH",
970 "ShelfW",
971 "ShelfD",
972 "ShelfBack",
973 "StepTog",
974 "StepX",
975 "StepZ",
976 "StepH",
977 "StepW",
978 "StepD",
979 "StepV",
980 "StepT",
981 "StepLeft",
982 "StepOnly",
983 "StepBack",
985 return WallParameters