Skip to content

Commit cd24712

Browse files
Copilotchenkasirer
andcommitted
Separate proto definitions into geometry, datastructures, and message files
Co-authored-by: chenkasirer <3398309+chenkasirer@users.noreply.github.com>
1 parent 1d419bd commit cd24712

13 files changed

Lines changed: 588 additions & 439 deletions

File tree

‎docs/missing_compas_type.md‎

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ This guide explains how to extend compas_pb with support for more COMPAS types.
99

1010
### 1. Add a protobuf definition for the type you wish to add
1111

12-
Add a protobuf message definition for the new type to the unified `geometry.proto` file located at `src/compas_pb/protobuf_defs/compas_pb/generated/geometry.proto`.
12+
Add a protobuf message definition for the new type to the appropriate proto file:
1313

14-
For example, to add a custom `CustomShape` type:
14+
- **`geometry.proto`** - For geometry primitives (points, vectors, curves, surfaces, transformations)
15+
- **`datastructures.proto`** - For COMPAS datastructures (mesh, polyhedron)
16+
- **`message.proto`** - For serialization framework types (internal use only)
17+
18+
For example, to add a custom geometry type, add it to `src/compas_pb/protobuf_defs/compas_pb/generated/geometry.proto`:
1519

1620
```protobuf title="src/compas_pb/protobuf_defs/compas_pb/generated/geometry.proto"
1721
// Add to the appropriate section in geometry.proto
@@ -24,18 +28,34 @@ message CustomShapeData {
2428
}
2529
```
2630

31+
Or, for a COMPAS datastructure type, add it to `src/compas_pb/protobuf_defs/compas_pb/generated/datastructures.proto`:
32+
33+
```protobuf title="src/compas_pb/protobuf_defs/compas_pb/generated/datastructures.proto"
34+
// Import geometry types if needed
35+
import "compas_pb/generated/geometry.proto";
36+
37+
message CustomDataStructureData {
38+
string guid = 1;
39+
string name = 2;
40+
repeated PointData vertices = 3;
41+
}
42+
```
43+
2744
!!! note
28-
All geometry types are now defined in a single `geometry.proto` file. This makes it easier to manage dependencies between types and see the full structure at a glance.
45+
Proto definitions are organized to match COMPAS package structure:
46+
- `geometry.proto` → `compas.geometry`
47+
- `datastructures.proto` → `compas.datastructures`
48+
- `message.proto` → internal serialization framework
2949

3050
### 2. Generate the python code for the updated proto file
3151

32-
Now run the following command to regenerate the python code from the updated proto file:
52+
Now run the following command to regenerate the python code from the updated proto files:
3353

3454
```bash
3555
invoke generate-proto-classes -t python
3656
```
3757

38-
The generated `geometry_pb2` module in `src/compas_pb/generated/` will now include your new type.
58+
The generated modules (`geometry_pb2`, `datastructures_pb2`, `message_pb2`) in `src/compas_pb/generated/` will now include your new type.
3959

4060
### 3. Create a (de)serializer for the new type
4161

@@ -44,7 +64,7 @@ To create a (de)serializer for a custom type, use the `@pb_serializer` and `@pb_
4464
```python title="compas_pb/conversions.py"
4565
from compas_pb.registry import pb_serializer
4666
from compas_pb.registry import pb_deserializer
47-
from compas_pb.generated import geometry_pb2
67+
from compas_pb.generated import geometry_pb2 # or datastructures_pb2
4868

4969

5070
@pb_serializer(CustomShape)

0 commit comments

Comments
 (0)