39 lines
2.4 KiB
Python
39 lines
2.4 KiB
Python
import bpy,math,os
|
|
from mathutils import Vector
|
|
sc=bpy.context.scene;folder=os.path.dirname(bpy.data.filepath)
|
|
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'map_before_sign_supports.blend'),copy=True)
|
|
roots=[o for o in sc.objects if o.type=='EMPTY' and o.name.startswith('Zone_') and o.name.endswith('_Nameplate')]
|
|
wood=bpy.data.materials.get('Fence_Warm_Cedar_Subtle');snow=bpy.data.materials.get('Snow_Full_Soft')
|
|
coll=bpy.data.collections.new('Sign_Fence_Style_Supports');sc.collection.children.link(coll)
|
|
template=next(o for o in sc.objects if o.name.startswith('Snow_Drape_') and not o.hide_render and o.location.z>6)
|
|
def box(name,x,z,size,parent):
|
|
bpy.ops.mesh.primitive_cube_add(size=1,location=(x,0,z));o=bpy.context.object;o.name=name;o.dimensions=size
|
|
bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)
|
|
for c in list(o.users_collection):c.objects.unlink(o)
|
|
coll.objects.link(o);o.parent=parent;o.data.materials.append(wood)
|
|
b=o.modifiers.new('Fence edge bevel','BEVEL');b.width=.09;b.segments=3
|
|
return o
|
|
for root in roots:
|
|
a=root.rotation_euler.z;root.location+=Vector((math.cos(a)*3.8,math.sin(a)*3.8,0))
|
|
for o in list(root.children):
|
|
if o.name.startswith(('Sign_Post','Post_Snow')):o.hide_render=True;o.hide_set(True)
|
|
else:o.location.z-=1.2
|
|
for x in (-6.3,6.3):
|
|
box('Sign_Fence_Post',x,4.4,(1.15,1.15,8.8),root)
|
|
box('Sign_Post_Foot',x,.24,(1.55,1.55,.48),root)
|
|
box('Sign_Post_Capital',x,8.65,(1.55,1.55,.44),root)
|
|
cp=template.copy();cp.data=template.data.copy();cp.name='Sign_Smooth_SnowCap';coll.objects.link(cp);cp.parent=root
|
|
cp.location=(x,0,9.0);cp.rotation_euler=(0,0,0)
|
|
# Normalize copied snow to the sign's capital while retaining its curved lobes.
|
|
coords=[v.co for v in cp.data.vertices]
|
|
lo=Vector(tuple(min(v[k] for v in coords) for k in range(3)));hi=Vector(tuple(max(v[k] for v in coords) for k in range(3)))
|
|
center=(lo+hi)*.5;extent=hi-lo
|
|
for v in cp.data.vertices:
|
|
v.co=Vector(((v.co.x-center.x)/extent.x*1.95,(v.co.y-center.y)/extent.y*1.95,(v.co.z-center.z)/extent.z*.85))
|
|
cp.scale=(1,1,1)
|
|
for f in cp.data.polygons:f.use_smooth=True
|
|
# Horizontal rails connect the plaque to the wide-set fence-style posts.
|
|
for z in (6.35,8.05):box('Sign_Mount_Rail',0,z,(12.6,.35,.36),root)
|
|
path=os.path.join(folder,'map_signs_adjusted.blend');bpy.ops.wm.save_as_mainfile(filepath=path)
|
|
print('Adjusted',len(roots),'signs. Shift right 3.8, board down 1.2.',path)
|