A package for the PHG modeling language and 3D visualization tool.
Project description
PHG
PHG is a Windows-oriented 3D modeling and visualization library built around a compact scene description language and a desktop viewer (VIS). It is designed for procedural geometry generation, engineering visualization, scene inspection, and pipe-system debugging workflows.
Current release target: 5.0.0
Core Capabilities
- Minimal PHG script language for hierarchical 3D scene generation
- Python APIs for interactive visualization and off-screen rendering
- Desktop viewer (
VIS) for local inspection and scene debugging - Reader-based scene loading for
.wlkxand.rvm - Direct loading for
.phg,.sce,.obj,.sm, and.grid - Screenshot export and interactive MP4 recording
- Pipe visualization helpers for world/local coordinate workflows
Installation
pip install phg_vis
Install from source:
pip install .
Optional shader dependencies:
pip install .[shader]
Quick Start
Render a PHG script interactively:
from pathlib import Path
import phg
script = Path("scene.phg").read_text(encoding="utf-8")
phg.visualize(script, mode="vis")
Render a deterministic PNG:
from pathlib import Path
from phg.visphg import image
script = Path("scene.phg").read_text(encoding="utf-8")
image(script, "scene.png")
Render inline content directly:
import phg
script = """
{
sample{md:cylinder 0.25 3; rgb:120,180,255;}
}setup_draw(sample);
"""
phg.visualize(script, mode="vis")
VIS Viewer
VIS is the desktop front-end bundled with PHG. It is intended for local review, debugging, and scene inspection.
Supported Inputs
.phg.sce.wlkx.rvm.obj.sm.grid
Current Interaction Features
- Auto-focus after loading or drag-dropping supported files
- Focus prefers actual loaded submesh bounds when available
Tabcycles scene observation targets instead of blindly walking every object- If the camera is far away from the next observation target, VIS automatically pulls in to a practical viewing distance
Shotexports a PNG screenshotREC / STOPrecords viewport videoRtoggles recording- Recording output is MP4 only
- Temporary PNG frames are used internally during recording and are deleted after successful encoding
- If MP4 encoding fails, the temporary frame directory is kept for troubleshooting
- Camera clip planes are initialized from scene scale and remain stable during wheel zooming
Recording Requirements
Recording requires ffmpeg.exe to be available in PATH.
Behavior:
- Press
RECorRto start recording. - Frames are captured into a temporary directory.
- Press
STOPorRagain to finish. - VIS encodes the recording to MP4 automatically.
- On success, temporary frames are removed.
- On failure, VIS keeps the frame directory and reports it in the notification.
Default Configuration
Do not ship machine-specific absolute paths in the library package. Use environment-neutral defaults and fill in reader paths during deployment.
phg/vis/config.ini
[Paths]
rvmReader=
wlkxReader=
meshRoot=./
Notes:
rvmReaderandwlkxReaderare intentionally blank by default.meshRoot=./keeps the package environment-neutral.
phg/vis/vis.ini
AUTO_FOCUS=true
CAMERA=
CONSOLE=true
COORD_HAND=LH
COORD_MIRROR_Z=false
COORD_UP=YUP
ENABLE_DUAL_SCREEN=false
HOSTIP=127.0.0.1
LAST_MESH_PATH=./
RECORD_FPS=12
SCREENSHOT_PATH=
meshRoot=./
Notes:
- Blank
SCREENSHOT_PATHfalls back to the desktop at runtime. AUTO_FOCUS=trueis the recommended default.RECORD_FPS=12is the current balanced default for interactive recording.
Recommended Workflow
For engineering or automatic-piping tasks, prefer this inspection order:
- Intermediate debug PHG
- Final geometry PHG
- Deterministic PNG snapshot
- Interactive VIS review when manual inspection is needed
This helps separate semantic-path problems, pose-layer problems, and final geometry translation problems.
Troubleshooting
Scene loads but nothing is visible
Check:
- The input file was actually loaded.
- Auto-focus is enabled.
- The scene contains valid submeshes.
- The camera is not still parked on the previous scene.
.wlkx or .rvm cannot be opened
Check:
- Reader executables are configured in
config.ini. - The reader can produce the expected
.sceand mesh database outputs. - The output directory is writable.
Recording fails
Check:
ffmpeg.exeis available inPATH.- The output location is writable.
- The notification reports a temporary frame directory for inspection.
Minimal Syntax Reminder
{
part{
md:cylinder 5 20;
rgb:180,180,220;
}
}setup_draw(part);
Rules:
- Use root braces
{ ... } - Finish with
setup(); draw();orsetup_draw(...) - Use spaces for
md:arguments - Use commas for vector values such as
xyz:1,2,3
Python API Snapshot
import phg
phg.visualize("box(10);", mode="vis")
phg.image("sphere(5);", filename="sphere.png")
phg.visualize("box(10);", mode="web", out_html="view.html")
Versioning
This release line is prepared as 5.0.0 because VIS behavior changed materially in user-facing areas:
- scene auto-focus after load
- observation-target camera cycling
- MP4 recording workflow
- stabilized clip-plane behavior
- release-oriented default configuration cleanup
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file phg_vis-5.0.0.tar.gz.
File metadata
- Download URL: phg_vis-5.0.0.tar.gz
- Upload date:
- Size: 3.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5efc1968b87c6c19f28a84381c828eff182e2b491927bd18f76a46c37115f42
|
|
| MD5 |
a4f5e239708d2a71f942af254aa6a8e2
|
|
| BLAKE2b-256 |
1040c05d9c75a4b16ac5bf18dbdf20929fd957b63cd074876ac8114432d2a2eb
|
File details
Details for the file phg_vis-5.0.0-py3-none-any.whl.
File metadata
- Download URL: phg_vis-5.0.0-py3-none-any.whl
- Upload date:
- Size: 3.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10c263cc671eff8876db730b162a352d23a0fc33c5c5244ac6ea0853c222afee
|
|
| MD5 |
19cf779f7e1a5bf04278f605395cb59e
|
|
| BLAKE2b-256 |
4f7cbd09d99bb17654a4da8244360142bdbf1973fa82c9e29bb0270c0f70f18d
|