Fix #7225. Handle freestyle linework regardless of generated SVG filename.

This commit is contained in:
Dion Moult
2025-10-11 19:15:50 +11:00
parent 71d5239823
commit df0e8bba8c
5 changed files with 11 additions and 17 deletions
@@ -796,8 +796,9 @@ class CreateDrawing(bpy.types.Operator):
edge_bm.to_mesh(edge_mesh)
edge_bm.free()
actual_path = svg_path[0:-4] + "0001.svg"
freestyle_svg_exporter = tool.Blender.get_addon("freestyle_svg_exporter")
context.scene.render.filepath = svg_path[0:-4]
actual_path = freestyle_svg_exporter.create_path(bpy.context.scene)
bpy.ops.render.render(write_still=False)
os.replace(actual_path, svg_path)
+1 -1
View File
@@ -41,7 +41,7 @@ class SolarData:
@classmethod
def sun_position(cls):
return tool.Blender.get_sun_position_addon()
return tool.Blender.get_addon("sun_position")
@classmethod
def sites(cls):
@@ -202,7 +202,7 @@ class RadianceRender(bpy.types.Operator):
print(f"Camera position: {camera_position}")
print(f"Camera direction: {camera_direction}")
# sun_position = tool.Blender.get_sun_position_addon()
# sun_position = tool.Blender.get_addon("sun_position")
# azimuth, elevation = sun_position.sun_calc.get_sun_coordinates(
# sun_pos_props.time,
# sun_pos_props.latitude,
+1 -1
View File
@@ -40,7 +40,7 @@ from bpy.types import PropertyGroup
from bonsai.bim.module.light.data import SolarData
from bonsai.bim.module.light.decorator import SolarDecorator
sun_position = tool.Blender.get_sun_position_addon()
sun_position = tool.Blender.get_addon("sun_position")
now = datetime.datetime.now()
with open(os.path.join(os.path.dirname(__file__), "spectraldb.json"), "r") as f:
+6 -13
View File
@@ -1506,28 +1506,21 @@ class Blender(bonsai.core.tool.Blender):
return bpy.context.preferences.addons[blender_package_name].preferences
@classmethod
def get_sun_position_addon(cls) -> Union[types.ModuleType, None]:
# Check if it's installed as legacy Blender addon.
def get_addon(cls, name: str) -> Union[types.ModuleType, None]:
import importlib
try:
sun_position = importlib.import_module("sun_position")
return importlib.import_module(name) # Legacy Blender addon
except ImportError:
sun_position = None
if sun_position:
return sun_position
pass
for package_name in bpy.context.preferences.addons.keys():
if package_name.endswith(".sun_position"):
if package_name.endswith(f".{name}"):
try:
sun_position = importlib.import_module(package_name)
return sun_position
return importlib.import_module(package_name)
except ModuleNotFoundError:
pass
return sun_position
@classmethod
def get_sun_props(cls) -> Union[SunPosProperties, None]:
assert (scene := bpy.context.scene)
@@ -1897,7 +1890,7 @@ class Blender(bonsai.core.tool.Blender):
should_hides = [0 if obj.visible_get() else 1 for obj in bpy.data.objects]
should_hides = np.fromiter(should_hides, dtype=np.uint8, count=len(should_hides))
bpy.data.objects.foreach_set("hide_render", should_hides)
return # Otherwise...
return # Otherwise...
# for obj in bpy.data.objects:
# if not obj.data:
# continue