Skip to content

Commit

Permalink
scdocx support (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
margalva authored Nov 22, 2024
1 parent 1f6328e commit 9474f85
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion codegen/pyadritem.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Item:
self.item_image = None
"""Image object (Image and PNG binary files)"""
self.item_scene = None
"""3D scene (AVZ, PLY, SCDOC, GLB, and STL files)"""
"""3D scene (AVZ, PLY, SCDOC, SCDOCX, GLB, and STL files)"""
self.item_animation = None
"""Animation file (MP4/H.264 format files)"""
# Attributes for the table items
Expand Down
2 changes: 1 addition & 1 deletion doc/source/lowlevelapi/DataItemObject.rst
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ Scene Item

This method sets the item payload to the 3D geometry found in the passed
filename. Supported geometry formats include: EnSight CSF, STL, PLY,
SCDOC and AVZ format files.
SCDOC, SCDOCX and AVZ format files.

String Item
'''''''''''
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/dynamicreporting/core/serverless/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class AnimContent(FileValidator):


class SceneContent(FileValidator):
ALLOWED_EXT = ("stl", "ply", "csf", "avz", "scdoc", "glb")
ALLOWED_EXT = ("stl", "ply", "csf", "avz", "scdoc", "scdocx", "glb")


class FileContent(FileValidator):
Expand Down
27 changes: 14 additions & 13 deletions src/ansys/dynamicreporting/core/utils/geofile_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ def get_evsn_proxy_image(filename: str) -> typing.Union[bytearray, None]:
return None


# The basic idea of the 3D geometry pipeline is that files in .csf, .ply, .scdoc, .avz or
# .stl format (formats supported by udrws) are pushed into the MEDIA_ROOT directory on the
# server. The server then launches cei_apexXY_udrw2avz to convert the files to the format
# used by the server to generate entries in reports. Currently, this operation results
# in a new subdirectory named as the geometry filename w/o any extension that is read by
# the view generation engine. The system also tags the MEDIA_ROOT directory with a
# file containing the version of cei_apexXY_udrw2avz that was used (-i). The first
# The basic idea of the 3D geometry pipeline is that files in .csf, .ply, .scdoc, .scdocx,
# .avz or.stl format (formats supported by udrws) are pushed into the MEDIA_ROOT directory
# on the server. The server then launches cei_apexXY_udrw2avz to convert the files to the
# format used by the server to generate entries in reports. Currently, this operation
# results in a new subdirectory named as the geometry filename w/o any extension that is
# read by the view generation engine. The system also tags the MEDIA_ROOT directory with
# a file containing the version of cei_apexXY_udrw2avz that was used (-i). The first
# time the server is accessed, it checks this tag and if needed, will delete all
# the existing output from previous runs of the tool and replace them with run of the
# new version. Thus, the version number of cei_apexXY_udrw2avz as reported with -i
Expand All @@ -95,15 +95,15 @@ def file_can_have_proxy(filename: str) -> bool:
"""For a given filename, return True if the file format could include a proxy
image."""
_, extension = os.path.splitext(filename)
return extension in (".csf", ".avz", ".evsn", ".ens", ".scdoc")
return extension in (".csf", ".avz", ".evsn", ".ens", ".scdoc", ".scdocx")


def file_is_3d_geometry(filename: str, file_item_only: bool = True) -> bool:
"""For a given filename, return True if the file format contains 3D geometry."""
_, extension = os.path.splitext(filename)
if file_item_only:
return extension in (".evsn", ".ens", ".scdoc")
return extension in (".csf", ".stl", ".ply", ".avz", ".evsn", ".ens", ".scdoc")
return extension in (".evsn", ".ens", ".scdoc", ".scdocx")
return extension in (".csf", ".stl", ".ply", ".avz", ".evsn", ".ens", ".scdoc", ".scdocx")


def rebuild_3d_geometry(csf_file: str, unique_id: str = "", exec_basis: str = None):
Expand All @@ -119,6 +119,7 @@ def rebuild_3d_geometry(csf_file: str, unique_id: str = "", exec_basis: str = No
#
# Three special cases:
# '.scdoc' -> extract thumbnail image (if any)
# '.scdocx' -> extract thumbnail image (if any)
# '.avz' -> just extract the proxy image (if any)
# '.evsn' -> extract the proxy image (if any)
# No file conversions needed in these cases, but the proxy image (if any) is extracted as:
Expand All @@ -131,9 +132,9 @@ def rebuild_3d_geometry(csf_file: str, unique_id: str = "", exec_basis: str = No
print(f"Warning: unable to create 3D geometry directory: {avz_dir}")
return
avz_filename = csf_file
# Easiest case, handle SCDOC files
if csf_ext.lower() == ".scdoc":
# SCDOC files can have a thumbnail as: docProps/thumbnail.png
# Easiest case, handle SCDOC and SCDOCX files
if csf_ext.lower() == ".scdoc" or csf_ext.lower() == ".scdocx":
# SCDOC / SCDOCX files can have a thumbnail as: docProps/thumbnail.png
with zipfile.ZipFile(avz_filename) as archive:
for name in archive.namelist():
if name.endswith("thumbnail.png"):
Expand Down
2 changes: 2 additions & 0 deletions src/ansys/dynamicreporting/core/utils/report_download_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ def _is_scene_file(name: str) -> bool:
return True
if name.upper().endswith(".SCDOC"):
return True
if name.upper().endswith(".SCDOCX"):
return True
if name.upper().endswith(".GLB"):
return True
return False
Expand Down

0 comments on commit 9474f85

Please sign in to comment.