Skip to content

Commit

Permalink
Merge pull request #316 from howetuft/assembly3
Browse files Browse the repository at this point in the history
Limit filename length
  • Loading branch information
howetuft authored Oct 21, 2023
2 parents 1db1678 + 8b0f12d commit 5185785
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Render/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@

# Workbench parameters
PARAMS = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Render")

MAX_FILENAME_LEN = 256
2 changes: 1 addition & 1 deletion Render/renderers/Appleseed.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def write_mesh(name, mesh, material, **kwargs):
<parameter name="filename" value="{filename}" />
</object>
<object_instance name="{shortfilename}.instance"
object="{shortfilename}.{shortfilename}" >
object="{shortfilename}.{name}" >
<transform>
<matrix>
{transfo_rows[0]}
Expand Down
9 changes: 7 additions & 2 deletions Render/rendermesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from math import pi, atan2, asin, isclose, radians, cos, hypot
import copy
import cmath
import uuid

import FreeCAD as App
import Mesh
Expand All @@ -49,7 +50,7 @@
multiprocessing_enabled,
numpy_enabled,
)
from Render.constants import PARAMS
from Render.constants import PARAMS, MAX_FILENAME_LEN
from Render.rendermesh_mp import vector3d
from Render.utils import debug

Expand Down Expand Up @@ -396,7 +397,11 @@ def write_file(
else App.ActiveDocument.TransientDir
)
extension = _EXPORT_EXTENSIONS[filetype]
basename = name + extension
if len(name) + len(extension) <= MAX_FILENAME_LEN:
basename = name
else:
basename = uuid.uuid4().hex
basename += extension
filename = os.path.join(export_directory, basename)

# Relative/absolute path
Expand Down
6 changes: 3 additions & 3 deletions templates/cycles_studio_dark.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<state name="KEY" shader="studio_white">
<light
light_type="distant"
strength="1.5 1.5 1.5"
strength="3 3 3"
dir="-1 1 -1.5"
angle="0.3"
use_mis="true"
Expand All @@ -46,7 +46,7 @@
<state name="FILL" shader="studio_white">
<light
light_type="distant"
strength="0.1"
strength="0.1 0.1 0.1"
dir="1 1 -0.5"
angle="2"
use_mis="true"
Expand All @@ -56,7 +56,7 @@
<state name="RIM" shader="studio_white">
<light
light_type="distant"
strength="20"
strength="0.20 0.20 0.20"
dir="0 -1 0"
angle="1.57"
use_mis="true"
Expand Down
6 changes: 3 additions & 3 deletions templates/cycles_studio_light.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<state name="KEY" shader="studio_white">
<light
light_type="distant"
strength="1.5 1.5 1.5"
strength="3.0 3.0 3.0"
dir="-1 1 -1.5"
angle="0.3"
use_mis="true"
Expand All @@ -46,7 +46,7 @@
<state name="FILL" shader="studio_white">
<light
light_type="distant"
strength="0.1"
strength="0.1 0.1 0.1"
dir="1 1 -0.5"
angle="2"
use_mis="true"
Expand All @@ -56,7 +56,7 @@
<state name="RIM" shader="studio_white">
<light
light_type="distant"
strength="20"
strength="0.20 0.20 0.20"
dir="0 -1 0"
angle="1.57"
use_mis="true"
Expand Down
2 changes: 1 addition & 1 deletion templates/ospray_studio_light.sg
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"sgOnly": false,
"subType": "float",
"type": 1,
"value": 1.0
"value": 2.0
},
{
"description": "color of the light",
Expand Down

0 comments on commit 5185785

Please sign in to comment.