Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ __pycache__
pymvr.egg-info/
devel/
*whl
*.mvr
uv.lock
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
### Changelog

### 1.0.0-dev0

* Breaking changes!
* Big refactor of structure - ensure that XML structure is followed in code
* Implemented all MVR fields
* Big refactor for export

#### 0.5.0

* Add classing to export
Expand Down
99 changes: 46 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,58 @@ python -m pip install https://codeload.github.com/open-stage/python-mvr/zip/refs

```python
import pymvr
mvr_scene = pymvr.GeneralSceneDescription("mvr_file.mvr")
mvr_file = pymvr.GeneralSceneDescription("mvr_file.mvr")

for layer_index, layer in enumerate(mvr_scene.layers):
for layer_index, layer in enumerate(mvr_file.scene.layers):
... #process data
```

### Writing

```python
fixtures_list = []
mvr = pymvr.GeneralSceneDescriptionWriter()
pymvr.UserData().to_xml(parent=mvr.xml_root)
scene = pymvr.SceneElement().to_xml(parent=mvr.xml_root)
layers = pymvr.LayersElement().to_xml(parent=scene)
layer = pymvr.Layer(name="Test layer").to_xml(parent=layers)
child_list = pymvr.ChildList().to_xml(parent=layer)

fixture = pymvr.Fixture(name="Test Fixture") # not really a valid fixture
child_list.append(fixture.to_xml())
fixtures_list.append((fixture.gdtf_spec, fixture.gdtf_spec))

pymvr.AUXData().to_xml(parent=scene)

mvr.files_list = list(set(fixtures_list))
mvr.write_mvr("example.mvr")
import pymvr
from pathlib import Path

# 1. Create a writer instance
mvr_writer = pymvr.GeneralSceneDescriptionWriter()

# 2. Build the MVR object tree
# Create a scene object
scene_obj = pymvr.Scene()

# Create layers and add them to the scene
layers = pymvr.Layers()
scene_obj.layers = layers

# Create a layer and add it to the layers
layer = pymvr.Layer(name="Test layer")
layers.append(layer)

# Create a child list for the layer
child_list = pymvr.ChildList()
layer.child_list = child_list

# Create a fixture and add it to the child list
# Note: A valid fixture would require more attributes
fixture = pymvr.Fixture(name="Test Fixture")
child_list.fixtures.append(fixture)

# 3. Serialize the scene object into the writer's XML root
scene_obj.to_xml(parent=mvr_writer.xml_root)

# 4. Add any necessary files (like GDTF) to the MVR archive
# (This example fixture doesn't have a GDTF file, so this list will be empty)
files_to_pack = []
if fixture.gdtf_spec:
# The list should contain tuples of (source_path, archive_name)
files_to_pack.append((fixture.gdtf_spec, fixture.gdtf_spec))
mvr_writer.files_list = list(set(files_to_pack))

# 5. Write the MVR file
output_path = Path("example.mvr")
mvr_writer.write_mvr(output_path)

print(f"MVR file written to {output_path.resolve()}")
```

See [BlenderDMX](https://github.com/open-stage/blender-dmx) and
Expand All @@ -67,41 +94,7 @@ reference implementation.

## Status

- Reading:

- Address
- Alignment
- AUXData
- ChildList
- Class
- Connection
- CustomCommand
- Data
- Fixture
- FocusPoint
- Geometries
- Geometry3D
- Gobo
- GroupObject
- Layer
- Mapping
- Overwrite
- Position
- Projector
- Protocol
- SceneObject
- Sources
- Support
- Symbol
- Symdef
- Truss
- UserData
- VideoScreen

- Writing:
- Fixture
- Focus point
- creating MVR zip file
- Reading and Writing of all aspects of MVR should be covered.

## Development

Expand Down
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def mvr_scene(request):
yield mvr_scene


@pytest.fixture(scope="session")
@pytest.fixture(scope="function")
def pymvr_module():
yield pymvr

Expand Down
Loading