mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 09:02:29 +00:00
Fix #7225. Handle freestyle linework regardless of generated SVG filename.
This commit is contained in:
@@ -796,8 +796,9 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
edge_bm.to_mesh(edge_mesh)
|
edge_bm.to_mesh(edge_mesh)
|
||||||
edge_bm.free()
|
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]
|
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)
|
bpy.ops.render.render(write_still=False)
|
||||||
|
|
||||||
os.replace(actual_path, svg_path)
|
os.replace(actual_path, svg_path)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class SolarData:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def sun_position(cls):
|
def sun_position(cls):
|
||||||
return tool.Blender.get_sun_position_addon()
|
return tool.Blender.get_addon("sun_position")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def sites(cls):
|
def sites(cls):
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ class RadianceRender(bpy.types.Operator):
|
|||||||
print(f"Camera position: {camera_position}")
|
print(f"Camera position: {camera_position}")
|
||||||
print(f"Camera direction: {camera_direction}")
|
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(
|
# azimuth, elevation = sun_position.sun_calc.get_sun_coordinates(
|
||||||
# sun_pos_props.time,
|
# sun_pos_props.time,
|
||||||
# sun_pos_props.latitude,
|
# sun_pos_props.latitude,
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ from bpy.types import PropertyGroup
|
|||||||
from bonsai.bim.module.light.data import SolarData
|
from bonsai.bim.module.light.data import SolarData
|
||||||
from bonsai.bim.module.light.decorator import SolarDecorator
|
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()
|
now = datetime.datetime.now()
|
||||||
|
|
||||||
with open(os.path.join(os.path.dirname(__file__), "spectraldb.json"), "r") as f:
|
with open(os.path.join(os.path.dirname(__file__), "spectraldb.json"), "r") as f:
|
||||||
|
|||||||
@@ -1506,28 +1506,21 @@ class Blender(bonsai.core.tool.Blender):
|
|||||||
return bpy.context.preferences.addons[blender_package_name].preferences
|
return bpy.context.preferences.addons[blender_package_name].preferences
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_sun_position_addon(cls) -> Union[types.ModuleType, None]:
|
def get_addon(cls, name: str) -> Union[types.ModuleType, None]:
|
||||||
# Check if it's installed as legacy Blender addon.
|
|
||||||
import importlib
|
import importlib
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sun_position = importlib.import_module("sun_position")
|
return importlib.import_module(name) # Legacy Blender addon
|
||||||
except ImportError:
|
except ImportError:
|
||||||
sun_position = None
|
pass
|
||||||
|
|
||||||
if sun_position:
|
|
||||||
return sun_position
|
|
||||||
|
|
||||||
for package_name in bpy.context.preferences.addons.keys():
|
for package_name in bpy.context.preferences.addons.keys():
|
||||||
if package_name.endswith(".sun_position"):
|
if package_name.endswith(f".{name}"):
|
||||||
try:
|
try:
|
||||||
sun_position = importlib.import_module(package_name)
|
return importlib.import_module(package_name)
|
||||||
return sun_position
|
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return sun_position
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_sun_props(cls) -> Union[SunPosProperties, None]:
|
def get_sun_props(cls) -> Union[SunPosProperties, None]:
|
||||||
assert (scene := bpy.context.scene)
|
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 = [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))
|
should_hides = np.fromiter(should_hides, dtype=np.uint8, count=len(should_hides))
|
||||||
bpy.data.objects.foreach_set("hide_render", should_hides)
|
bpy.data.objects.foreach_set("hide_render", should_hides)
|
||||||
return # Otherwise...
|
return # Otherwise...
|
||||||
# for obj in bpy.data.objects:
|
# for obj in bpy.data.objects:
|
||||||
# if not obj.data:
|
# if not obj.data:
|
||||||
# continue
|
# continue
|
||||||
|
|||||||
Reference in New Issue
Block a user