add Bethany tool

This commit is contained in:
Yuki-Kokomi
2024-08-16 17:50:51 +08:00
parent be3615ab12
commit c0326ca5eb
37 changed files with 19245 additions and 0 deletions

10
.gitignore vendored Normal file
View File

@@ -0,0 +1,10 @@
data/
__pycache__/
*.tar*
*_json/
*_step/
*_image/
*.7z
data.json
output.*
_*/

20
Bethany/README.md Normal file
View File

@@ -0,0 +1,20 @@
# Bethany
## Prerequisites
- Linux
- Python 3.10
## Dependencies
Install python package dependencies through pip:
```bash
$ pip install -r requirements.txt
```
Install [pythonocc](https://github.com/tpaviot/pythonocc-core) (OpenCASCADE) by conda:
```bash
$ conda install -c conda-forge pythonocc-core=7.5.1
```

View File

@@ -0,0 +1,40 @@
#!/bin/bash
ENV_NAME=Bethany
CONDA_INIT_SCRIPT="$(conda info --base)/etc/profile.d/conda.sh"
if [ -f "$CONDA_INIT_SCRIPT" ]; then
# 初始化 conda
source "$CONDA_INIT_SCRIPT"
else
echo "Error: Cannot find conda initialization script."
exit 1
fi
conda activate "$ENV_NAME"
conda activate Bethany
JSON_SOURCE=./examples/
OUT_DIR=./examples/_out
# python json2step.py --src $JSON_SOURCE -o $OUT_DIR/steps_segment/ --mode segment
# python step2img.py --src $OUT_DIR/steps_segment/ -o $OUT_DIR/images_segment/ --mode segment
# python img2seg.py --src $OUT_DIR/images_segment/ -o $OUT_DIR/images_mask --srcc $OUT_DIR/images_transparent/
python json2step.py --src $JSON_SOURCE -o $OUT_DIR/steps_default/ --mode default
python step2img.py --src $OUT_DIR/steps_default/ -o $OUT_DIR/images_default/ --mode default
python step2img.py --src $OUT_DIR/steps_default/ -o $OUT_DIR/images_transparent/ --mode transparent
python step2img.py --src $OUT_DIR/steps_default/ -o $OUT_DIR/images_orthographic/ --mode orthographic
python json2dataset.py --src $JSON_SOURCE -o $OUT_DIR/code_default_directout_3k.json --ignore True --mode default --token 3072
python json2dataset.py --src $JSON_SOURCE -o $OUT_DIR/code_transparent_directout_3k.json --ignore True --mode transparent --token 3072
python json2dataset.py --src $JSON_SOURCE -o $OUT_DIR/code_orthographic_directout_3k.json --ignore True --mode orthographic --token 3072
python json2py.py --src $JSON_SOURCE -o $OUT_DIR/codes_python/
python py2step.py --src $OUT_DIR/codes_python/ -o $OUT_DIR/steps_from_py/
python step2img.py --src $OUT_DIR/steps_from_py/ -o $OUT_DIR/images_from_py/
conda deactivate

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,956 @@
{
"entities": {
"Fo8ZVIGCycfBiaX_1": {
"transform": {
"origin": {
"y": -0.0254,
"x": 0.0,
"z": -9.93e-06
},
"y_axis": {
"y": 0.0,
"x": -0.0,
"z": 1.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
},
"type": "Sketch",
"name": "Sketch 4",
"profiles": {
"JTC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"type": "Line3D",
"start_point": {
"y": 0.01164113,
"x": -0.000635,
"z": 0.0
},
"curve": "JTB",
"end_point": {
"y": 0.01164113,
"x": 0.000635,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.01164113,
"x": 0.000635,
"z": 0.0
},
"curve": "JTV",
"end_point": {
"y": 0.01015007,
"x": 0.000635,
"z": 0.0
}
},
{
"center_point": {
"y": 9.93e-06,
"x": 0.0,
"z": 0.0
},
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": 0.01015007,
"x": 0.000635,
"z": 0.0
},
"start_angle": 0.0,
"curve": "JTt",
"end_angle": 0.12508148463379154,
"radius": 0.01016,
"type": "Arc3D",
"start_point": {
"y": 0.01015007,
"x": -0.000635,
"z": 0.0
},
"reference_vector": {
"y": 0.9980449651344315,
"x": 0.06249998055848972,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.01164113,
"x": -0.000635,
"z": 0.0
},
"curve": "JTF",
"end_point": {
"y": 0.01015007,
"x": -0.000635,
"z": 0.0
}
}
]
}
],
"properties": {}
},
"JTW": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"type": "Line3D",
"start_point": {
"y": 0.00242794,
"x": -0.000635,
"z": 0.0
},
"curve": "JTN",
"end_point": {
"y": -0.00240808,
"x": -0.000635,
"z": 0.0
}
},
{
"center_point": {
"y": 9.93e-06,
"x": 0.0,
"z": 0.0
},
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": -0.00240808,
"x": 0.000635,
"z": 0.0
},
"start_angle": 0.0,
"curve": "JT5",
"end_angle": 0.5136274205390272,
"radius": 0.0025,
"type": "Arc3D",
"start_point": {
"y": -0.00240808,
"x": -0.000635,
"z": 0.0
},
"reference_vector": {
"y": -0.9672042042658119,
"x": -0.25400005364278505,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.00242794,
"x": 0.000635,
"z": 0.0
},
"curve": "JTd",
"end_point": {
"y": -0.00240808,
"x": 0.000635,
"z": 0.0
}
},
{
"center_point": {
"y": 9.93e-06,
"x": 0.0,
"z": 0.0
},
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": 0.00242794,
"x": 0.000635,
"z": 0.0
},
"start_angle": 0.0,
"curve": "JT1",
"end_angle": 0.5136274205390281,
"radius": 0.0025,
"type": "Arc3D",
"start_point": {
"y": 0.00242794,
"x": -0.000635,
"z": 0.0
},
"reference_vector": {
"y": 0.9672042042658119,
"x": 0.25400005364278505,
"z": 0.0
}
}
]
}
],
"properties": {}
},
"JTK": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"type": "Line3D",
"start_point": {
"y": -0.00850306,
"x": -0.000635,
"z": 0.0
},
"curve": "JTR",
"end_point": {
"y": -0.00240808,
"x": -0.000635,
"z": 0.0
}
},
{
"center_point": {
"y": 9.93e-06,
"x": 0.0,
"z": 0.0
},
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": -0.00240808,
"x": 0.000635,
"z": 0.0
},
"start_angle": 0.0,
"curve": "JT5",
"end_angle": 0.5136274205390272,
"radius": 0.0025,
"type": "Arc3D",
"start_point": {
"y": -0.00240808,
"x": -0.000635,
"z": 0.0
},
"reference_vector": {
"y": -0.9672042042658119,
"x": -0.25400005364278505,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": -0.00850306,
"x": 0.000635,
"z": 0.0
},
"curve": "JTh",
"end_point": {
"y": -0.00240808,
"x": 0.000635,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": -0.00850306,
"x": -0.000635,
"z": 0.0
},
"curve": "JTl",
"end_point": {
"y": -0.00850306,
"x": 0.000635,
"z": 0.0
}
}
]
}
],
"properties": {}
},
"JTS": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"type": "Line3D",
"start_point": {
"y": 0.01015007,
"x": -0.000635,
"z": 0.0
},
"curve": "JTJ",
"end_point": {
"y": 0.00242794,
"x": -0.000635,
"z": 0.0
}
},
{
"center_point": {
"y": 9.93e-06,
"x": 0.0,
"z": 0.0
},
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": 0.00242794,
"x": 0.000635,
"z": 0.0
},
"start_angle": 0.0,
"curve": "JT1",
"end_angle": 0.5136274205390281,
"radius": 0.0025,
"type": "Arc3D",
"start_point": {
"y": 0.00242794,
"x": -0.000635,
"z": 0.0
},
"reference_vector": {
"y": 0.9672042042658119,
"x": 0.25400005364278505,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.01015007,
"x": 0.000635,
"z": 0.0
},
"curve": "JTZ",
"end_point": {
"y": 0.00242794,
"x": 0.000635,
"z": 0.0
}
},
{
"center_point": {
"y": 9.93e-06,
"x": 0.0,
"z": 0.0
},
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": 0.01015007,
"x": 0.000635,
"z": 0.0
},
"start_angle": 0.0,
"curve": "JTt",
"end_angle": 0.12508148463379154,
"radius": 0.01016,
"type": "Arc3D",
"start_point": {
"y": 0.01015007,
"x": -0.000635,
"z": 0.0
},
"reference_vector": {
"y": 0.9980449651344315,
"x": 0.06249998055848972,
"z": 0.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
},
"FYk0kTmVxIulnxh_1": {
"name": "Extrude 4",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JPC",
"sketch": "F4akSLM8jsEhHQd_1"
},
{
"profile": "JPG",
"sketch": "F4akSLM8jsEhHQd_1"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": 0.025400000000000002
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "CutFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
},
"F262llpzE1N6Ecl_0": {
"name": "Extrude 1",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JGC",
"sketch": "Fl5EmzXybmYL8OB_0"
},
{
"profile": "JGK",
"sketch": "Fl5EmzXybmYL8OB_0"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": 0.025400000000000002
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "NewBodyFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
},
"FqOjU5KExGkflVJ_1": {
"name": "Extrude 2",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JGK",
"sketch": "Fl5EmzXybmYL8OB_0"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": 0.012700000000000001
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "CutFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
},
"FeetK5BcCKytC5s_1": {
"name": "Extrude 3",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JLC",
"sketch": "FPXPvHvj2sTuxfF_1"
},
{
"profile": "JLG",
"sketch": "FPXPvHvj2sTuxfF_1"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": -0.012700000000000001
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "CutFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "SymmetricFeatureExtentType"
},
"F4akSLM8jsEhHQd_1": {
"transform": {
"origin": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"y_axis": {
"y": 0.0,
"x": 0.0,
"z": 1.0
},
"x_axis": {
"y": 1.0,
"x": 0.0,
"z": 0.0
},
"z_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
}
},
"type": "Sketch",
"name": "Sketch 3",
"profiles": {
"JPC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.006985,
"x": -0.0218948,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0025019,
"curve": "JPB",
"normal": {
"y": 0.0,
"x": 1.0,
"z": 0.0
}
}
]
}
],
"properties": {}
},
"JPG": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.006985,
"x": -0.0035,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0025019,
"curve": "JPF",
"normal": {
"y": 0.0,
"x": 1.0,
"z": 0.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
},
"FPXPvHvj2sTuxfF_1": {
"transform": {
"origin": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"y_axis": {
"y": 0.0,
"x": 0.0,
"z": 1.0
},
"x_axis": {
"y": 1.0,
"x": 0.0,
"z": 0.0
},
"z_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
}
},
"type": "Sketch",
"name": "Sketch 2",
"profiles": {
"JLG": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.006985,
"x": -0.0218948,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0015,
"curve": "JLF",
"normal": {
"y": 0.0,
"x": 1.0,
"z": 0.0
}
}
]
}
],
"properties": {}
},
"JLC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.006985,
"x": -0.0035,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0015,
"curve": "JLB",
"normal": {
"y": 0.0,
"x": 1.0,
"z": 0.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
},
"Fl5EmzXybmYL8OB_0": {
"transform": {
"origin": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"y_axis": {
"y": 0.0,
"x": -0.0,
"z": 1.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
},
"type": "Sketch",
"name": "Sketch 1",
"profiles": {
"JGC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.01016,
"curve": "JGB",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
},
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.003175,
"curve": "JGF",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
},
"JGK": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.003175,
"curve": "JGF",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
},
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0025,
"curve": "JGJ",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
},
"JGG": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0025,
"curve": "JGJ",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
}
},
"properties": {
"bounding_box": {
"max_point": {
"y": 0.0,
"x": 0.010160000000000004,
"z": 0.010140136833396287
},
"type": "BoundingBox3D",
"min_point": {
"y": -0.025400000000000002,
"x": -0.010160000000000004,
"z": -0.010160000000000004
}
}
},
"sequence": [
{
"index": 0,
"type": "Sketch",
"entity": "Fl5EmzXybmYL8OB_0"
},
{
"index": 1,
"type": "ExtrudeFeature",
"entity": "F262llpzE1N6Ecl_0"
},
{
"index": 2,
"type": "ExtrudeFeature",
"entity": "FqOjU5KExGkflVJ_1"
},
{
"index": 3,
"type": "Sketch",
"entity": "FPXPvHvj2sTuxfF_1"
},
{
"index": 4,
"type": "ExtrudeFeature",
"entity": "FeetK5BcCKytC5s_1"
},
{
"index": 5,
"type": "Sketch",
"entity": "F4akSLM8jsEhHQd_1"
},
{
"index": 6,
"type": "ExtrudeFeature",
"entity": "FYk0kTmVxIulnxh_1"
},
{
"index": 7,
"type": "Sketch",
"entity": "Fo8ZVIGCycfBiaX_1"
}
]
}

View File

@@ -0,0 +1,910 @@
{
"entities": {
"FB1BsVVXjokR8sK_0": {
"name": "Extrude 1",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JGO",
"sketch": "Ff9nQMfu23XEMAd_0"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": 0.005080000000000001
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "NewBodyFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
},
"FZkEXQdoeyMOwbM_1": {
"transform": {
"origin": {
"y": 0.0,
"x": -0.0,
"z": 0.00125824
},
"y_axis": {
"y": -0.0,
"x": 0.0,
"z": 1.0
},
"x_axis": {
"y": 0.0,
"x": -1.0,
"z": 0.0
},
"z_axis": {
"y": 1.0,
"x": 0.0,
"z": 0.0
}
},
"type": "Sketch",
"name": "Sketch 3",
"profiles": {
"JNS": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"type": "Line3D",
"start_point": {
"y": -0.00439146,
"x": -0.00718479,
"z": 0.0
},
"curve": "JNB",
"end_point": {
"y": -0.00439146,
"x": -0.01310092,
"z": 0.0
}
},
{
"center_point": {
"y": -0.00125824,
"x": 0.0,
"z": 0.0
},
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": -0.00439146,
"x": -0.01310092,
"z": 0.0
},
"start_angle": 0.0,
"curve": "KNRB",
"end_angle": 0.550647298233991,
"radius": 0.01347038,
"type": "Arc3D",
"start_point": {
"y": -0.010783240000000001,
"x": -0.009525,
"z": 0.0
},
"reference_vector": {
"y": -0.2326006910873911,
"x": -0.9725723204500878,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": -0.010783240000000001,
"x": 0.009525,
"z": 0.0
},
"curve": "JN1",
"end_point": {
"y": -0.010783240000000001,
"x": -0.009525,
"z": 0.0
}
},
{
"center_point": {
"y": -0.00125824,
"x": 0.0,
"z": 0.0
},
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": -0.00439146,
"x": 0.01310092,
"z": 0.0
},
"start_angle": 0.0,
"curve": "KNJB",
"end_angle": 0.550647298233991,
"radius": 0.01347038,
"type": "Arc3D",
"start_point": {
"y": -0.010783240000000001,
"x": 0.009525,
"z": 0.0
},
"reference_vector": {
"y": -0.7071067811865476,
"x": 0.7071067811865476,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": -0.00439146,
"x": 0.00718479,
"z": 0.0
},
"curve": "JNd",
"end_point": {
"y": -0.00439146,
"x": 0.01310092,
"z": 0.0
}
},
{
"center_point": {
"y": -0.00566146,
"x": 0.00718479,
"z": 0.0
},
"normal": {
"y": 1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": -0.00439146,
"x": 0.00718479,
"z": 0.0
},
"start_angle": 0.0,
"curve": "JNl",
"end_angle": 1.5707963267948966,
"radius": 0.00127,
"type": "Arc3D",
"start_point": {
"y": -0.00566146,
"x": 0.00591479,
"z": 0.0
},
"reference_vector": {
"y": 1.0,
"x": 0.0,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": -0.00566146,
"x": 0.00591479,
"z": 0.0
},
"curve": "JNV",
"end_point": {
"y": -0.00826675,
"x": 0.00591479,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": -0.00826675,
"x": -0.00591479,
"z": 0.0
},
"curve": "JNt",
"end_point": {
"y": -0.00826675,
"x": 0.00591479,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": -0.00566146,
"x": -0.00591479,
"z": 0.0
},
"curve": "JNN",
"end_point": {
"y": -0.00826675,
"x": -0.00591479,
"z": 0.0
}
},
{
"center_point": {
"y": -0.00566146,
"x": -0.00718479,
"z": 0.0
},
"normal": {
"y": 1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": -0.00566146,
"x": -0.00591479,
"z": 0.0
},
"start_angle": 0.0,
"curve": "JNp",
"end_angle": 1.5707963267948966,
"radius": 0.00127,
"type": "Arc3D",
"start_point": {
"y": -0.00439146,
"x": -0.00718479,
"z": 0.0
},
"reference_vector": {
"y": 0.0,
"x": 1.0,
"z": 0.0
}
}
]
}
],
"properties": {}
},
"JNO": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"type": "Line3D",
"start_point": {
"y": -0.00439146,
"x": -0.01421416,
"z": 0.0
},
"curve": "JNF",
"end_point": {
"y": -0.00439146,
"x": -0.01310092,
"z": 0.0
}
},
{
"center_point": {
"y": -0.00125824,
"x": 0.0,
"z": 0.0
},
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": -0.00439146,
"x": -0.01310092,
"z": 0.0
},
"start_angle": 0.0,
"curve": "KNRB",
"end_angle": 0.550647298233991,
"radius": 0.01347038,
"type": "Arc3D",
"start_point": {
"y": -0.010783240000000001,
"x": -0.009525,
"z": 0.0
},
"reference_vector": {
"y": -0.2326006910873911,
"x": -0.9725723204500878,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": -0.010783240000000001,
"x": 0.009525,
"z": 0.0
},
"curve": "JN1",
"end_point": {
"y": -0.010783240000000001,
"x": -0.009525,
"z": 0.0
}
},
{
"center_point": {
"y": -0.00125824,
"x": 0.0,
"z": 0.0
},
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": -0.00439146,
"x": 0.01310092,
"z": 0.0
},
"start_angle": 0.0,
"curve": "KNJB",
"end_angle": 0.550647298233991,
"radius": 0.01347038,
"type": "Arc3D",
"start_point": {
"y": -0.010783240000000001,
"x": 0.009525,
"z": 0.0
},
"reference_vector": {
"y": -0.7071067811865476,
"x": 0.7071067811865476,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": -0.00439146,
"x": 0.01421416,
"z": 0.0
},
"curve": "JNh",
"end_point": {
"y": -0.00439146,
"x": 0.01310092,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": -0.011993940000000002,
"x": 0.01421416,
"z": 0.0
},
"curve": "JNZ",
"end_point": {
"y": -0.00439146,
"x": 0.01421416,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": -0.011993940000000002,
"x": -0.01421416,
"z": 0.0
},
"curve": "JNJ",
"end_point": {
"y": -0.011993940000000002,
"x": 0.01421416,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": -0.00439146,
"x": -0.01421416,
"z": 0.0
},
"curve": "JNR",
"end_point": {
"y": -0.011993940000000002,
"x": -0.01421416,
"z": 0.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
},
"FlICELfwWsWdhrL_1": {
"name": "Extrude 2",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JJO",
"sketch": "FmHlkQzj3o8nFL2_1"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": 0.018288000000000002
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "JoinFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
},
"FmHlkQzj3o8nFL2_1": {
"transform": {
"origin": {
"y": -0.00508,
"x": -0.0,
"z": 0.00125824
},
"y_axis": {
"y": 0.0,
"x": -0.0,
"z": 1.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
},
"type": "Sketch",
"name": "Sketch 2",
"profiles": {
"JJO": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": -0.00125824,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.006731,
"curve": "JJB",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
},
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": -0.00125824,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.003175,
"curve": "JJF",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
},
"JJC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": -0.00125824,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.003175,
"curve": "JJF",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
},
"Ff9nQMfu23XEMAd_0": {
"transform": {
"origin": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"y_axis": {
"y": 0.0,
"x": -0.0,
"z": 1.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
},
"type": "Sketch",
"name": "Sketch 1",
"profiles": {
"JGC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": -0.009525,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0014478,
"curve": "JGJ",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
},
"JGG": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.009525,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0014478,
"curve": "JGN",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
},
"JGK": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.003175,
"curve": "JGZ",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
},
"JGO": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"type": "Line3D",
"start_point": {
"y": 0.009525,
"x": -0.009525,
"z": 0.0
},
"curve": "JGB",
"end_point": {
"y": 0.009525,
"x": 0.009525,
"z": 0.0
}
},
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": -0.009525,
"x": 0.009525,
"z": 0.0
},
"start_angle": 0.0,
"curve": "JGV",
"end_angle": 1.5707963267948966,
"radius": 0.01347038,
"type": "Arc3D",
"start_point": {
"y": 0.009525,
"x": 0.009525,
"z": 0.0
},
"reference_vector": {
"y": -0.7071067811865476,
"x": 0.7071067811865476,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": -0.009525,
"x": -0.009525,
"z": 0.0
},
"curve": "JGF",
"end_point": {
"y": -0.009525,
"x": 0.009525,
"z": 0.0
}
},
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": -0.009525,
"x": -0.009525,
"z": 0.0
},
"start_angle": 0.0,
"curve": "JGR",
"end_angle": 1.5707963267948966,
"radius": 0.01347038,
"type": "Arc3D",
"start_point": {
"y": 0.009525,
"x": -0.009525,
"z": 0.0
},
"reference_vector": {
"y": 0.7071067811865476,
"x": -0.7071067811865476,
"z": 0.0
}
}
]
},
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": -0.009525,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0014478,
"curve": "JGJ",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
},
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.009525,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0014478,
"curve": "JGN",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
},
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.003175,
"curve": "JGZ",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
}
},
"properties": {
"bounding_box": {
"max_point": {
"y": 0.0,
"x": 0.013470384181603727,
"z": 0.009525
},
"type": "BoundingBox3D",
"min_point": {
"y": -0.023368000000000003,
"x": -0.01347038418160373,
"z": -0.007008510176092386
}
}
},
"sequence": [
{
"index": 0,
"type": "Sketch",
"entity": "Ff9nQMfu23XEMAd_0"
},
{
"index": 1,
"type": "ExtrudeFeature",
"entity": "FB1BsVVXjokR8sK_0"
},
{
"index": 2,
"type": "Sketch",
"entity": "FmHlkQzj3o8nFL2_1"
},
{
"index": 3,
"type": "ExtrudeFeature",
"entity": "FlICELfwWsWdhrL_1"
},
{
"index": 4,
"type": "Sketch",
"entity": "FZkEXQdoeyMOwbM_1"
}
]
}

View File

@@ -0,0 +1,823 @@
{
"entities": {
"FFM6rAYixEEIKBE_0": {
"transform": {
"origin": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"y_axis": {
"y": 0.0,
"x": -0.0,
"z": 1.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
},
"type": "Sketch",
"name": "Sketch 1",
"profiles": {
"JGK": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0127,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.003175,
"curve": "JG1",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
},
"JGO": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": -0.034925,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.003175,
"curve": "JGR",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
},
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": -0.034925,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0047625,
"curve": "JGZ",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
},
"JGa": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"type": "Line3D",
"start_point": {
"y": 0.0127,
"x": -0.041275,
"z": 0.0
},
"curve": "JGB",
"end_point": {
"y": 0.0127,
"x": -0.02566071,
"z": 0.0
}
},
{
"center_point": {
"y": 0.015875,
"x": -0.02566071,
"z": 0.0
},
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": 0.015875,
"x": -0.02248571,
"z": 0.0
},
"start_angle": 0.0,
"curve": "JG5",
"end_angle": 1.5707963267948966,
"radius": 0.003175,
"type": "Arc3D",
"start_point": {
"y": 0.0127,
"x": -0.02566071,
"z": 0.0
},
"reference_vector": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.015875,
"x": -0.02248571,
"z": 0.0
},
"curve": "JGp",
"end_point": {
"y": 0.01930466,
"x": -0.02248571,
"z": 0.0
}
},
{
"center_point": {
"y": 0.01930466,
"x": -0.01931071,
"z": 0.0
},
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": 0.01930466,
"x": -0.02248571,
"z": 0.0
},
"start_angle": 0.0,
"curve": "JG9",
"end_angle": 1.5707963267948966,
"radius": 0.003175,
"type": "Arc3D",
"start_point": {
"y": 0.02247966,
"x": -0.01931071,
"z": 0.0
},
"reference_vector": {
"y": 1.0,
"x": 0.0,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.02247966,
"x": 0.01931071,
"z": 0.0
},
"curve": "JGh",
"end_point": {
"y": 0.02247966,
"x": -0.01931071,
"z": 0.0
}
},
{
"center_point": {
"y": 0.01930466,
"x": 0.01931071,
"z": 0.0
},
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": 0.01930466,
"x": 0.02248571,
"z": 0.0
},
"start_angle": 0.0,
"curve": "KGBB",
"end_angle": 1.5707963267948966,
"radius": 0.003175,
"type": "Arc3D",
"start_point": {
"y": 0.02247966,
"x": 0.01931071,
"z": 0.0
},
"reference_vector": {
"y": 0.0,
"x": 1.0,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.015875,
"x": 0.02248571,
"z": 0.0
},
"curve": "JGl",
"end_point": {
"y": 0.01930466,
"x": 0.02248571,
"z": 0.0
}
},
{
"center_point": {
"y": 0.015875,
"x": 0.02566071,
"z": 0.0
},
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": 0.0127,
"x": 0.02566071,
"z": 0.0
},
"start_angle": 0.0,
"curve": "KGFB",
"end_angle": 1.5707963267948966,
"radius": 0.003175,
"type": "Arc3D",
"start_point": {
"y": 0.015875,
"x": 0.02248571,
"z": 0.0
},
"reference_vector": {
"y": 0.0,
"x": -1.0,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.0127,
"x": 0.02566071,
"z": 0.0
},
"curve": "JGt",
"end_point": {
"y": 0.0127,
"x": 0.041275,
"z": 0.0
}
},
{
"center_point": {
"y": 0.009525,
"x": 0.041275,
"z": 0.0
},
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": 0.0127,
"x": 0.041275,
"z": 0.0
},
"start_angle": 0.0,
"curve": "KGJB",
"end_angle": 1.5707963267948966,
"radius": 0.003175,
"type": "Arc3D",
"start_point": {
"y": 0.009525,
"x": 0.04445,
"z": 0.0
},
"reference_vector": {
"y": 0.0,
"x": 1.0,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.009525,
"x": 0.04445,
"z": 0.0
},
"curve": "JGN",
"end_point": {
"y": -0.009525,
"x": 0.04445,
"z": 0.0
}
},
{
"center_point": {
"y": -0.009525,
"x": 0.041275,
"z": 0.0
},
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": -0.009525,
"x": 0.04445,
"z": 0.0
},
"start_angle": 0.0,
"curve": "KGNB",
"end_angle": 1.5707963267948966,
"radius": 0.003175,
"type": "Arc3D",
"start_point": {
"y": -0.0127,
"x": 0.041275,
"z": 0.0
},
"reference_vector": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": -0.0127,
"x": -0.041275,
"z": 0.0
},
"curve": "JGF",
"end_point": {
"y": -0.0127,
"x": 0.041275,
"z": 0.0
}
},
{
"center_point": {
"y": -0.009525,
"x": -0.041275,
"z": 0.0
},
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": -0.009525,
"x": -0.04445,
"z": 0.0
},
"start_angle": 0.0,
"curve": "KGRB",
"end_angle": 1.5707963267948966,
"radius": 0.003175,
"type": "Arc3D",
"start_point": {
"y": -0.0127,
"x": -0.041275,
"z": 0.0
},
"reference_vector": {
"y": 0.0,
"x": -1.0,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.009525,
"x": -0.04445,
"z": 0.0
},
"curve": "JGJ",
"end_point": {
"y": -0.009525,
"x": -0.04445,
"z": 0.0
}
},
{
"center_point": {
"y": 0.009525,
"x": -0.041275,
"z": 0.0
},
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
},
"end_point": {
"y": 0.009525,
"x": -0.04445,
"z": 0.0
},
"start_angle": 0.0,
"curve": "KGVB",
"end_angle": 1.5707963267948966,
"radius": 0.003175,
"type": "Arc3D",
"start_point": {
"y": 0.0127,
"x": -0.041275,
"z": 0.0
},
"reference_vector": {
"y": 1.0,
"x": 0.0,
"z": 0.0
}
}
]
},
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": -0.034925,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0047625,
"curve": "JGZ",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
},
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.034925,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0047625,
"curve": "JGd",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
},
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0127,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.00873125,
"curve": "JGx",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
},
"JGC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": -0.034925,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.003175,
"curve": "JGR",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
},
"JGG": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.034925,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.003175,
"curve": "JGV",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
},
"JGS": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.034925,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.003175,
"curve": "JGV",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
},
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.034925,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0047625,
"curve": "JGd",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
},
"JGW": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0127,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.00873125,
"curve": "JGx",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
},
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0127,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.003175,
"curve": "JG1",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
},
"FyrL0AwNhBqP1e8_0": {
"name": "Extrude 1",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JGa",
"sketch": "FFM6rAYixEEIKBE_0"
},
{
"profile": "JGO",
"sketch": "FFM6rAYixEEIKBE_0"
},
{
"profile": "JGS",
"sketch": "FFM6rAYixEEIKBE_0"
},
{
"profile": "JGW",
"sketch": "FFM6rAYixEEIKBE_0"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": 0.006350000000000001
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "NewBodyFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
},
"F0gWDhaieH90UVv_1": {
"name": "Extrude 2",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JGW",
"sketch": "FFM6rAYixEEIKBE_0"
},
{
"profile": "JGS",
"sketch": "FFM6rAYixEEIKBE_0"
},
{
"profile": "JGO",
"sketch": "FFM6rAYixEEIKBE_0"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": 0.0031750000000000003
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "CutFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
}
},
"properties": {
"bounding_box": {
"max_point": {
"y": 0.0,
"x": 0.04445,
"z": 0.02247965972423567
},
"type": "BoundingBox3D",
"min_point": {
"y": -0.006350000000000001,
"x": -0.04445,
"z": -0.012700000000000003
}
}
},
"sequence": [
{
"index": 0,
"type": "Sketch",
"entity": "FFM6rAYixEEIKBE_0"
},
{
"index": 1,
"type": "ExtrudeFeature",
"entity": "FyrL0AwNhBqP1e8_0"
},
{
"index": 2,
"type": "ExtrudeFeature",
"entity": "F0gWDhaieH90UVv_1"
}
]
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,547 @@
{
"entities": {
"F94fSs5Rrru6Csr_1": {
"name": "Extrude 4",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JRG",
"sketch": "FgQr27bSD2lOoPV_1"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": -0.030457750000000002
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "NewBodyFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
},
"FJvbya9Ckc0JTKP_0": {
"name": "Extrude 1",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JGC",
"sketch": "F1cZkOtDYlVqWtk_0"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": 0.10793309
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "NewBodyFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
},
"F34Rmfkp42JY8ON_1": {
"transform": {
"origin": {
"y": -0.23403896,
"x": 0.0,
"z": 0.0
},
"y_axis": {
"y": 0.0,
"x": -0.0,
"z": 1.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
},
"type": "Sketch",
"name": "Sketch 3",
"profiles": {
"JNC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.02144662,
"curve": "JNB",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
},
"FZopFG87VXSkIrt_1": {
"name": "Extrude 2",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JJC",
"sketch": "FKI3A6vhIzpZNfN_1"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": 0.12610587
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "JoinFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
},
"F1cZkOtDYlVqWtk_0": {
"transform": {
"origin": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"y_axis": {
"y": 0.0,
"x": -0.0,
"z": 1.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
},
"type": "Sketch",
"name": "Sketch 1",
"profiles": {
"JGC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.04175514,
"curve": "JGB",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
},
"FgQr27bSD2lOoPV_1": {
"transform": {
"origin": {
"y": -0.23403896,
"x": 0.0,
"z": 0.0
},
"y_axis": {
"y": 0.0,
"x": -0.0,
"z": 1.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
},
"type": "Sketch",
"name": "Sketch 4",
"profiles": {
"JRG": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.05449525,
"curve": "JRF",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
},
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.02891399,
"curve": "JRJ",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
},
"JRC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.02144662,
"curve": "JRB",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
},
"JRK": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.02144662,
"curve": "JRB",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
},
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.02891399,
"curve": "JRJ",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
},
"FKI3A6vhIzpZNfN_1": {
"transform": {
"origin": {
"y": -0.10793309,
"x": 0.0,
"z": 0.0
},
"y_axis": {
"y": 0.0,
"x": -0.0,
"z": 1.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
},
"type": "Sketch",
"name": "Sketch 2",
"profiles": {
"JJC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.02891399,
"curve": "JJB",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
},
"F4IsHPXzRLoUquG_1": {
"name": "Extrude 3",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JNC",
"sketch": "F34Rmfkp42JY8ON_1"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": -0.26565213
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "CutFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
}
},
"properties": {
"bounding_box": {
"max_point": {
"y": 0.025400000000000002,
"x": 0.054495252668857574,
"z": 0.054495252668857574
},
"type": "BoundingBox3D",
"min_point": {
"y": -0.32511954,
"x": -0.054495252668857574,
"z": -0.054495252668857574
}
}
},
"sequence": [
{
"index": 0,
"type": "Sketch",
"entity": "F1cZkOtDYlVqWtk_0"
},
{
"index": 1,
"type": "ExtrudeFeature",
"entity": "FJvbya9Ckc0JTKP_0"
},
{
"index": 2,
"type": "Sketch",
"entity": "FKI3A6vhIzpZNfN_1"
},
{
"index": 3,
"type": "ExtrudeFeature",
"entity": "FZopFG87VXSkIrt_1"
},
{
"index": 4,
"type": "Sketch",
"entity": "F34Rmfkp42JY8ON_1"
},
{
"index": 5,
"type": "ExtrudeFeature",
"entity": "F4IsHPXzRLoUquG_1"
},
{
"index": 6,
"type": "Sketch",
"entity": "FgQr27bSD2lOoPV_1"
},
{
"index": 7,
"type": "ExtrudeFeature",
"entity": "F94fSs5Rrru6Csr_1"
}
]
}

View File

@@ -0,0 +1,308 @@
{
"entities": {
"Fz5ZkhSFew6soRB_0": {
"name": "Extrude 1",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JGC",
"sketch": "FvqT0Llm0TkI5qe_0"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": 0.02
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "NewBodyFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
},
"FR6JugW7scIQZrM_1": {
"transform": {
"origin": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"y_axis": {
"y": 0.0,
"x": -0.0,
"z": 1.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
},
"type": "Sketch",
"name": "Sketch 2",
"profiles": {
"JJC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.01,
"x": 0.0065,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0017526,
"curve": "JJB",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
},
"F8dMsQ0VNGp1h7Y_1": {
"name": "Extrude 2",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JJC",
"sketch": "FR6JugW7scIQZrM_1"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": -0.025
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "CutFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
},
"FvqT0Llm0TkI5qe_0": {
"transform": {
"origin": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"y_axis": {
"y": 1.0,
"x": 0.0,
"z": 0.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
},
"type": "Sketch",
"name": "Sketch 1",
"profiles": {
"JGC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"type": "Line3D",
"start_point": {
"y": 0.01,
"x": 0.0,
"z": 0.0
},
"curve": "JGB",
"end_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"curve": "JGF",
"end_point": {
"y": 0.0,
"x": 0.01,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.0,
"x": 0.01,
"z": 0.0
},
"curve": "JGJ",
"end_point": {
"y": 0.003,
"x": 0.01,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.003,
"x": 0.01,
"z": 0.0
},
"curve": "JGN",
"end_point": {
"y": 0.003,
"x": 0.003,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.003,
"x": 0.003,
"z": 0.0
},
"curve": "JGR",
"end_point": {
"y": 0.01,
"x": 0.003,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.01,
"x": 0.0,
"z": 0.0
},
"curve": "JGV",
"end_point": {
"y": 0.01,
"x": 0.003,
"z": 0.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
}
},
"properties": {
"bounding_box": {
"max_point": {
"y": 0.01,
"x": 0.01,
"z": 0.02
},
"type": "BoundingBox3D",
"min_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
}
}
},
"sequence": [
{
"index": 0,
"type": "Sketch",
"entity": "FvqT0Llm0TkI5qe_0"
},
{
"index": 1,
"type": "ExtrudeFeature",
"entity": "Fz5ZkhSFew6soRB_0"
},
{
"index": 2,
"type": "Sketch",
"entity": "FR6JugW7scIQZrM_1"
},
{
"index": 3,
"type": "ExtrudeFeature",
"entity": "F8dMsQ0VNGp1h7Y_1"
}
]
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,498 @@
{
"entities": {
"F5c4pqDbip87cOv_1": {
"name": "Extrude 2",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JJK",
"sketch": "FZ8bL1M2q7EXt0u_1"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": 0.0014
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "JoinFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
},
"FZ8bL1M2q7EXt0u_1": {
"transform": {
"origin": {
"y": -0.0,
"x": 0.0,
"z": 0.0016
},
"y_axis": {
"y": 1.0,
"x": 0.0,
"z": 0.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
},
"type": "Sketch",
"name": "Sketch 2",
"profiles": {
"JJC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0025,
"curve": "JJB",
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
]
}
],
"properties": {}
},
"JJK": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0025,
"curve": "JJB",
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
]
},
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.00345,
"curve": "JJF",
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
},
"F5BhbWqXcUw0QKR_0": {
"transform": {
"origin": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"y_axis": {
"y": 1.0,
"x": 0.0,
"z": 0.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
},
"type": "Sketch",
"name": "Sketch 1",
"profiles": {
"JGC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"type": "Line3D",
"start_point": {
"y": 0.0075,
"x": 0.0035,
"z": 0.0
},
"curve": "JGB",
"end_point": {
"y": 0.0075,
"x": -0.0035,
"z": 0.0
}
},
{
"center_point": {
"y": 0.006,
"x": -0.0035,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
},
"end_point": {
"y": 0.006,
"x": -0.005,
"z": 0.0
},
"start_angle": 0.0,
"curve": "JGR",
"end_angle": 1.5707963267948966,
"radius": 0.0015,
"type": "Arc3D",
"start_point": {
"y": 0.0075,
"x": -0.0035,
"z": 0.0
},
"reference_vector": {
"y": 1.0,
"x": 0.0,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.006,
"x": -0.005,
"z": 0.0
},
"curve": "JGN",
"end_point": {
"y": -0.006,
"x": -0.005,
"z": 0.0
}
},
{
"center_point": {
"y": -0.006,
"x": -0.0035,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
},
"end_point": {
"y": -0.006,
"x": -0.005,
"z": 0.0
},
"start_angle": 0.0,
"curve": "JGV",
"end_angle": 1.5707963267948966,
"radius": 0.0015,
"type": "Arc3D",
"start_point": {
"y": -0.0075,
"x": -0.0035,
"z": 0.0
},
"reference_vector": {
"y": 0.0,
"x": -1.0,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": -0.0075,
"x": 0.0035,
"z": 0.0
},
"curve": "JGF",
"end_point": {
"y": -0.0075,
"x": -0.0035,
"z": 0.0
}
},
{
"center_point": {
"y": -0.006,
"x": 0.0035,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
},
"end_point": {
"y": -0.006,
"x": 0.005,
"z": 0.0
},
"start_angle": 0.0,
"curve": "JGZ",
"end_angle": 1.5707963267948966,
"radius": 0.0015,
"type": "Arc3D",
"start_point": {
"y": -0.0075,
"x": 0.0035,
"z": 0.0
},
"reference_vector": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.006,
"x": 0.005,
"z": 0.0
},
"curve": "JGJ",
"end_point": {
"y": -0.006,
"x": 0.005,
"z": 0.0
}
},
{
"center_point": {
"y": 0.006,
"x": 0.0035,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
},
"end_point": {
"y": 0.006,
"x": 0.005,
"z": 0.0
},
"start_angle": 0.0,
"curve": "JGd",
"end_angle": 1.5707963267948966,
"radius": 0.0015,
"type": "Arc3D",
"start_point": {
"y": 0.0075,
"x": 0.0035,
"z": 0.0
},
"reference_vector": {
"y": 0.0,
"x": 1.0,
"z": 0.0
}
}
]
},
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0025,
"curve": "JGh",
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
]
}
],
"properties": {}
},
"JGG": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0025,
"curve": "JGh",
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
},
"FwAoVHn0IYyGbWo_0": {
"name": "Extrude 1",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JGC",
"sketch": "F5BhbWqXcUw0QKR_0"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": 0.0016
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "NewBodyFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
}
},
"properties": {
"bounding_box": {
"max_point": {
"y": 0.007499999999999999,
"x": 0.005000000000000001,
"z": 0.003
},
"type": "BoundingBox3D",
"min_point": {
"y": -0.0075,
"x": -0.005000000000000001,
"z": 0.0
}
}
},
"sequence": [
{
"index": 0,
"type": "Sketch",
"entity": "F5BhbWqXcUw0QKR_0"
},
{
"index": 1,
"type": "ExtrudeFeature",
"entity": "FwAoVHn0IYyGbWo_0"
},
{
"index": 2,
"type": "Sketch",
"entity": "FZ8bL1M2q7EXt0u_1"
},
{
"index": 3,
"type": "ExtrudeFeature",
"entity": "F5c4pqDbip87cOv_1"
}
]
}

View File

@@ -0,0 +1,498 @@
{
"entities": {
"F99k1D8wnwW2DMl_0": {
"transform": {
"origin": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"y_axis": {
"y": 1.0,
"x": 0.0,
"z": 0.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
},
"type": "Sketch",
"name": "Sketch 1",
"profiles": {
"JGC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"type": "Line3D",
"start_point": {
"y": 0.01,
"x": 0.0085,
"z": 0.0
},
"curve": "JGB",
"end_point": {
"y": 0.01,
"x": -0.0085,
"z": 0.0
}
},
{
"center_point": {
"y": 0.0085,
"x": -0.0085,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
},
"end_point": {
"y": 0.0085,
"x": -0.01,
"z": 0.0
},
"start_angle": 0.0,
"curve": "JGV",
"end_angle": 1.5707963267948966,
"radius": 0.0015,
"type": "Arc3D",
"start_point": {
"y": 0.01,
"x": -0.0085,
"z": 0.0
},
"reference_vector": {
"y": 1.0,
"x": 0.0,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.0085,
"x": -0.01,
"z": 0.0
},
"curve": "JGN",
"end_point": {
"y": -0.0085,
"x": -0.01,
"z": 0.0
}
},
{
"center_point": {
"y": -0.0085,
"x": -0.0085,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
},
"end_point": {
"y": -0.0085,
"x": -0.01,
"z": 0.0
},
"start_angle": 0.0,
"curve": "JGZ",
"end_angle": 1.5707963267948966,
"radius": 0.0015,
"type": "Arc3D",
"start_point": {
"y": -0.01,
"x": -0.0085,
"z": 0.0
},
"reference_vector": {
"y": 0.0,
"x": -1.0,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": -0.01,
"x": 0.0085,
"z": 0.0
},
"curve": "JGF",
"end_point": {
"y": -0.01,
"x": -0.0085,
"z": 0.0
}
},
{
"center_point": {
"y": -0.0085,
"x": 0.0085,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
},
"end_point": {
"y": -0.0085,
"x": 0.01,
"z": 0.0
},
"start_angle": 0.0,
"curve": "JGd",
"end_angle": 1.5707963267948966,
"radius": 0.0015,
"type": "Arc3D",
"start_point": {
"y": -0.01,
"x": 0.0085,
"z": 0.0
},
"reference_vector": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.0085,
"x": 0.01,
"z": 0.0
},
"curve": "JGJ",
"end_point": {
"y": -0.0085,
"x": 0.01,
"z": 0.0
}
},
{
"center_point": {
"y": 0.0085,
"x": 0.0085,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
},
"end_point": {
"y": 0.0085,
"x": 0.01,
"z": 0.0
},
"start_angle": 0.0,
"curve": "JGh",
"end_angle": 1.5707963267948966,
"radius": 0.0015,
"type": "Arc3D",
"start_point": {
"y": 0.01,
"x": 0.0085,
"z": 0.0
},
"reference_vector": {
"y": 0.0,
"x": 1.0,
"z": 0.0
}
}
]
},
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0025,
"curve": "JGR",
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
]
}
],
"properties": {}
},
"JGG": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0025,
"curve": "JGR",
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
},
"FVF0CQZ4DLkH0Xw_1": {
"name": "Extrude 2",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JJK",
"sketch": "FeTIkbBD8FHuMLr_1"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": -0.0015
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "CutFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
},
"FuPAaUoL6yD51aa_0": {
"name": "Extrude 1",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JGC",
"sketch": "F99k1D8wnwW2DMl_0"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": 0.003
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "NewBodyFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
},
"FeTIkbBD8FHuMLr_1": {
"transform": {
"origin": {
"y": 0.0,
"x": 0.0,
"z": 0.003
},
"y_axis": {
"y": 1.0,
"x": 0.0,
"z": 0.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
},
"type": "Sketch",
"name": "Sketch 2",
"profiles": {
"JJC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0025,
"curve": "JJB",
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
]
}
],
"properties": {}
},
"JJK": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0025,
"curve": "JJB",
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
]
},
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.005,
"curve": "JJF",
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
}
},
"properties": {
"bounding_box": {
"max_point": {
"y": 0.01,
"x": 0.01,
"z": 0.003
},
"type": "BoundingBox3D",
"min_point": {
"y": -0.01,
"x": -0.01,
"z": 0.0
}
}
},
"sequence": [
{
"index": 0,
"type": "Sketch",
"entity": "F99k1D8wnwW2DMl_0"
},
{
"index": 1,
"type": "ExtrudeFeature",
"entity": "FuPAaUoL6yD51aa_0"
},
{
"index": 2,
"type": "Sketch",
"entity": "FeTIkbBD8FHuMLr_1"
},
{
"index": 3,
"type": "ExtrudeFeature",
"entity": "FVF0CQZ4DLkH0Xw_1"
}
]
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,572 @@
{
"entities": {
"FmrV6HbxzaryA5E_1": {
"name": "Extrude 4",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JVC",
"sketch": "FJmIje6KzlYzJQu_1"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": 0.012700000000000001
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "JoinFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
},
"FsNWntU6DsmMLjO_1": {
"transform": {
"origin": {
"y": 0.0,
"x": -0.0254,
"z": 0.0254
},
"y_axis": {
"y": -0.0,
"x": 0.0,
"z": 1.0
},
"x_axis": {
"y": 0.0,
"x": -1.0,
"z": 0.0
},
"z_axis": {
"y": 1.0,
"x": 0.0,
"z": 0.0
}
},
"type": "Sketch",
"name": "Sketch 3",
"profiles": {
"JNC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0127,
"curve": "JNB",
"normal": {
"y": 1.0,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
},
"FsVXe897f08Tjls_1": {
"transform": {
"origin": {
"y": -0.0508,
"x": -0.0254,
"z": 0.0254
},
"y_axis": {
"y": 0.0,
"x": -0.0,
"z": 1.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
},
"type": "Sketch",
"name": "Sketch 4",
"profiles": {},
"reference_plane": {}
},
"FbeI0JR1aX5BPSI_0": {
"name": "Extrude 1",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JGC",
"sketch": "FaMBajUC8yyUjTc_0"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": 0.050800000000000005
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "NewBodyFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
},
"FJmIje6KzlYzJQu_1": {
"transform": {
"origin": {
"y": -0.0254,
"x": 0.0,
"z": 0.0254
},
"y_axis": {
"y": 0.0,
"x": 0.0,
"z": 1.0
},
"x_axis": {
"y": 1.0,
"x": 0.0,
"z": 0.0
},
"z_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
}
},
"type": "Sketch",
"name": "Sketch 5",
"profiles": {
"JVC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"type": "Line3D",
"start_point": {
"y": 0.012700000000000003,
"x": -0.012700000000000003,
"z": 0.0
},
"curve": "JVB",
"end_point": {
"y": 0.012700000000000003,
"x": 0.0127,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.012700000000000003,
"x": 0.0127,
"z": 0.0
},
"curve": "JVN",
"end_point": {
"y": -0.0127,
"x": 0.0127,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": -0.0127,
"x": -0.012700000000000003,
"z": 0.0
},
"curve": "JVF",
"end_point": {
"y": -0.0127,
"x": 0.0127,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.012700000000000003,
"x": -0.012700000000000003,
"z": 0.0
},
"curve": "JVJ",
"end_point": {
"y": -0.0127,
"x": -0.012700000000000003,
"z": 0.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
},
"FfmWQ7YnYtyaUaY_1": {
"name": "Extrude 2",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JJC",
"sketch": "F9BMMoQbB6HQfC2_1"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": -0.050800000000000005
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "CutFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
},
"FaMBajUC8yyUjTc_0": {
"transform": {
"origin": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"y_axis": {
"y": 0.0,
"x": -0.0,
"z": 1.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
},
"type": "Sketch",
"name": "Sketch 1",
"profiles": {
"JGC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"type": "Line3D",
"start_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"curve": "JGB",
"end_point": {
"y": 0.0,
"x": -0.0508,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.0,
"x": -0.0508,
"z": 0.0
},
"curve": "JGN",
"end_point": {
"y": 0.0508,
"x": -0.0508,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.0508,
"x": 0.0,
"z": 0.0
},
"curve": "JGF",
"end_point": {
"y": 0.0508,
"x": -0.0508,
"z": 0.0
}
},
{
"type": "Line3D",
"start_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"curve": "JGJ",
"end_point": {
"y": 0.0508,
"x": 0.0,
"z": 0.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
},
"F9BMMoQbB6HQfC2_1": {
"transform": {
"origin": {
"y": -0.0254,
"x": -0.0254,
"z": 0.0508
},
"y_axis": {
"y": 1.0,
"x": 0.0,
"z": -0.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": 0.0,
"x": -0.0,
"z": 1.0
}
},
"type": "Sketch",
"name": "Sketch 2",
"profiles": {
"JJC": {
"loops": [
{
"is_outer": true,
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Circle3D",
"radius": 0.0127,
"curve": "JJB",
"normal": {
"y": 0.0,
"x": -0.0,
"z": 1.0
}
}
]
}
],
"properties": {}
}
},
"reference_plane": {}
},
"FDEzbkABrHGG40C_1": {
"name": "Extrude 3",
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JNC",
"sketch": "FsNWntU6DsmMLjO_1"
}
],
"extent_two": {
"distance": {
"type": "ModelParameter",
"role": "AgainstDistance",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "Side2TaperAngle",
"name": "none",
"value": 0.0
}
},
"extent_one": {
"distance": {
"type": "ModelParameter",
"role": "AlongDistance",
"name": "none",
"value": 0.012700000000000001
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"type": "ModelParameter",
"role": "TaperAngle",
"name": "none",
"value": 0.0
}
},
"operation": "JoinFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"extent_type": "OneSideFeatureExtentType"
}
},
"properties": {
"bounding_box": {
"max_point": {
"y": 0.012700000000000001,
"x": 0.012700000000000001,
"z": 0.05080000000000001
},
"type": "BoundingBox3D",
"min_point": {
"y": -0.050800000000000005,
"x": -0.05080000000000002,
"z": 0.0
}
}
},
"sequence": [
{
"index": 0,
"type": "Sketch",
"entity": "FaMBajUC8yyUjTc_0"
},
{
"index": 1,
"type": "ExtrudeFeature",
"entity": "FbeI0JR1aX5BPSI_0"
},
{
"index": 2,
"type": "Sketch",
"entity": "F9BMMoQbB6HQfC2_1"
},
{
"index": 3,
"type": "ExtrudeFeature",
"entity": "FfmWQ7YnYtyaUaY_1"
},
{
"index": 4,
"type": "Sketch",
"entity": "FsNWntU6DsmMLjO_1"
},
{
"index": 5,
"type": "ExtrudeFeature",
"entity": "FDEzbkABrHGG40C_1"
},
{
"index": 6,
"type": "Sketch",
"entity": "FsVXe897f08Tjls_1"
},
{
"index": 7,
"type": "Sketch",
"entity": "FJmIje6KzlYzJQu_1"
},
{
"index": 8,
"type": "ExtrudeFeature",
"entity": "FmrV6HbxzaryA5E_1"
}
]
}

View File

@@ -0,0 +1,606 @@
{
"entities": {
"FJuq88FpdEHHyl9_0": {
"reference_plane": {},
"type": "Sketch",
"name": "Sketch 1",
"profiles": {
"JGC": {
"loops": [
{
"profile_curves": [
{
"start_point": {
"y": 0.0,
"x": 0.01,
"z": 0.0
},
"type": "Line3D",
"curve": "JGB",
"end_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
}
},
{
"start_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Line3D",
"curve": "JGN",
"end_point": {
"y": 0.01,
"x": 0.0,
"z": 0.0
}
},
{
"start_point": {
"y": 0.01,
"x": 0.01,
"z": 0.0
},
"type": "Line3D",
"curve": "JGF",
"end_point": {
"y": 0.01,
"x": 0.0,
"z": 0.0
}
},
{
"start_point": {
"y": 0.0,
"x": 0.01,
"z": 0.0
},
"type": "Line3D",
"curve": "JGJ",
"end_point": {
"y": 0.01,
"x": 0.01,
"z": 0.0
}
}
],
"is_outer": true
},
{
"profile_curves": [
{
"center_point": {
"y": 0.005,
"x": 0.005,
"z": 0.0
},
"radius": 0.00150015,
"type": "Circle3D",
"curve": "JGR",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
],
"is_outer": true
}
],
"properties": {}
},
"JGG": {
"loops": [
{
"profile_curves": [
{
"center_point": {
"y": 0.005,
"x": 0.005,
"z": 0.0
},
"radius": 0.00150015,
"type": "Circle3D",
"curve": "JGR",
"normal": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
],
"is_outer": true
}
],
"properties": {}
}
},
"transform": {
"origin": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"y_axis": {
"y": 0.0,
"x": -0.0,
"z": 1.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": -1.0,
"x": 0.0,
"z": 0.0
}
}
},
"FRCqhvaTLC45hNi_0": {
"reference_plane": {},
"type": "Sketch",
"name": "Sketch 2",
"profiles": {
"JIG": {
"loops": [
{
"profile_curves": [
{
"center_point": {
"y": 0.005,
"x": 0.005,
"z": 0.0
},
"radius": 0.00150015,
"type": "Circle3D",
"curve": "JIR",
"normal": {
"y": 0.0,
"x": 1.0,
"z": 0.0
}
}
],
"is_outer": true
}
],
"properties": {}
},
"JIC": {
"loops": [
{
"profile_curves": [
{
"start_point": {
"y": 0.0,
"x": 0.01,
"z": 0.0
},
"type": "Line3D",
"curve": "JIB",
"end_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
}
},
{
"start_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Line3D",
"curve": "JIN",
"end_point": {
"y": 0.01,
"x": 0.0,
"z": 0.0
}
},
{
"start_point": {
"y": 0.01,
"x": 0.01,
"z": 0.0
},
"type": "Line3D",
"curve": "JIF",
"end_point": {
"y": 0.01,
"x": 0.0,
"z": 0.0
}
},
{
"start_point": {
"y": 0.0,
"x": 0.01,
"z": 0.0
},
"type": "Line3D",
"curve": "JIJ",
"end_point": {
"y": 0.01,
"x": 0.01,
"z": 0.0
}
}
],
"is_outer": true
},
{
"profile_curves": [
{
"center_point": {
"y": 0.005,
"x": 0.005,
"z": 0.0
},
"radius": 0.00150015,
"type": "Circle3D",
"curve": "JIR",
"normal": {
"y": 0.0,
"x": 1.0,
"z": 0.0
}
}
],
"is_outer": true
}
],
"properties": {}
}
},
"transform": {
"origin": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"y_axis": {
"y": 0.0,
"x": 0.0,
"z": 1.0
},
"x_axis": {
"y": 1.0,
"x": 0.0,
"z": 0.0
},
"z_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
}
}
},
"FzDqYq1JMieZAmV_0": {
"reference_plane": {},
"type": "Sketch",
"name": "Sketch 3",
"profiles": {
"JKG": {
"loops": [
{
"profile_curves": [
{
"center_point": {
"y": 0.005,
"x": 0.005,
"z": 0.0
},
"radius": 0.00150015,
"type": "Circle3D",
"curve": "JKR",
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
],
"is_outer": true
}
],
"properties": {}
},
"JKC": {
"loops": [
{
"profile_curves": [
{
"start_point": {
"y": 0.0,
"x": 0.01,
"z": 0.0
},
"type": "Line3D",
"curve": "JKB",
"end_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
}
},
{
"start_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"type": "Line3D",
"curve": "JKN",
"end_point": {
"y": 0.01,
"x": 0.0,
"z": 0.0
}
},
{
"start_point": {
"y": 0.01,
"x": 0.01,
"z": 0.0
},
"type": "Line3D",
"curve": "JKF",
"end_point": {
"y": 0.01,
"x": 0.0,
"z": 0.0
}
},
{
"start_point": {
"y": 0.0,
"x": 0.01,
"z": 0.0
},
"type": "Line3D",
"curve": "JKJ",
"end_point": {
"y": 0.01,
"x": 0.01,
"z": 0.0
}
}
],
"is_outer": true
},
{
"profile_curves": [
{
"center_point": {
"y": 0.005,
"x": 0.005,
"z": 0.0
},
"radius": 0.00150015,
"type": "Circle3D",
"curve": "JKR",
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
],
"is_outer": true
}
],
"properties": {}
}
},
"transform": {
"origin": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"y_axis": {
"y": 1.0,
"x": 0.0,
"z": 0.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
},
"FEguRxck489nlUH_0": {
"extent_two": {
"distance": {
"role": "AgainstDistance",
"type": "ModelParameter",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"role": "Side2TaperAngle",
"type": "ModelParameter",
"name": "none",
"value": 0.0
}
},
"name": "Extrude 1",
"extent_one": {
"distance": {
"role": "AlongDistance",
"type": "ModelParameter",
"name": "none",
"value": -0.0015
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"role": "TaperAngle",
"type": "ModelParameter",
"name": "none",
"value": 0.0
}
},
"extent_type": "OneSideFeatureExtentType",
"operation": "NewBodyFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JGC",
"sketch": "FJuq88FpdEHHyl9_0"
}
]
},
"FfFCWbj9yhmlzJq_1": {
"extent_two": {
"distance": {
"role": "AgainstDistance",
"type": "ModelParameter",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"role": "Side2TaperAngle",
"type": "ModelParameter",
"name": "none",
"value": 0.0
}
},
"name": "Extrude 2",
"extent_one": {
"distance": {
"role": "AlongDistance",
"type": "ModelParameter",
"name": "none",
"value": 0.0015
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"role": "TaperAngle",
"type": "ModelParameter",
"name": "none",
"value": 0.0
}
},
"extent_type": "OneSideFeatureExtentType",
"operation": "JoinFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JKC",
"sketch": "FzDqYq1JMieZAmV_0"
}
]
},
"FZQ8SCqstPv0Z03_1": {
"extent_two": {
"distance": {
"role": "AgainstDistance",
"type": "ModelParameter",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"role": "Side2TaperAngle",
"type": "ModelParameter",
"name": "none",
"value": 0.0
}
},
"name": "Extrude 3",
"extent_one": {
"distance": {
"role": "AlongDistance",
"type": "ModelParameter",
"name": "none",
"value": 0.0015
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"role": "TaperAngle",
"type": "ModelParameter",
"name": "none",
"value": 0.0
}
},
"extent_type": "OneSideFeatureExtentType",
"operation": "JoinFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JIC",
"sketch": "FRCqhvaTLC45hNi_0"
}
]
}
},
"properties": {
"bounding_box": {
"max_point": {
"y": 0.010000000000000002,
"x": 0.010000000000000002,
"z": 0.010000000000000002
},
"type": "BoundingBox3D",
"min_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
}
}
},
"sequence": [
{
"index": 0,
"type": "Sketch",
"entity": "FJuq88FpdEHHyl9_0"
},
{
"index": 1,
"type": "Sketch",
"entity": "FRCqhvaTLC45hNi_0"
},
{
"index": 2,
"type": "Sketch",
"entity": "FzDqYq1JMieZAmV_0"
},
{
"index": 3,
"type": "ExtrudeFeature",
"entity": "FEguRxck489nlUH_0"
},
{
"index": 4,
"type": "ExtrudeFeature",
"entity": "FfFCWbj9yhmlzJq_1"
},
{
"index": 5,
"type": "ExtrudeFeature",
"entity": "FZQ8SCqstPv0Z03_1"
}
]
}

View File

@@ -0,0 +1,239 @@
{
"entities": {
"FpO04MEuGua24Pb_0": {
"reference_plane": {},
"type": "Sketch",
"name": "Sketch 1",
"profiles": {
"JGC": {
"loops": [
{
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"radius": 0.009,
"type": "Circle3D",
"curve": "JGB",
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
],
"is_outer": true
}
],
"properties": {}
}
},
"transform": {
"origin": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"y_axis": {
"y": 1.0,
"x": 0.0,
"z": 0.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
},
"FzNOyOEp7IOU6cG_0": {
"extent_two": {
"distance": {
"role": "AgainstDistance",
"type": "ModelParameter",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"role": "Side2TaperAngle",
"type": "ModelParameter",
"name": "none",
"value": 0.0
}
},
"name": "Extrude 1",
"extent_one": {
"distance": {
"role": "AlongDistance",
"type": "ModelParameter",
"name": "none",
"value": 0.005
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"role": "TaperAngle",
"type": "ModelParameter",
"name": "none",
"value": 0.0
}
},
"extent_type": "OneSideFeatureExtentType",
"operation": "NewBodyFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JGC",
"sketch": "FpO04MEuGua24Pb_0"
}
]
},
"FmWYDK3pbyUD5IL_1": {
"reference_plane": {},
"type": "Sketch",
"name": "Sketch 2",
"profiles": {
"JJC": {
"loops": [
{
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"radius": 0.0062,
"type": "Circle3D",
"curve": "JJB",
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
],
"is_outer": true
}
],
"properties": {}
}
},
"transform": {
"origin": {
"y": 0.0,
"x": 0.0,
"z": 0.005
},
"y_axis": {
"y": 1.0,
"x": 0.0,
"z": 0.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
},
"FgMDBvjh4kgvPkY_1": {
"extent_two": {
"distance": {
"role": "AgainstDistance",
"type": "ModelParameter",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"role": "Side2TaperAngle",
"type": "ModelParameter",
"name": "none",
"value": 0.0
}
},
"name": "Extrude 2",
"extent_one": {
"distance": {
"role": "AlongDistance",
"type": "ModelParameter",
"name": "none",
"value": 0.007
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"role": "TaperAngle",
"type": "ModelParameter",
"name": "none",
"value": 0.0
}
},
"extent_type": "OneSideFeatureExtentType",
"operation": "JoinFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JJC",
"sketch": "FmWYDK3pbyUD5IL_1"
}
]
}
},
"properties": {
"bounding_box": {
"max_point": {
"y": 0.009000000000000003,
"x": 0.009000000000000003,
"z": 0.014
},
"type": "BoundingBox3D",
"min_point": {
"y": -0.009000000000000003,
"x": -0.009000000000000003,
"z": 0.0
}
}
},
"sequence": [
{
"index": 0,
"type": "Sketch",
"entity": "FpO04MEuGua24Pb_0"
},
{
"index": 1,
"type": "ExtrudeFeature",
"entity": "FzNOyOEp7IOU6cG_0"
},
{
"index": 2,
"type": "Sketch",
"entity": "FmWYDK3pbyUD5IL_1"
},
{
"index": 3,
"type": "ExtrudeFeature",
"entity": "FgMDBvjh4kgvPkY_1"
}
]
}

View File

@@ -0,0 +1,761 @@
{
"entities": {
"FRX1UekMEYmT7BZ_0": {
"reference_plane": {},
"type": "Sketch",
"name": "Sketch 1",
"profiles": {
"JGC": {
"loops": [
{
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"radius": 0.03175,
"type": "Circle3D",
"curve": "JGB",
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
],
"is_outer": true
},
{
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"radius": 0.0111125,
"type": "Circle3D",
"curve": "JGF",
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
],
"is_outer": true
}
],
"properties": {}
},
"JGG": {
"loops": [
{
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"radius": 0.0111125,
"type": "Circle3D",
"curve": "JGF",
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
],
"is_outer": true
}
],
"properties": {}
}
},
"transform": {
"origin": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"y_axis": {
"y": 1.0,
"x": 0.0,
"z": 0.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
},
"F5tX7NvnA1Y5aRR_0": {
"extent_two": {
"distance": {
"role": "AgainstDistance",
"type": "ModelParameter",
"name": "none",
"value": 0.0
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"role": "Side2TaperAngle",
"type": "ModelParameter",
"name": "none",
"value": 0.0
}
},
"name": "Extrude 1",
"extent_one": {
"distance": {
"role": "AlongDistance",
"type": "ModelParameter",
"name": "none",
"value": 0.006350000000000001
},
"type": "DistanceExtentDefinition",
"taper_angle": {
"role": "TaperAngle",
"type": "ModelParameter",
"name": "none",
"value": 0.0
}
},
"extent_type": "OneSideFeatureExtentType",
"operation": "NewBodyFeatureOperation",
"start_extent": {
"type": "ProfilePlaneStartDefinition"
},
"type": "ExtrudeFeature",
"profiles": [
{
"profile": "JGC",
"sketch": "FRX1UekMEYmT7BZ_0"
}
]
},
"FlG94wXw67CXwu8_1": {
"reference_plane": {},
"type": "Sketch",
"name": "Sketch 2",
"profiles": {
"JJG": {
"loops": [
{
"profile_curves": [
{
"center_point": {
"y": -0.01085092,
"x": 0.01760707,
"z": 0.0
},
"start_angle": 0.0,
"radius": 0.00817648,
"end_point": {
"y": -0.00544286,
"x": 0.01147455,
"z": 0.0
},
"start_point": {
"y": -0.01625898,
"x": 0.02373958,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
},
"type": "Arc3D",
"curve": "JJR",
"end_angle": 3.14159346251536,
"reference_vector": {
"y": -0.6614168135850699,
"x": 0.7500185322423527,
"z": 0.0
}
},
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"start_angle": 0.0,
"radius": 0.0127,
"end_point": {
"y": -0.01147455,
"x": 0.00544286,
"z": 0.0
},
"start_point": {
"y": -0.00544286,
"x": 0.01147455,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": -1.0
},
"type": "Arc3D",
"curve": "JJd",
"end_angle": 0.684973807357478,
"reference_vector": {
"y": -0.9035078104859143,
"x": 0.4285716234084442,
"z": 0.0
}
},
{
"center_point": {
"y": -0.0179236,
"x": 0.01017941,
"z": 0.0
},
"start_angle": 0.0,
"radius": 0.00800158,
"end_point": {
"y": -0.01147455,
"x": 0.00544286,
"z": 0.0
},
"start_point": {
"y": -0.02437266,
"x": 0.01491596,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": -1.0
},
"type": "Arc3D",
"curve": "JJZ",
"end_angle": 3.141591913795338,
"reference_vector": {
"y": 0.8059728931112685,
"x": -0.5919524436725064,
"z": 0.0
}
},
{
"center_point": {
"y": -0.00407723,
"x": 0.00439573,
"z": 0.0
},
"start_angle": 0.0,
"radius": 0.02286,
"end_point": {
"y": -0.02437266,
"x": 0.01491596,
"z": 0.0
},
"start_point": {
"y": -0.01625898,
"x": 0.02373958,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": -1.0
},
"type": "Arc3D",
"curve": "JJV",
"end_angle": 0.5305667776595886,
"reference_vector": {
"y": -0.8878139853867381,
"x": 0.4602024851646467,
"z": 0.0
}
}
],
"is_outer": true
}
],
"properties": {}
},
"JJK": {
"loops": [
{
"profile_curves": [
{
"center_point": {
"y": 0.0179236,
"x": -0.01017941,
"z": 0.0
},
"start_angle": 0.0,
"radius": 0.00800158,
"end_point": {
"y": 0.01147455,
"x": -0.00544286,
"z": 0.0
},
"start_point": {
"y": 0.02437266,
"x": -0.01491596,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": -1.0
},
"type": "Arc3D",
"curve": "JJh",
"end_angle": 3.141591913795338,
"reference_vector": {
"y": -0.8059728931112685,
"x": 0.5919524436725064,
"z": 0.0
}
},
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"start_angle": 0.0,
"radius": 0.0127,
"end_point": {
"y": 0.00544286,
"x": -0.01147455,
"z": 0.0
},
"start_point": {
"y": 0.01147455,
"x": -0.00544286,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": -1.0
},
"type": "Arc3D",
"curve": "JJl",
"end_angle": 0.6849738073574776,
"reference_vector": {
"y": 0.9035078104859143,
"x": -0.4285716234084442,
"z": 0.0
}
},
{
"center_point": {
"y": 0.01085092,
"x": -0.01760707,
"z": 0.0
},
"start_angle": 0.0,
"radius": 0.00817648,
"end_point": {
"y": 0.01625898,
"x": -0.02373958,
"z": 0.0
},
"start_point": {
"y": 0.00544286,
"x": -0.01147455,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
},
"type": "Arc3D",
"curve": "JJp",
"end_angle": 3.141593462515359,
"reference_vector": {
"y": 0.6614168135850699,
"x": -0.7500185322423527,
"z": 0.0
}
},
{
"center_point": {
"y": 0.00407723,
"x": -0.00439573,
"z": 0.0
},
"start_angle": 0.0,
"radius": 0.02286,
"end_point": {
"y": 0.01625898,
"x": -0.02373958,
"z": 0.0
},
"start_point": {
"y": 0.02437266,
"x": -0.01491596,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": -1.0
},
"type": "Arc3D",
"curve": "JJt",
"end_angle": 0.5305667776595886,
"reference_vector": {
"y": 0.8878139853867381,
"x": -0.4602024851646467,
"z": 0.0
}
}
],
"is_outer": true
}
],
"properties": {}
},
"JJO": {
"loops": [
{
"profile_curves": [
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"start_angle": 0.0,
"radius": 0.0127,
"end_point": {
"y": -0.01147455,
"x": -0.00544286,
"z": 0.0
},
"start_point": {
"y": -0.00544286,
"x": -0.01147455,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
},
"type": "Arc3D",
"curve": "JJx",
"end_angle": 0.6849738073574776,
"reference_vector": {
"y": -0.4285716234084442,
"x": -0.9035078104859143,
"z": 0.0
}
},
{
"center_point": {
"y": -0.0179236,
"x": -0.01017941,
"z": 0.0
},
"start_angle": 0.0,
"radius": 0.00800158,
"end_point": {
"y": -0.02437266,
"x": -0.01491596,
"z": 0.0
},
"start_point": {
"y": -0.01147455,
"x": -0.00544286,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
},
"type": "Arc3D",
"curve": "JJ9",
"end_angle": 3.141591913795338,
"reference_vector": {
"y": -0.8059733310341832,
"x": -0.5919518474180674,
"z": 0.0
}
},
{
"center_point": {
"y": -0.00407723,
"x": -0.00439573,
"z": 0.0
},
"start_angle": 0.0,
"radius": 0.02286,
"end_point": {
"y": -0.02437266,
"x": -0.01491596,
"z": 0.0
},
"start_point": {
"y": -0.01625898,
"x": -0.02373958,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
},
"type": "Arc3D",
"curve": "JJ5",
"end_angle": 0.5305667776595886,
"reference_vector": {
"y": -0.5328849692748923,
"x": -0.8461876916623742,
"z": 0.0
}
},
{
"center_point": {
"y": -0.01085092,
"x": -0.01760707,
"z": 0.0
},
"start_angle": 0.0,
"radius": 0.00817648,
"end_point": {
"y": -0.01625898,
"x": -0.02373958,
"z": 0.0
},
"start_point": {
"y": -0.00544286,
"x": -0.01147455,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": -1.0
},
"type": "Arc3D",
"curve": "JJ1",
"end_angle": 3.1415934625153596,
"reference_vector": {
"y": 0.6614162068756875,
"x": 0.7500190672790779,
"z": 0.0
}
}
],
"is_outer": true
}
],
"properties": {}
},
"JJC": {
"loops": [
{
"profile_curves": [
{
"center_point": {
"y": 0.0179236,
"x": 0.01017941,
"z": 0.0
},
"start_angle": 0.0,
"radius": 0.00800158,
"end_point": {
"y": 0.01147455,
"x": 0.00544286,
"z": 0.0
},
"start_point": {
"y": 0.02437266,
"x": 0.01491596,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
},
"type": "Arc3D",
"curve": "JJB",
"end_angle": 3.141591913795338,
"reference_vector": {
"y": 0.8059733310341832,
"x": 0.5919518474180674,
"z": 0.0
}
},
{
"center_point": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"start_angle": 0.0,
"radius": 0.0127,
"end_point": {
"y": 0.00544286,
"x": 0.01147455,
"z": 0.0
},
"start_point": {
"y": 0.01147455,
"x": 0.00544286,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
},
"type": "Arc3D",
"curve": "JJJ",
"end_angle": 0.6849738073574777,
"reference_vector": {
"y": 0.4285716234084442,
"x": 0.9035078104859143,
"z": 0.0
}
},
{
"center_point": {
"y": 0.01085092,
"x": 0.01760707,
"z": 0.0
},
"start_angle": 0.0,
"radius": 0.00817648,
"end_point": {
"y": 0.00544286,
"x": 0.01147455,
"z": 0.0
},
"start_point": {
"y": 0.01625898,
"x": 0.02373958,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": -1.0
},
"type": "Arc3D",
"curve": "JJF",
"end_angle": 3.1415934625153596,
"reference_vector": {
"y": -0.6614162068756875,
"x": -0.7500190672790779,
"z": 0.0
}
},
{
"center_point": {
"y": 0.00407723,
"x": 0.00439573,
"z": 0.0
},
"start_angle": 0.0,
"radius": 0.02286,
"end_point": {
"y": 0.01625898,
"x": 0.02373958,
"z": 0.0
},
"start_point": {
"y": 0.02437266,
"x": 0.01491596,
"z": 0.0
},
"normal": {
"y": 0.0,
"x": 0.0,
"z": 1.0
},
"type": "Arc3D",
"curve": "JJN",
"end_angle": 0.5305667776595889,
"reference_vector": {
"y": 0.5328849692748923,
"x": 0.8461876916623742,
"z": 0.0
}
}
],
"is_outer": true
}
],
"properties": {}
}
},
"transform": {
"origin": {
"y": 0.0,
"x": 0.0,
"z": 0.0
},
"y_axis": {
"y": 1.0,
"x": 0.0,
"z": 0.0
},
"x_axis": {
"y": 0.0,
"x": 1.0,
"z": 0.0
},
"z_axis": {
"y": 0.0,
"x": 0.0,
"z": 1.0
}
}
}
},
"properties": {
"bounding_box": {
"max_point": {
"y": 0.03175,
"x": 0.03175,
"z": 0.006350000000000001
},
"type": "BoundingBox3D",
"min_point": {
"y": -0.03175,
"x": -0.03175,
"z": 0.0
}
}
},
"sequence": [
{
"index": 0,
"type": "Sketch",
"entity": "FRX1UekMEYmT7BZ_0"
},
{
"index": 1,
"type": "ExtrudeFeature",
"entity": "F5tX7NvnA1Y5aRR_0"
},
{
"index": 2,
"type": "Sketch",
"entity": "FlG94wXw67CXwu8_1"
}
]
}

113
Bethany/json2dataset.py Normal file
View File

@@ -0,0 +1,113 @@
import os
import glob
import json
import argparse
import sys
sys.path.append(".")
from lib.extrude import CADSequence
from lib.cad2code import get_cad_code
from count_tokens.count import count_tokens_in_string
parser = argparse.ArgumentParser()
parser.add_argument('--src', type=str, required=True, help="source folder")
parser.add_argument('--idx', type=int, default=0, help="export n files starting from idx.")
parser.add_argument('--num', type=int, default=-1, help="number of shapes to export. -1 exports all shapes.")
parser.add_argument('--filter', type=str, default=None, help="filter folder")
parser.add_argument('--ignore', type=bool, default=False, help="ignore too long code")
parser.add_argument('--mode', type=str, default="default", help="mode of generation")
parser.add_argument('--token', type=int, default=2048, help="limit of tokens count")
parser.add_argument('-o', '--outputs', type=str, default=None, help="save filename")
args = parser.parse_args()
src_dir = args.src
print(src_dir)
out_paths = sorted(glob.glob(os.path.join(src_dir, "*.{}".format("json"))))
if args.num != -1:
out_paths = out_paths[args.idx:args.idx+args.num]
from multiprocessing import Process, cpu_count, Manager
#tmp_folder="./_tmp/"
#ensure_dir(tmp_folder)
num_processes = cpu_count()
def main_process(process_id, result_list):
json_data = []
for index in range(process_id, len(out_paths), num_processes):
print(f"{index + 1}/{len(out_paths)}",end='\r')
path = out_paths[index]
name = path.split("/")[-1].split(".")[0]
data = {}
data["id"] = f"{name}"
data["image"] = f"{name}.jpg"
data["conversations"] = []
if args.filter is not None:
filter_dir = args.filter
filter_path = os.path.join(filter_dir, name + ".jpg")
if not os.path.isfile(filter_path):
continue
try:
with open(path, 'r') as fp:
src_data = json.load(fp)
cad_seq = CADSequence.from_dict(src_data)
cad_code = get_cad_code(cad_seq)
conversation_human = {"from": "human"}
if args.mode == "transparent":
conversation_human["value"] = f"<image>\nThis image is a transparent view of a 3D model from a certain angle. Please try to use OpenECAD-style API to render this model."
elif args.mode == "orthographic":
conversation_human["value"] = f"<image>\nThis image contains 4 views of a 3D model from a certain angle and three orthographic views. Please try to use OpenECAD-style API to render this model."
else:
conversation_human["value"] = f"<image>\nThis image is a view of a 3D model from a certain angle. Please try to use OpenECAD-style API to render this model."
data["conversations"].append(conversation_human)
conversation_gpt = {"from": "gpt"}
conversation_gpt["value"] = f"Of course, here are the codes:\n```python\n{cad_code}```"
num_tokens = count_tokens_in_string(cad_code)
if num_tokens > args.token:
continue
data["conversations"].append(conversation_gpt)
json_data.append(data)
except Exception as e:
print(f"load and create failed. Error: {e}")
continue
result_list.append(json_data)
#json_str = json.dumps(json_data, indent=4) # `indent=4` 用于美化输出, 使其更易读
#with open(os.path.join(tmp_folder ,f"data{process_id}.json"), "w") as json_file:
# json_file.write(json_str)
## python export2step.py --src ./ --filter ./
if __name__ == "__main__":
with Manager() as manager:
# 创建一个共享的列表
result_list = manager.list()
processes = []
for i in range(num_processes):
process = Process(target=main_process, args=(i, result_list,))
processes.append(process)
process.start()
# 等待所有进程完成
for process in processes:
process.join()
result_list = list(result_list)
json_res = []
for result in result_list:
json_res += result
print()
print(len(json_res))
with open(f'{args.outputs}', 'w') as f:
json.dump(json_res, f, indent=4)
print('任务完成')

76
Bethany/json2py.py Normal file
View File

@@ -0,0 +1,76 @@
import os
import glob
import json
import argparse
import sys
sys.path.append(".")
from lib.extrude import CADSequence
from lib.file_utils import ensure_dir
from lib.cad2code import get_cad_code
import traceback
parser = argparse.ArgumentParser()
parser.add_argument('--src', type=str, required=True, help="source folder")
parser.add_argument('--idx', type=int, default=0, help="export n files starting from idx.")
parser.add_argument('--num', type=int, default=-1, help="number of shapes to export. -1 exports all shapes.")
parser.add_argument('--filter', type=str, default=None, help="filter folder")
parser.add_argument('-o', '--outputs', type=str, default=None, help="save folder")
args = parser.parse_args()
src_dir = args.src
print(src_dir)
out_paths = sorted(glob.glob(os.path.join(src_dir, "*.{}".format("json"))))
if args.num != -1:
out_paths = out_paths[args.idx:args.idx+args.num]
save_dir = args.src + "_py" if args.outputs is None else args.outputs
ensure_dir(save_dir)
from multiprocessing import Process, cpu_count, Manager
num_processes = cpu_count()
def main_process(process_id):
for index in range(process_id, len(out_paths), num_processes):
print(f"{index + 1}/{len(out_paths)}",end='\r')
path = out_paths[index]
name = path.split("/")[-1].split(".")[0]
if args.filter is not None:
filter_dir = args.filter
filter_path = os.path.join(filter_dir, name + ".jpg")
if not os.path.isfile(filter_path):
continue
try:
with open(path, 'r') as fp:
src_data = json.load(fp)
cad_seq = CADSequence.from_dict(src_data)
cad_code = get_cad_code(cad_seq)
#print(cad_code)
except Exception as e:
print(f"load and create failed. Error: {e}")
traceback.print_exc()
continue
save_path = os.path.join(save_dir, name + ".py")
with open(save_path, 'w', encoding='utf-8') as file:
file.write(cad_code)
## python export2step.py --src ./ --filter ./
if __name__ == "__main__":
with Manager() as manager:
# 创建一个共享的列表
processes = []
for i in range(num_processes):
process = Process(target=main_process, args=(i, ))
processes.append(process)
process.start()
# 等待所有进程完成
for process in processes:
process.join()
print('任务完成')

125
Bethany/json2step.py Normal file
View File

@@ -0,0 +1,125 @@
import os
import glob
import json
import numpy as np
from OCC.Core.BRepCheck import BRepCheck_Analyzer
from lib.DataExchange import write_step_file
import argparse
import sys
sys.path.append(".")
from lib.extrude import CADSequence
from lib.visualize import vec2CADsolid, create_CAD, create_CAD_index
from lib.file_utils import ensure_dir
import traceback
parser = argparse.ArgumentParser()
parser.add_argument('--src', type=str, required=True, help="source folder")
parser.add_argument('--idx', type=int, default=0, help="export n files starting from idx.")
parser.add_argument('--num', type=int, default=-1, help="number of shapes to export. -1 exports all shapes.")
parser.add_argument('--mode', type=str, default="default", help="mode of generation")
parser.add_argument('--filter', action="store_true", help="use opencascade analyzer to filter invalid model")
parser.add_argument('-o', '--outputs', type=str, default=None, help="save folder")
args = parser.parse_args()
src_dir = args.src
print(src_dir)
out_paths = sorted(glob.glob(os.path.join(src_dir, "*.{}".format("json"))))
if args.num != -1:
out_paths = out_paths[args.idx:args.idx+args.num]
save_dir = args.src + "_step" if args.outputs is None else args.outputs
ensure_dir(save_dir)
from multiprocessing import Process, cpu_count
num_processes = cpu_count()
from OCC.Core.TDocStd import TDocStd_Document
from OCC.Core.TCollection import TCollection_ExtendedString
from lib.timeout import timeout_decorator
def main_process(process_id):
if args.mode == "segment":
for index in range(process_id, len(out_paths), num_processes):
path = out_paths[index]
@timeout_decorator
def main__():
with open(path, 'r') as fp:
data = json.load(fp)
cad_seq = CADSequence.from_dict(data)
for i in range(len(cad_seq.seq)):
doc_name = TCollection_ExtendedString("pythonocc-doc")
doc = TDocStd_Document(doc_name)
out_shape = create_CAD_index(doc, cad_seq, index=i)
name = path.split("/")[-1].split(".")[0]
sub_folder = os.path.join(save_dir, name)
ensure_dir(sub_folder)
save_path = os.path.join(sub_folder, name + f".{i:02d}.step")
write_step_file(doc, save_path, application_protocol="AP242DIS")
doc_name = TCollection_ExtendedString("pythonocc-doc")
doc = TDocStd_Document(doc_name)
out_shape = create_CAD(doc, cad_seq)
if args.filter:
analyzer = BRepCheck_Analyzer(out_shape)
if not analyzer.IsValid():
print("detect invalid.")
return
name = path.split("/")[-1].split(".")[0]
save_path = os.path.join(save_dir, name + f".step")
write_step_file(doc, save_path, application_protocol="AP242DIS")
try:
main__()
except Exception as e:
print(f"load and create failed. Error: {e}")
traceback.print_exc()
continue
elif args.mode == "default":
for index in range(process_id, len(out_paths), num_processes):
path = out_paths[index]
@timeout_decorator
def main__():
name = path.split("/")[-1].split(".")[0]
save_path = os.path.join(save_dir, name + f".step")
if os.path.isfile(save_path): return
with open(path, 'r') as fp:
data = json.load(fp)
cad_seq = CADSequence.from_dict(data)
doc_name = TCollection_ExtendedString("pythonocc-doc")
doc = TDocStd_Document(doc_name)
cad = CADSequence(cad_seq)
out_shape = create_CAD(doc, cad_seq)
if args.filter:
analyzer = BRepCheck_Analyzer(out_shape)
if not analyzer.IsValid():
print("detect invalid.")
return
write_step_file(doc, save_path, application_protocol="AP242DIS")
try:
main__()
except Exception as e:
print(f"load and create failed. Error: {e}")
traceback.print_exc()
continue
## python export2step.py --src ./ --outputs ./
if __name__ == "__main__":
processes = []
for i in range(num_processes):
process = Process(target=main_process, args=(i,))
processes.append(process)
process.start()
# 等待所有进程完成
for process in processes:
process.join()
print('任务完成')

View File

@@ -0,0 +1,40 @@
import os
from OCC.Core.STEPControl import STEPControl_Reader, STEPControl_Writer, STEPControl_AsIs
from OCC.Core.STEPCAFControl import STEPCAFControl_Writer
from OCC.Core.Interface import Interface_Static_SetCVal
from OCC.Core.IFSelect import IFSelect_RetDone, IFSelect_ItemsByEntity
from OCC.Core.TDocStd import TDocStd_Document
from OCC.Core.TCollection import TCollection_ExtendedString
try:
import svgwrite
HAVE_SVGWRITE = True
except ImportError:
HAVE_SVGWRITE = False
def write_step_file(a_shape, filename, application_protocol="AP242DIS"):
""" exports a shape to a STEP file
a_shape: the topods_shape to export (a compound, a solid etc.)
filename: the filename
application protocol: "AP203" or "AP214IS" or "AP242DIS"
"""
# a few checks
#if a_shape.IsNull():
# raise AssertionError("Shape %s is null." % a_shape)
if application_protocol not in ["AP203", "AP214IS", "AP242DIS"]:
raise AssertionError("application_protocol must be either AP203 or AP214IS. You passed %s." % application_protocol)
if os.path.isfile(filename):
print("Warning: %s file already exists and will be replaced" % filename)
# creates and initialise the step exporter
step_writer = STEPCAFControl_Writer()
Interface_Static_SetCVal("write.step.schema", application_protocol)
# transfer shapes and write file
step_writer.Transfer(a_shape, STEPControl_AsIs)
status = step_writer.Write(filename)
if not status == IFSelect_RetDone:
raise IOError("Error while writing shape to STEP file.")
if not os.path.isfile(filename):
raise IOError("File %s was not saved to filesystem." % filename)

0
Bethany/lib/__init__.py Normal file
View File

147
Bethany/lib/cad2code.py Normal file
View File

@@ -0,0 +1,147 @@
import numpy as np
from lib.extrude import CADSequence
import lib.curves
from lib.math_utils import *
tol = 1e-10
def get_sketchplane(cad_seq, index):
ext = cad_seq.seq[index]
res = f"SketchPlane{index} = add_sketchplane(\n"
res += "\torigin= {}, normal= {}, x_axis= {})\n".format(
np.array2string(ext.sketch_plane.origin.round(4), separator=', '), np.array2string(ext.sketch_plane.normal.round(4), separator=', '),
np.array2string(ext.sketch_plane.x_axis.round(4), separator=', '))
return res
def get_sketchplane_ref(cad_seq, index):
if index == 0: return get_sketchplane(cad_seq, index) # 第一个没有参考
target_ext = cad_seq.seq[index]
target_plane = target_ext.sketch_plane
target_x_axis = target_plane.x_axis
target_n_axis = target_plane.normal
target_origin = target_plane.origin
for i in range(0, index):
ref_ext = cad_seq.seq[i]
ref_plane = ref_ext.sketch_plane
ref_x_axis = ref_plane.x_axis
ref_y_axis = ref_plane.y_axis
ref_n_axis = ref_plane.normal
ref_origin = ref_plane.origin
if are_parallel(target_n_axis, ref_n_axis):
# sameplane or extent_one/two
reverse = False if np.dot(target_n_axis, ref_n_axis) > 0 else True
vec_origin = target_origin - ref_origin
#if (np.linalg.norm(vec_origin) < tol) or (np.dot(vec_origin, ref_n_axis) < tol and np.abs(np.dot(vec_origin, ref_x_axis)) > tol):
if is_point_on_plane(ref_origin, ref_x_axis, ref_y_axis, target_origin):
# sameplane if OO' is same point or OO' and normal_axis are vertical.
typeop = "sameplane"
origin = map_3d_to_2d(ref_origin, ref_x_axis, ref_y_axis, target_origin)
angle = calculate_rotation_angle(ref_x_axis, target_x_axis, ref_n_axis)
res = f"SketchPlane{index} = add_sketchplane_ref(\n"
res += f"\tExtrude{i}, origin = {np.array2string(origin.round(4), separator=', ')}, type = \"{typeop}\""
if np.abs(angle) > tol:
res += f", angle = {number_to_pi_string(angle)}"
if reverse:
res += ", reverse = True"
res += ")\n"
return res
#elif (are_parallel(vec_origin, ref_n_axis) and np.dot(vec_origin, ref_n_axis) > 0) or (np.dot(vec_origin - ref_ext.extent_one * ref_n_axis, ref_n_axis) < tol):
elif (are_parallel(vec_origin, ref_n_axis) and np.dot(vec_origin, ref_n_axis) > 0) and np.abs(distance_of_point_and_plane(ref_origin, ref_x_axis, ref_y_axis, target_origin) - np.abs(ref_ext.extent_one)) < tol:
typeop = "extent_one"
ref_origin_ = ref_origin + ref_n_axis * ref_ext.extent_one
origin = map_3d_to_2d(ref_origin_, ref_x_axis, ref_y_axis, target_origin)
angle = calculate_rotation_angle(ref_x_axis, target_x_axis, ref_n_axis)
res = f"SketchPlane{index} = add_sketchplane_ref(\n"
res += f"\tExtrude{i}, origin = {np.array2string(origin.round(4), separator=', ')}, type = \"{typeop}\""
if np.abs(angle) > tol:
res += f", angle = {number_to_pi_string(angle)}"
if reverse:
res += ", reverse = True"
res += ")\n"
return res
#elif (are_parallel(vec_origin, ref_n_axis) and np.dot(vec_origin, ref_n_axis) < 0) or (np.dot(vec_origin + ref_ext.extent_two * ref_n_axis, ref_n_axis) < tol):
elif (are_parallel(vec_origin, ref_n_axis) and np.dot(vec_origin, ref_n_axis) < 0) and np.abs(distance_of_point_and_plane(ref_origin, ref_x_axis, ref_y_axis, target_origin) - np.abs(ref_ext.extent_two)) < tol:
typeop = "extent_two"
ref_origin_ = ref_origin - ref_n_axis * ref_ext.extent_two
origin = map_3d_to_2d(ref_origin_, ref_x_axis, ref_y_axis, target_origin)
angle = calculate_rotation_angle(ref_x_axis, target_x_axis, ref_n_axis)
res = f"SketchPlane{index} = add_sketchplane_ref(\n"
res += f"\tExtrude{i}, origin = {np.array2string(origin.round(4), separator=', ')}, type = \"{typeop}\""
if np.abs(angle) > tol:
res += f", angle = {number_to_pi_string(angle)}"
if reverse:
res += ", reverse = True"
res += ")\n"
return res
else:
pass # next situation
elif np.dot(target_n_axis, ref_n_axis) < tol:
typeop = "line"
# line
for j, loop in enumerate(ref_ext.profile.children):
for k, curve in enumerate(loop.children):
if type(curve) == lib.curves.Line:
start_point = map_2d_to_3d(ref_origin, ref_x_axis, ref_y_axis, curve.start_point)
end_point = map_2d_to_3d(ref_origin, ref_x_axis, ref_y_axis, curve.end_point)
ref_x_axis_ = unit_vector(end_point - start_point)
ref_y_axis_ = ref_n_axis
ref_n_axis_ = find_n_from_x_and_y(ref_x_axis_, ref_y_axis_)
ref_origin_ = start_point
reverse = False if np.dot(target_n_axis, ref_n_axis_) > 0 else True
vec_origin = target_origin - ref_origin_
if are_parallel(target_n_axis, ref_n_axis_):
#if (np.linalg.norm(vec_origin) < tol) or (np.dot(vec_origin, ref_n_axis_) < tol and np.abs(np.dot(vec_origin, ref_x_axis_)) > tol):
if is_point_on_plane(ref_origin_, ref_x_axis_, ref_y_axis_, target_origin):
# if SO' is same point or SO' and normal_axis are vertical.
origin = map_3d_to_2d(ref_origin_, ref_x_axis_, ref_y_axis_, target_origin)
angle = calculate_rotation_angle(ref_x_axis_, target_x_axis, ref_n_axis_)
res = f"SketchPlane{index} = add_sketchplane_ref(\n"
res += f"\tExtrude{i}, origin= {np.array2string(origin.round(4), separator=', ')}, type= \"{typeop}\", line= Line{i}_{j}_{k}"
if np.abs(angle) > tol:
res += f", angle= {number_to_pi_string(angle)}"
if reverse:
res += ", reverse= True"
res += ")\n"
return res
return get_sketchplane(cad_seq, index) # 查找失败,使用绝对坐标定义
def get_cad_code(cad_seq):
cad_code = ""
for i, ext in enumerate(cad_seq.seq):
# SketchPlane
cad_code += get_sketchplane_ref(cad_seq, i)
# Loops
cad_code += f"Loops{i} = []\n"
for j, loop in enumerate(ext.profile.children):
# Curves
cad_code += f"Curves{i}_{j} = []\n"
for k, curve in enumerate(loop.children):
if type(curve) == lib.curves.Line:
cad_code += f"Line{i}_{j}_{k} = add_line(start= {np.array2string(curve.start_point.round(4), separator=', ')}, end= {np.array2string(curve.end_point.round(4), separator=', ')})\n"
#cad_code += f"Curves{i}_{j}.append(Line{i}_{j}_{k})\n"
elif type(curve) == lib.curves.Arc:
cad_code += f"Arc{i}_{j}_{k} = add_arc(start= {np.array2string(curve.start_point.round(4), separator=', ')}, "
cad_code += f"end= {np.array2string(curve.end_point.round(4), separator=', ')}, mid= {np.array2string(curve.mid_point.round(4), separator=', ')})\n"
#cad_code += f"Curves{i}_{j}.append(Arc{i}_{j}_{k})\n"
elif type(curve) == lib.curves.Circle:
cad_code += f"Circle{i}_{j}_{k} = add_circle(center= {np.array2string(curve.center.round(4), separator=', ')}, radius= {np.array2string(np.float64(curve.radius).round(4), separator=', ')})\n"
#cad_code += f"Curves{i}_{j}.append(Circle{i}_{j}_{k})\n"
cad_code += f"Loop{i}_{j} = add_loop(Curves{i}_{j})\n"
#cad_code += f"Loops{i}.append(Loop{i}_{j})\n"
# Profile
cad_code += f"Profile{i} = add_profile(Loops{i})\n"
# Sketch
cad_code += f"Sketch{i} = add_sketch(sketch_plane= SketchPlane{i}, profile= Profile{i})\n"
#cad_code += "\tsketch_position= {}, sketch_size= {})\n".format(
# np.array2string(ext.sketch_pos.round(4), separator=', '), np.array2string(ext.sketch_size.round(4), separator=', '))
# Finally: Extrude
cad_code += f"Extrude{i} = add_extrude(sketch= Sketch{i},\n"
cad_code += "\toperation= {}, type= {}, extent_one= {}, extent_two= {})\n".format(
ext.operation, ext.extent_type, np.array2string(np.float64(ext.extent_one).round(4), separator=', '), np.array2string(np.float64(ext.extent_two).round(4), separator=', '))
return cad_code

422
Bethany/lib/curves.py Normal file
View File

@@ -0,0 +1,422 @@
import numpy as np
import matplotlib.lines as lines
import matplotlib.patches as patches
from .math_utils import rads_to_degs, angle_from_vector_to_x
from .macro import *
# FIXME: these two functions can be treated as static method
def construct_curve_from_dict(stat):
if stat['type'] == "Line3D":
return Line.from_dict(stat)
elif stat['type'] == "Circle3D":
return Circle.from_dict(stat)
elif stat['type'] == "Arc3D":
return Arc.from_dict(stat)
else:
raise NotImplementedError("curve type not supported yet: {}".format(stat['type']))
def construct_curve_from_vector(vec, start_point, is_numerical=True):
type = vec[0]
if type == LINE_IDX:
return Line.from_vector(vec, start_point, is_numerical=is_numerical)
elif type == CIRCLE_IDX:
return Circle.from_vector(vec, start_point, is_numerical=is_numerical)
elif type == ARC_IDX:
res = Arc.from_vector(vec, start_point, is_numerical=is_numerical)
if res is None: # for visualization purpose, replace illed arc with line
return Line.from_vector(vec, start_point, is_numerical=is_numerical)
return res
else:
raise NotImplementedError("curve type not supported yet: command idx {}".format(vec[0]))
####################### base #######################
class CurveBase(object):
"""Base class for curve. All types of curves shall inherit from this."""
def __init__(self):
pass
@staticmethod
def from_dict(stat):
"""construct curve from json data"""
raise NotImplementedError
@staticmethod
def from_vector(vec, start_point, is_numerical=True):
"""construct curve from vector representation"""
raise NotImplementedError
@property
def bbox(self):
"""compute bounding box of the curve"""
raise NotImplementedError
def direction(self, from_start=True):
"""return a vector indicating the curve direction"""
raise NotImplementedError
def transform(self, translate, scale):
"""linear transformation"""
raise NotImplementedError
def flip(self, axis):
"""flip the curve about axis"""
raise NotImplementedError
def reverse(self):
"""reverse the curve direction"""
raise NotImplementedError
def numericalize(self, n=256):
"""quantize curve parameters into integers"""
raise NotImplementedError
def to_vector(self):
"""represent curve using a vector. see macro.py"""
raise NotImplementedError
def draw(self, ax, color):
"""draw the curve using matplotlib"""
raise NotImplementedError
def sample_points(self, n=32):
"""uniformly sample points from the curve"""
raise NotImplementedError
####################### curves #######################
class Line(CurveBase):
def __init__(self, start_point, end_point):
super(Line, self).__init__()
self.start_point = start_point
self.end_point = end_point
def __str__(self):
return "Line: start({}), end({})".format(self.start_point.round(4), self.end_point.round(4))
@staticmethod
def from_dict(stat):
assert stat['type'] == "Line3D"
start_point = np.array([stat['start_point']['x'] * 1000,
stat['start_point']['y'] * 1000])
end_point = np.array([stat['end_point']['x'] * 1000,
stat['end_point']['y'] * 1000])
return Line(start_point, end_point)
@staticmethod
def from_vector(vec, start_point, is_numerical=True):
return Line(start_point, vec[1:3])
@property
def bbox(self):
points = np.stack([self.start_point, self.end_point], axis=0)
return np.stack([np.min(points, axis=0), np.max(points, axis=0)], axis=0)
def direction(self, from_start=True):
return self.end_point - self.start_point
def transform(self, translate, scale):
self.start_point = (self.start_point + translate) * scale
self.end_point = (self.end_point + translate) * scale
def flip(self, axis):
if axis == 'x':
self.start_point[1], self.end_point[1] = -self.start_point[1], -self.end_point[1]
elif axis == 'y':
self.start_point[0], self.end_point[0] = -self.start_point[0], -self.end_point[0]
elif axis == 'xy':
self.start_point = self.start_point * -1
self.end_point = self.end_point * -1
else:
raise ValueError("axis = {}".format(axis))
def reverse(self):
self.start_point, self.end_point = self.end_point, self.start_point
def numericalize(self, n=256):
self.start_point = self.start_point.round().clip(min=0, max=n-1).astype(np.int)
self.end_point = self.end_point.round().clip(min=0, max=n-1).astype(np.int)
def to_vector(self):
vec = [LINE_IDX, self.end_point[0], self.end_point[1]]
return np.array(vec + [PAD_VAL] * (1 + N_ARGS - len(vec)))
def draw(self, ax, color):
xdata = [self.start_point[0], self.end_point[0]]
ydata = [self.start_point[1], self.end_point[1]]
l1 = lines.Line2D(xdata, ydata, lw=1, color=color, axes=ax)
ax.add_line(l1)
ax.plot(self.start_point[0], self.start_point[1], 'ok', color=color)
# ax.plot(self.end_point[0], self.end_point[1], 'ok')
def sample_points(self, n=32):
return np.linspace(self.start_point, self.end_point, num=n)
class Arc(CurveBase):
def __init__(self, start_point, end_point, center, radius,
normal=None, start_angle=None, end_angle=None, ref_vec=None, mid_point=None):
super(Arc, self).__init__()
self.start_point = start_point
self.end_point = end_point
self.center = center
self.radius = radius
self.normal = normal
self.start_angle = start_angle
self.end_angle = end_angle
self.ref_vec = ref_vec
if mid_point is None:
self.mid_point = self.get_mid_point()
else:
self.mid_point = mid_point
def __str__(self):
return "Arc: start({}), end({}), mid({})".format(self.start_point.round(4), self.end_point.round(4),
self.mid_point.round(4))
@staticmethod
def from_dict(stat):
assert stat['type'] == "Arc3D"
start_point = np.array([stat['start_point']['x'] * 1000,
stat['start_point']['y'] * 1000])
end_point = np.array([stat['end_point']['x'] * 1000,
stat['end_point']['y'] * 1000])
center = np.array([stat['center_point']['x'] * 1000,
stat['center_point']['y'] * 1000])
radius = stat['radius'] * 1000
normal = np.array([stat['normal']['x'],
stat['normal']['y'],
stat['normal']['z']])
start_angle = stat['start_angle']
end_angle = stat['end_angle']
ref_vec = np.array([stat['reference_vector']['x'],
stat['reference_vector']['y']])
return Arc(start_point, end_point, center, radius, normal, start_angle, end_angle, ref_vec)
@staticmethod
def from_vector(vec, start_point, is_numerical=True):
end_point = vec[1:3]
sweep_angle = vec[3] / 256 * 2 * np.pi if is_numerical else vec[3]
clock_sign = vec[4]
s2e_vec = end_point - start_point
if np.linalg.norm(s2e_vec) == 0:
return None
radius = (np.linalg.norm(s2e_vec) / 2) / np.sin(sweep_angle / 2)
s2e_mid = (start_point + end_point) / 2
vertical = np.cross(s2e_vec, [0, 0, 1])[:2]
vertical = vertical / np.linalg.norm(vertical)
if clock_sign == 0:
vertical = -vertical
center_point = s2e_mid - vertical * (radius * np.cos(sweep_angle / 2))
start_angle = 0
end_angle = sweep_angle
if clock_sign == 0:
ref_vec = end_point - center_point
else:
ref_vec = start_point - center_point
ref_vec = ref_vec / np.linalg.norm(ref_vec)
return Arc(start_point, end_point, center_point, radius,
start_angle=start_angle, end_angle=end_angle, ref_vec=ref_vec)
def get_angles_counterclockwise(self, eps=1e-8):
c2s_vec = (self.start_point - self.center) / (np.linalg.norm(self.start_point - self.center) + eps)
c2m_vec = (self.mid_point - self.center) / (np.linalg.norm(self.mid_point - self.center) + eps)
c2e_vec = (self.end_point - self.center) / (np.linalg.norm(self.end_point - self.center) + eps)
angle_s, angle_m, angle_e = angle_from_vector_to_x(c2s_vec), angle_from_vector_to_x(c2m_vec), \
angle_from_vector_to_x(c2e_vec)
angle_s, angle_e = min(angle_s, angle_e), max(angle_s, angle_e)
if not angle_s < angle_m < angle_e:
angle_s, angle_e = angle_e - np.pi * 2, angle_s
return angle_s, angle_e
@property
def bbox(self):
points = [self.start_point, self.end_point]
angle_s, angle_e = self.get_angles_counterclockwise()
if angle_s < 0 < angle_e:
points.append(np.array([self.center[0] + self.radius, self.center[1]]))
if angle_s < np.pi / 2 < angle_e or angle_s < -np.pi / 2 * 3 < angle_e:
points.append(np.array([self.center[0], self.center[1] + self.radius]))
if angle_s < np.pi < angle_e or angle_s < -np.pi < angle_e:
points.append(np.array([self.center[0] - self.radius, self.center[1]]))
if angle_s < np.pi / 2 * 3 < angle_e or angle_s < -np.pi/2 < angle_e:
points.append(np.array([self.center[0], self.center[1] - self.radius]))
points = np.stack(points, axis=0)
return np.stack([np.min(points, axis=0), np.max(points, axis=0)], axis=0)
def direction(self, from_start=True):
if from_start:
return self.mid_point - self.start_point
else:
return self.end_point - self.mid_point
@property
def clock_sign(self):
"""get a boolean sign indicating whether the arc is on top of s->e """
s2e = self.end_point - self.start_point
s2m = self.mid_point - self.start_point
sign = np.cross(s2m, s2e) >= 0 # counter-clockwise
return sign
def get_mid_point(self):
mid_angle = (self.start_angle + self.end_angle) / 2
rot_mat = np.array([[np.cos(mid_angle), -np.sin(mid_angle)],
[np.sin(mid_angle), np.cos(mid_angle)]])
mid_vec = rot_mat @ self.ref_vec
return self.center + mid_vec * self.radius
def transform(self, translate, scale):
self.start_point = (self.start_point + translate) * scale
self.mid_point = (self.mid_point + translate) * scale
self.end_point = (self.end_point + translate) * scale
self.center = (self.center + translate) * scale
if isinstance(scale * 1.0, float):
self.radius = abs(self.radius * scale)
def flip(self, axis):
if axis == 'x':
self.transform(0, np.array([1, -1]))
new_ref_vec_angle = angle_from_vector_to_x(self.ref_vec) + self.end_angle - self.start_angle
self.ref_vec = np.array([np.cos(new_ref_vec_angle), -np.sin(new_ref_vec_angle)])
elif axis == 'y':
self.transform(0, np.array([-1, 1]))
new_ref_vec_angle = angle_from_vector_to_x(self.ref_vec) + self.end_angle - self.start_angle
self.ref_vec = np.array([-np.cos(new_ref_vec_angle), np.sin(new_ref_vec_angle)])
elif axis == 'xy':
self.transform(0, -1)
self.ref_vec = self.ref_vec * -1
else:
raise ValueError("axis = {}".format(axis))
def reverse(self):
self.start_point, self.end_point = self.end_point, self.start_point
def numericalize(self, n=256):
self.start_point = self.start_point.round().clip(min=0, max=n-1).astype(np.int)
self.mid_point = self.mid_point.round().clip(min=0, max=n-1).astype(np.int)
self.end_point = self.end_point.round().clip(min=0, max=n-1).astype(np.int)
self.center = self.center.round().clip(min=0, max=n-1).astype(np.int)
tmp = np.array([self.start_angle, self.end_angle])
self.start_angle, self.end_angle = (tmp / (2 * np.pi) * n).round().clip(
min=0, max=n-1).astype(np.int)
def to_vector(self):
sweep_angle = max(abs(self.start_angle - self.end_angle), 1)
return np.array([ARC_IDX, self.end_point[0], self.end_point[1], sweep_angle, int(self.clock_sign), PAD_VAL,
*[PAD_VAL] * N_ARGS_EXT])
def draw(self, ax, color):
ref_vec_angle = rads_to_degs(angle_from_vector_to_x(self.ref_vec))
start_angle = rads_to_degs(self.start_angle)
end_angle = rads_to_degs(self.end_angle)
diameter = 2.0 * self.radius
ap = patches.Arc(
(self.center[0], self.center[1]),
diameter,
diameter,
angle=ref_vec_angle,
theta1=start_angle,
theta2=end_angle,
lw=1,
color=color
)
ax.add_patch(ap)
ax.plot(self.start_point[0], self.start_point[1], 'ok', color=color)
# ax.plot(self.center[0], self.center[1], 'ok', color=color)
ax.plot(self.mid_point[0], self.mid_point[1], 'ok', color=color)
# ax.plot(self.end_point[0], self.end_point[1], 'ok')
def sample_points(self, n=32):
c2s_vec = (self.start_point - self.center) / np.linalg.norm(self.start_point - self.center)
c2m_vec = (self.mid_point - self.center) / np.linalg.norm(self.mid_point - self.center)
c2e_vec = (self.end_point - self.center) / np.linalg.norm(self.end_point - self.center)
angle_s, angle_m, angle_e = angle_from_vector_to_x(c2s_vec), angle_from_vector_to_x(c2m_vec), \
angle_from_vector_to_x(c2e_vec)
angle_s, angle_e = min(angle_s, angle_e), max(angle_s, angle_e)
if not angle_s < angle_m < angle_e:
angle_s, angle_e = angle_e - np.pi * 2, angle_s
angles = np.linspace(angle_s, angle_e, num=n)
points = np.stack([np.cos(angles), np.sin(angles)], axis=1) * self.radius + self.center[np.newaxis]
return points
class Circle(CurveBase):
def __init__(self, center, radius, normal=None):
super(Circle, self).__init__()
self.center = center
self.radius = radius
self.normal = normal
def __str__(self):
return "Circle: center({}), radius({})".format(self.center.round(4), round(self.radius, 4))
@staticmethod
def from_dict(stat):
assert stat['type'] == "Circle3D"
center = np.array([stat['center_point']['x'] * 1000,
stat['center_point']['y'] * 1000])
radius = stat['radius'] * 1000
normal = np.array([stat['normal']['x'],
stat['normal']['y'],
stat['normal']['z']])
return Circle(center, radius, normal)
@staticmethod
def from_vector(vec, start_point=None, is_numerical=True):
return Circle(vec[1:3], vec[5])
@property
def bbox(self):
return np.stack([self.center - self.radius, self.center + self.radius], axis=0)
def direction(self, from_start=True):
return self.center - self.start_point
@property
def start_point(self):
return np.array([self.center[0] - self.radius, self.center[1]])
@property
def end_point(self):
return np.array([self.center[0] + self.radius, self.center[1]])
def transform(self, translate, scale):
self.center = (self.center + translate) * scale
self.radius = self.radius * scale
def flip(self, axis):
if axis == 'x':
self.center[1] = -self.center[1]
elif axis == 'y':
self.center[0] = -self.center[0]
elif axis == 'xy':
self.center = self.center * -1
else:
raise ValueError("axis = {}".format(axis))
def reverse(self):
pass
def numericalize(self, n=256):
self.center = self.center.round().clip(min=0, max=n-1).astype(np.int)
self.radius = np.round(self.radius).clip(min=1, max=n-1).astype(np.int)
def to_vector(self):
vec = [CIRCLE_IDX, self.center[0], self.center[1], PAD_VAL, PAD_VAL, self.radius]
return np.array(vec + [PAD_VAL] * (1 + N_ARGS - len(vec)))
def draw(self, ax, color):
ap = patches.Circle((self.center[0], self.center[1]), self.radius,
lw=1, fill=None, color=color)
ax.add_patch(ap)
ax.plot(self.center[0], self.center[1], 'ok')
def sample_points(self, n=32):
angles = np.linspace(0, np.pi * 2, num=n, endpoint=False)
points = np.stack([np.cos(angles), np.sin(angles)], axis=1) * self.radius + self.center[np.newaxis]
return points

324
Bethany/lib/extrude.py Normal file
View File

@@ -0,0 +1,324 @@
import numpy as np
import random
from .sketch import Profile
from .macro import *
from .math_utils import cartesian2polar, polar2cartesian, polar_parameterization, polar_parameterization_inverse
class CoordSystem(object):
"""Local coordinate system for sketch plane."""
def __init__(self, origin, theta, phi, gamma, y_axis=None, is_numerical=False):
self.origin = origin
self._theta = theta # 0~pi
self._phi = phi # -pi~pi
self._gamma = gamma # -pi~pi
self._y_axis = y_axis # (theta, phi)
self.is_numerical = is_numerical
@property
def normal(self):
return polar2cartesian([self._theta, self._phi])
@property
def x_axis(self):
normal_3d, x_axis_3d = polar_parameterization_inverse(self._theta, self._phi, self._gamma)
return x_axis_3d
@property
def y_axis(self):
if self._y_axis is None:
return np.cross(self.normal, self.x_axis)
return polar2cartesian(self._y_axis)
@staticmethod
def from_dict(stat):
origin = np.array([stat["origin"]["x"] * 1000, stat["origin"]["y"] * 1000, stat["origin"]["z"] * 1000])
normal_3d = np.array([stat["z_axis"]["x"], stat["z_axis"]["y"], stat["z_axis"]["z"]])
x_axis_3d = np.array([stat["x_axis"]["x"], stat["x_axis"]["y"], stat["x_axis"]["z"]])
y_axis_3d = np.array([stat["y_axis"]["x"], stat["y_axis"]["y"], stat["y_axis"]["z"]])
theta, phi, gamma = polar_parameterization(normal_3d, x_axis_3d)
return CoordSystem(origin, theta, phi, gamma, y_axis=cartesian2polar(y_axis_3d))
@staticmethod
def from_vector(vec, is_numerical=False, n=256):
origin = vec[:3]
theta, phi, gamma = vec[3:]
system = CoordSystem(origin, theta, phi, gamma)
if is_numerical:
system.denumericalize(n)
return system
def __str__(self):
return "origin: {}, normal: {}, x_axis: {}, y_axis: {}".format(
self.origin.round(4), self.normal.round(4), self.x_axis.round(4), self.y_axis.round(4))
def transform(self, translation, scale):
self.origin = (self.origin + translation) * scale
def numericalize(self, n=256):
"""NOTE: shall only be called after normalization"""
# assert np.max(self.origin) <= 1.0 and np.min(self.origin) >= -1.0 # TODO: origin can be out-of-bound!
self.origin = ((self.origin + 1.0) / 2 * n).round().clip(min=0, max=n-1).astype(np.int)
tmp = np.array([self._theta, self._phi, self._gamma])
self._theta, self._phi, self._gamma = ((tmp / np.pi + 1.0) / 2 * n).round().clip(
min=0, max=n-1).astype(np.int)
self.is_numerical = True
def denumericalize(self, n=256):
self.origin = self.origin / n * 2 - 1.0
tmp = np.array([self._theta, self._phi, self._gamma])
self._theta, self._phi, self._gamma = (tmp / n * 2 - 1.0) * np.pi
self.is_numerical = False
def to_vector(self):
return np.array([*self.origin, self._theta, self._phi, self._gamma])
class Extrude(object):
"""Single extrude operation with corresponding a sketch profile.
NOTE: only support single sketch profile. Extrusion with multiple profiles is decomposed."""
def __init__(self, profile: Profile, sketch_plane: CoordSystem,
operation, extent_type, extent_one, extent_two, sketch_pos, sketch_size):
"""
Args:
profile (Profile): normalized sketch profile
sketch_plane (CoordSystem): coordinate system for sketch plane
operation (int): index of EXTRUDE_OPERATIONS, see macro.py
extent_type (int): index of EXTENT_TYPE, see macro.py
extent_one (float): extrude distance in normal direction (NOTE: it's negative in some data)
extent_two (float): extrude distance in opposite direction
sketch_pos (np.array): the global 3D position of sketch starting point
sketch_size (float): size of the sketch
"""
self.profile = profile # normalized sketch
self.sketch_plane = sketch_plane
self.operation = operation
self.extent_type = extent_type
self.extent_one = extent_one
self.extent_two = extent_two
self.sketch_pos = sketch_pos
self.sketch_size = sketch_size
@staticmethod
def from_dict(all_stat, extrude_id, sketch_dim=256):
"""construct Extrude from json data
Args:
all_stat (dict): all json data
extrude_id (str): entity ID for this extrude
sketch_dim (int, optional): sketch normalization size. Defaults to 256.
Returns:
list: one or more Extrude instances
"""
extrude_entity = all_stat["entities"][extrude_id]
assert extrude_entity["start_extent"]["type"] == "ProfilePlaneStartDefinition"
all_skets = []
n = len(extrude_entity["profiles"])
for i in range(len(extrude_entity["profiles"])):
sket_id, profile_id = extrude_entity["profiles"][i]["sketch"], extrude_entity["profiles"][i]["profile"]
sket_entity = all_stat["entities"][sket_id]
sket_profile = Profile.from_dict(sket_entity["profiles"][profile_id])
sket_plane = CoordSystem.from_dict(sket_entity["transform"])
# normalize profile
#point = sket_profile.start_point
point = np.array([0.0,0.0,0.0])
sket_pos = point[0] * sket_plane.x_axis + point[1] * sket_plane.y_axis + sket_plane.origin
sket_size = sket_profile.bbox_size
sket_profile.normalize(sketch_dim)
all_skets.append((sket_profile, sket_plane, sket_pos, sket_size))
operation = EXTRUDE_OPERATIONS.index(extrude_entity["operation"])
extent_type = EXTENT_TYPE.index(extrude_entity["extent_type"])
extent_one = extrude_entity["extent_one"]["distance"]["value"] * 1000
extent_two = 0.0
if extrude_entity["extent_type"] == "TwoSidesFeatureExtentType":
extent_two = extrude_entity["extent_two"]["distance"]["value"] * 1000
if operation == EXTRUDE_OPERATIONS.index("NewBodyFeatureOperation"):
all_operations = [operation] + [EXTRUDE_OPERATIONS.index("JoinFeatureOperation")] * (n - 1)
else:
all_operations = [operation] * n
return [Extrude(all_skets[i][0], all_skets[i][1], all_operations[i], extent_type, extent_one, extent_two,
all_skets[i][2], all_skets[i][3]) for i in range(n)]
@staticmethod
def from_vector(vec, is_numerical=False, n=256):
"""vector representation: commands [SOL, ..., SOL, ..., EXT]"""
assert vec[-1][0] == EXT_IDX and vec[0][0] == SOL_IDX
profile_vec = np.concatenate([vec[:-1], EOS_VEC[np.newaxis]])
profile = Profile.from_vector(profile_vec, is_numerical=is_numerical)
ext_vec = vec[-1][-N_ARGS_EXT:]
sket_pos = ext_vec[N_ARGS_PLANE:N_ARGS_PLANE + 3]
sket_size = ext_vec[N_ARGS_PLANE + N_ARGS_TRANS - 1]
sket_plane = CoordSystem.from_vector(np.concatenate([sket_pos, ext_vec[:N_ARGS_PLANE]]))
ext_param = ext_vec[-N_ARGS_EXT_PARAM:]
res = Extrude(profile, sket_plane, int(ext_param[2]), int(ext_param[3]), ext_param[0], ext_param[1],
sket_pos, sket_size)
if is_numerical:
res.denumericalize(n)
return res
def __str__(self):
s = "Sketch-Extrude pair:"
s += "\n -" + str(self.sketch_plane)
s += "\n -sketch position: {}, sketch size: {}".format(self.sketch_pos.round(4), self.sketch_size.round(4))
s += "\n -operation:{}, type:{}, extent_one:{}, extent_two:{}".format(
self.operation, self.extent_type, self.extent_one.round(4), self.extent_two.round(4))
s += "\n -" + str(self.profile)
return s
def transform(self, translation, scale):
"""linear transformation"""
# self.profile.transform(np.array([0, 0]), scale)
self.sketch_plane.transform(translation, scale)
self.extent_one *= scale
self.extent_two *= scale
self.sketch_pos = (self.sketch_pos + translation) * scale
self.sketch_size *= scale
def numericalize(self, n=256):
"""quantize the representation.
NOTE: shall only be called after CADSequence.normalize (the shape lies in unit cube, -1~1)"""
assert -2.0 <= self.extent_one <= 2.0 and -2.0 <= self.extent_two <= 2.0
self.profile.numericalize(n)
self.sketch_plane.numericalize(n)
self.extent_one = ((self.extent_one + 1.0) / 2 * n).round().clip(min=0, max=n-1).astype(np.int)
self.extent_two = ((self.extent_two + 1.0) / 2 * n).round().clip(min=0, max=n-1).astype(np.int)
self.operation = int(self.operation)
self.extent_type = int(self.extent_type)
self.sketch_pos = ((self.sketch_pos + 1.0) / 2 * n).round().clip(min=0, max=n-1).astype(np.int)
self.sketch_size = (self.sketch_size / 2 * n).round().clip(min=0, max=n-1).astype(np.int)
def denumericalize(self, n=256):
"""de-quantize the representation."""
self.extent_one = self.extent_one / n * 2 - 1.0
self.extent_two = self.extent_two / n * 2 - 1.0
self.sketch_plane.denumericalize(n)
self.sketch_pos = self.sketch_pos / n * 2 - 1.0
self.sketch_size = self.sketch_size / n * 2
self.operation = self.operation
self.extent_type = self.extent_type
def flip_sketch(self, axis):
self.profile.flip(axis)
self.profile.normalize()
def to_vector(self, max_n_loops=6, max_len_loop=15, pad=True):
"""vector representation: commands [SOL, ..., SOL, ..., EXT]"""
profile_vec = self.profile.to_vector(max_n_loops, max_len_loop, pad=False)
if profile_vec is None:
return None
sket_plane_orientation = self.sketch_plane.to_vector()[3:]
ext_param = list(sket_plane_orientation) + list(self.sketch_pos) + [self.sketch_size] + \
[self.extent_one, self.extent_two, self.operation, self.extent_type]
ext_vec = np.array([EXT_IDX, *[PAD_VAL] * N_ARGS_SKETCH, *ext_param])
vec = np.concatenate([profile_vec[:-1], ext_vec[np.newaxis], profile_vec[-1:]], axis=0) # NOTE: last one is EOS
if pad:
pad_len = max_n_loops * max_len_loop - vec.shape[0]
vec = np.concatenate([vec, EOS_VEC[np.newaxis].repeat(pad_len, axis=0)], axis=0)
return vec
class CADSequence(object):
"""A CAD modeling sequence, a series of extrude operations."""
def __init__(self, extrude_seq, bbox=None):
self.seq = extrude_seq
self.bbox = bbox
@staticmethod
def from_dict(all_stat):
"""construct CADSequence from json data"""
seq = []
for item in all_stat["sequence"]:
if item["type"] == "ExtrudeFeature":
extrude_ops = Extrude.from_dict(all_stat, item["entity"])
seq.extend(extrude_ops)
bbox_info = all_stat["properties"]["bounding_box"]
max_point = np.array([bbox_info["max_point"]["x"] * 1000, bbox_info["max_point"]["y"] * 1000, bbox_info["max_point"]["z"] * 1000])
min_point = np.array([bbox_info["min_point"]["x"] * 1000, bbox_info["min_point"]["y"] * 1000, bbox_info["min_point"]["z"] * 1000])
bbox = np.stack([max_point, min_point], axis=0)
return CADSequence(seq, bbox)
@staticmethod
def from_vector(vec, is_numerical=False, n=256):
commands = vec[:, 0]
ext_indices = [-1] + np.where(commands == EXT_IDX)[0].tolist()
ext_seq = []
for i in range(len(ext_indices) - 1):
start, end = ext_indices[i], ext_indices[i + 1]
ext_seq.append(Extrude.from_vector(vec[start+1:end+1], is_numerical, n))
cad_seq = CADSequence(ext_seq)
return cad_seq
def __str__(self):
return "" + "\n".join(["({})".format(i) + str(ext) for i, ext in enumerate(self.seq)])
def to_vector(self, max_n_ext=10, max_n_loops=6, max_len_loop=15, max_total_len=60, pad=False):
if len(self.seq) > max_n_ext:
return None
vec_seq = []
for item in self.seq:
vec = item.to_vector(max_n_loops, max_len_loop, pad=False)
if vec is None:
return None
vec = vec[:-1] # last one is EOS, removed
vec_seq.append(vec)
vec_seq = np.concatenate(vec_seq, axis=0)
vec_seq = np.concatenate([vec_seq, EOS_VEC[np.newaxis]], axis=0)
# add EOS padding
if pad and vec_seq.shape[0] < max_total_len:
pad_len = max_total_len - vec_seq.shape[0]
vec_seq = np.concatenate([vec_seq, EOS_VEC[np.newaxis].repeat(pad_len, axis=0)], axis=0)
return vec_seq
def transform(self, translation, scale):
"""linear transformation"""
for item in self.seq:
item.transform(translation, scale)
def normalize(self, size=1.0):
"""(1)normalize the shape into unit cube (-1~1). """
scale = size * NORM_FACTOR / np.max(np.abs(self.bbox))
self.transform(0.0, scale)
def numericalize(self, n=256):
for item in self.seq:
item.numericalize(n)
def flip_sketch(self, axis):
for item in self.seq:
item.flip_sketch(axis)
def random_transform(self):
for item in self.seq:
# random transform sketch
scale = random.uniform(0.8, 1.2)
item.profile.transform(-np.array([128, 128]), scale)
translate = np.array([random.randint(-5, 5), random.randint(-5, 5)], dtype=np.int) + 128
item.profile.transform(translate, 1)
# random transform and scale extrusion
t = 0.05
translate = np.array([random.uniform(-t, t), random.uniform(-t, t), random.uniform(-t, t)])
scale = random.uniform(0.8, 1.2)
# item.sketch_plane.transform(translate, scale)
item.sketch_pos = (item.sketch_pos + translate) * scale
item.extent_one *= random.uniform(0.8, 1.2)
item.extent_two *= random.uniform(0.8, 1.2)
def random_flip_sketch(self):
for item in self.seq:
flip_idx = random.randint(0, 3)
if flip_idx > 0:
item.flip_sketch(['x', 'y', 'xy'][flip_idx - 1])

52
Bethany/lib/file_utils.py Normal file
View File

@@ -0,0 +1,52 @@
import os
import json
import logging
import shutil
import csv
def save_args(args, save_dir):
param_path = os.path.join(save_dir, 'params.json')
with open(param_path, 'w') as fp:
json.dump(args.__dict__, fp, indent=4, sort_keys=True)
def ensure_dir(path):
"""
create path by first checking its existence,
:param paths: path
:return:
"""
if not os.path.exists(path):
os.makedirs(path)
def ensure_dirs(paths):
"""
create paths by first checking their existence
:param paths: list of path
:return:
"""
if isinstance(paths, list) and not isinstance(paths, str):
for path in paths:
ensure_dir(path)
else:
ensure_dir(paths)
def remkdir(path):
"""
if dir exists, remove it and create a new one
:param path:
:return:
"""
if os.path.exists(path):
shutil.rmtree(path)
os.makedirs(path)
def cycle(iterable):
while True:
for x in iterable:
yield x

40
Bethany/lib/macro.py Normal file
View File

@@ -0,0 +1,40 @@
import numpy as np
ALL_COMMANDS = ['Line', 'Arc', 'Circle', 'EOS', 'SOL', 'Ext']
LINE_IDX = ALL_COMMANDS.index('Line')
ARC_IDX = ALL_COMMANDS.index('Arc')
CIRCLE_IDX = ALL_COMMANDS.index('Circle')
EOS_IDX = ALL_COMMANDS.index('EOS')
SOL_IDX = ALL_COMMANDS.index('SOL')
EXT_IDX = ALL_COMMANDS.index('Ext')
EXTRUDE_OPERATIONS = ["NewBodyFeatureOperation", "JoinFeatureOperation",
"CutFeatureOperation", "IntersectFeatureOperation"]
EXTENT_TYPE = ["OneSideFeatureExtentType", "SymmetricFeatureExtentType",
"TwoSidesFeatureExtentType"]
PAD_VAL = -1
N_ARGS_SKETCH = 5 # sketch parameters: x, y, alpha, f, r
N_ARGS_PLANE = 3 # sketch plane orientation: theta, phi, gamma
N_ARGS_TRANS = 4 # sketch plane origin + sketch bbox size: p_x, p_y, p_z, s
N_ARGS_EXT_PARAM = 4 # extrusion parameters: e1, e2, b, u
N_ARGS_EXT = N_ARGS_PLANE + N_ARGS_TRANS + N_ARGS_EXT_PARAM
N_ARGS = N_ARGS_SKETCH + N_ARGS_EXT
SOL_VEC = np.array([SOL_IDX, *([PAD_VAL] * N_ARGS)])
EOS_VEC = np.array([EOS_IDX, *([PAD_VAL] * N_ARGS)])
CMD_ARGS_MASK = np.array([[1, 1, 0, 0, 0, *[0]*N_ARGS_EXT], # line
[1, 1, 1, 1, 0, *[0]*N_ARGS_EXT], # arc
[1, 1, 0, 0, 1, *[0]*N_ARGS_EXT], # circle
[0, 0, 0, 0, 0, *[0]*N_ARGS_EXT], # EOS
[0, 0, 0, 0, 0, *[0]*N_ARGS_EXT], # SOL
[*[0]*N_ARGS_SKETCH, *[1]*N_ARGS_EXT]]) # Extrude
NORM_FACTOR = 0.75 # scale factor for normalization to prevent overflow during augmentation
MAX_N_EXT = 10 # maximum number of extrusion
MAX_N_LOOPS = 6 # maximum number of loops per sketch
MAX_N_CURVES = 15 # maximum number of curves per loop
MAX_TOTAL_LEN = 60 # maximum cad sequence length
ARGS_DIM = 256

367
Bethany/lib/math_utils.py Normal file
View File

@@ -0,0 +1,367 @@
import math
import numpy as np
def rads_to_degs(rads):
"""Convert an angle from radians to degrees"""
return 180 * rads / math.pi
def distance_of_point_and_plane(origin, x_axis, y_axis, point):
# 确保输入是 numpy 数组
origin = np.array(origin)
x_axis = np.array(x_axis)
y_axis = np.array(y_axis)
point = np.array(point)
normal_vector = np.cross(x_axis, y_axis)
distance = np.dot(point - origin, normal_vector)
return np.abs(distance)
def is_point_on_plane(origin, x_axis, y_axis, point, tolerance=1e-10):
"""
判断一个3D点是否在给定的平面上
参数:
origin - 平面的原点坐标,形状为 (3,)
x_axis - 平面X轴的方向向量形状为 (3,)
y_axis - 平面Y轴的方向向量形状为 (3,)
point - 要检查的3D点形状为 (3,)
tolerance - 容忍度,默认值为 1e-10
返回:
如果点在平面上返回 True否则返回 False
"""
# 确保输入是 numpy 数组
origin = np.array(origin)
x_axis = np.array(x_axis)
y_axis = np.array(y_axis)
point = np.array(point)
# 计算法向量
normal_vector = np.cross(x_axis, y_axis)
# 计算点到平面的距离
distance = np.dot(point - origin, normal_vector)
# 判断距离是否在容忍度范围内
return np.abs(distance) < tolerance
def number_to_pi_string(number):
"""
将数字转换为带有 np.pi 的字符串表示形式
参数:
number - 输入数字,可以是 np.pi 的倍数
返回:
带有 np.pi 的字符串表示形式
"""
# 定义一个容忍度来比较浮点数
tolerance = 1e-10
# 预定义一些常见的 π 的倍数及其对应的字符串表示
pi_factors = {
np.pi: 'np.pi',
np.pi / 2: 'np.pi/2',
np.pi / 3: 'np.pi/3',
np.pi / 4: 'np.pi/4',
np.pi / 6: 'np.pi/6',
2 * np.pi: '2*np.pi',
3 * np.pi / 2: '3*np.pi/2',
3 * np.pi / 4: '3*np.pi/4',
5 * np.pi / 6: '5*np.pi/6',
5 * np.pi / 3: '5*np.pi/3',
7 * np.pi / 6: '7*np.pi/6',
4 * np.pi / 3: '4*np.pi/3',
}
# 检查输入数字是否接近这些常见的 π 倍数
for key, value in pi_factors.items():
if np.abs(np.abs(number) - key) < tolerance:
return value if number > 0 else '-' + value
# 如果数字不在预定义的 π 倍数中,返回原数字
return str(number.round(6))
def are_parallel(v1, v2, tol=1e-10):
# 计算叉积
cross_product = np.cross(v1, v2)
# 判断叉积是否接近于零向量
return np.all(np.abs(cross_product) < tol)
def find_circle_center_and_radius(start_point, end_point, mid_point):
# Calculate midpoints of the chords
mid_point_start_end = (start_point + end_point) / 2
mid_point_start_mid = (start_point + mid_point) / 2
# Calculate direction vectors of the chords
direction_start_end = end_point - start_point
direction_start_mid = mid_point - start_point
# Calculate perpendicular direction vectors
perp_start_end = np.array([-direction_start_end[1], direction_start_end[0]])
perp_start_mid = np.array([-direction_start_mid[1], direction_start_mid[0]])
# Solve for the intersection of the perpendicular bisectors
A = np.array([perp_start_end, -perp_start_mid]).T
b = mid_point_start_mid - mid_point_start_end
# Solve the linear system
t, s = np.linalg.solve(A, b)
# Calculate the center
center = mid_point_start_end + t * perp_start_end
# Calculate the radius
radius = np.linalg.norm(center - start_point)
return center, radius
def rotate_vector(vector, axis, angle):
"""
将一个3D向量绕指定轴逆时针旋转给定角度
参数:
vector - 要旋转的3D向量形状为 (3,)
axis - 旋转轴,形状为 (3,)
angle - 旋转角度(弧度)
返回:
旋转后的3D向量形状为 (3,)
"""
# 确保输入是 numpy 数组
vector = np.array(vector)
axis = np.array(axis)
# 计算单位轴向量
axis = axis / np.linalg.norm(axis)
# 计算旋转矩阵的各个分量
cos_theta = np.cos(angle)
sin_theta = np.sin(angle)
cross_product = np.cross(axis, vector)
dot_product = np.dot(axis, vector)
# 计算旋转后的向量
rotated_vector = (vector * cos_theta +
cross_product * sin_theta +
axis * dot_product * (1 - cos_theta))
return rotated_vector
def calculate_rotation_angle(v1, v2, axis):
"""
计算从向量 v1 到向量 v2 绕给定轴的逆时针旋转角度
参数:
v1 - 初始向量,形状为 (3,)
v2 - 旋转后的向量,形状为 (3,)
axis - 旋转轴,形状为 (3,)
返回:
旋转角度(弧度),范围 (-pi, pi]
"""
# 确保输入是 numpy 数组
v1 = np.array(v1)
v2 = np.array(v2)
axis = np.array(axis)
# 计算单位轴向量
axis = axis / np.linalg.norm(axis)
# 计算点积
dot_product = np.dot(v1, v2)
# 计算叉积
cross_product = np.cross(v1, v2)
# 计算叉积在旋转轴上的投影长度
projection_length = np.dot(cross_product, axis)
# 计算向量的范数
norm_v1 = np.linalg.norm(v1)
norm_v2 = np.linalg.norm(v2)
# 计算角度的余弦值和正弦值
cos_theta = dot_product / (norm_v1 * norm_v2)
sin_theta = projection_length / (norm_v1 * norm_v2)
# 使用 arctan2 计算角度
angle = np.arctan2(sin_theta, cos_theta)
return angle
def map_2d_to_3d(origin, x_axis, y_axis, point):
u, v = point
return origin + u * x_axis + v * y_axis
def map_3d_to_2d(origin, x_axis, y_axis, point_3d):
"""
将三维空间中的点转换为二维平面上的点
参数:
origin - 原点坐标 (Ox, Oy, Oz),形状为 (3,)
x_axis - X轴向量 (Xx, Xy, Xz),形状为 (3,)
y_axis - Y轴向量 (Yx, Yy, Yz),形状为 (3,)
point_3d - 三维空间中的点 (Px, Py, Pz),形状为 (3,)
返回:
二维平面上的点 (u, v),形状为 (2,)
"""
# 确保输入是 numpy 数组
origin = np.array(origin)
x_axis = np.array(x_axis)
y_axis = np.array(y_axis)
point_3d = np.array(point_3d)
# 构建矩阵 A 和向量 b
A = np.vstack([x_axis, y_axis]).T
b = point_3d - origin
# 求解线性方程组 Ax = b
uv = np.linalg.lstsq(A, b, rcond=None)[0]
return uv
def unit_vector(vector):
"""
计算给定向量的单位向量
参数:
vector - 输入向量,形状为 (n,)
返回:
单位向量,形状为 (n,)
"""
# 计算向量的范数
norm = np.linalg.norm(vector)
if norm == 0:
raise ValueError("零向量没有单位向量")
# 计算单位向量
unit_vector = vector / norm
return unit_vector
def find_n_from_x_and_y(x, y):
"""
Given vectors x and y, find a vector n such that y = n × x.
Assumes that n is orthogonal to x.
Parameters:
x (numpy array): The vector x.
y (numpy array): The vector y.
Returns:
numpy array: The vector n.
"""
# Step 1: Compute the cross product of x and y to get n'
n_prime = np.cross(x, y)
# Step 2: Normalize n' to get the unit vector
n_prime_unit = n_prime / np.linalg.norm(n_prime)
# Step 3: Determine the correct sign of n_prime_unit
# To ensure y = n × x, we should check if the direction is correct
if np.allclose(np.cross(n_prime_unit, x), y):
n = n_prime_unit
else:
n = -n_prime_unit
return n
def angle_from_vector_to_x(vec):
"""computer the angle (0~2pi) between a unit vector and positive x axis"""
angle = 0.0
# 2 | 1
# -------
# 3 | 4
if vec[0] >= 0:
if vec[1] >= 0:
# Qadrant 1
angle = math.asin(vec[1])
else:
# Qadrant 4
angle = 2.0 * math.pi - math.asin(-vec[1])
else:
if vec[1] >= 0:
# Qadrant 2
angle = math.pi - math.asin(vec[1])
else:
# Qadrant 3
angle = math.pi + math.asin(-vec[1])
return angle
def cartesian2polar(vec, with_radius=False):
"""convert a vector in cartesian coordinates to polar(spherical) coordinates"""
vec = vec.round(6)
norm = np.linalg.norm(vec)
theta = np.arccos(vec[2] / norm) # (0, pi)
phi = np.arctan(vec[1] / (vec[0] + 1e-15)) # (-pi, pi) # FIXME: -0.0 cannot be identified here
if not with_radius:
return np.array([theta, phi])
else:
return np.array([theta, phi, norm])
def polar2cartesian(vec):
"""convert a vector in polar(spherical) coordinates to cartesian coordinates"""
r = 1 if len(vec) == 2 else vec[2]
theta, phi = vec[0], vec[1]
x = r * np.sin(theta) * np.cos(phi)
y = r * np.sin(theta) * np.sin(phi)
z = r * np.cos(theta)
return np.array([x, y, z])
def rotate_by_x(vec, theta):
mat = np.array([[1, 0, 0],
[0, np.cos(theta), -np.sin(theta)],
[0, np.sin(theta), np.cos(theta)]])
return np.dot(mat, vec)
def rotate_by_y(vec, theta):
mat = np.array([[np.cos(theta), 0, np.sin(theta)],
[0, 1, 0],
[-np.sin(theta), 0, np.cos(theta)]])
return np.dot(mat, vec)
def rotate_by_z(vec, phi):
mat = np.array([[np.cos(phi), -np.sin(phi), 0],
[np.sin(phi), np.cos(phi), 0],
[0, 0, 1]])
return np.dot(mat, vec)
def polar_parameterization(normal_3d, x_axis_3d):
"""represent a coordinate system by its rotation from the standard 3D coordinate system
Args:
normal_3d (np.array): unit vector for normal direction (z-axis)
x_axis_3d (np.array): unit vector for x-axis
Returns:
theta, phi, gamma: axis-angle rotation
"""
normal_polar = cartesian2polar(normal_3d)
theta = normal_polar[0]
phi = normal_polar[1]
ref_x = rotate_by_z(rotate_by_y(np.array([1, 0, 0]), theta), phi)
gamma = np.arccos(np.dot(x_axis_3d, ref_x).round(6))
if np.dot(np.cross(ref_x, x_axis_3d), normal_3d) < 0:
gamma = -gamma
return theta, phi, gamma
def polar_parameterization_inverse(theta, phi, gamma):
"""build a coordinate system by the given rotation from the standard 3D coordinate system"""
normal_3d = polar2cartesian([theta, phi])
ref_x = rotate_by_z(rotate_by_y(np.array([1, 0, 0]), theta), phi)
ref_y = np.cross(normal_3d, ref_x)
x_axis_3d = ref_x * np.cos(gamma) + ref_y * np.sin(gamma)
return normal_3d, x_axis_3d

263
Bethany/lib/sketch.py Normal file
View File

@@ -0,0 +1,263 @@
import numpy as np
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
from .curves import *
from .macro import *
########################## base ###########################
class SketchBase(object):
"""Base class for sketch (a collection of curves). """
def __init__(self, children, reorder=True):
self.children = children
if reorder:
self.reorder()
@staticmethod
def from_dict(stat):
"""construct sketch from json data
Args:
stat (dict): dict from json data
"""
raise NotImplementedError
@staticmethod
def from_vector(vec, start_point, is_numerical=True):
"""construct sketch from vector representation
Args:
vec (np.array): (seq_len, n_args)
start_point (np.array): (2, ). If none, implicitly defined as the last end point.
"""
raise NotImplementedError
def reorder(self):
"""rearrange the curves to follow counter-clockwise direction"""
raise NotImplementedError
@property
def start_point(self):
return self.children[0].start_point
@property
def end_point(self):
return self.children[-1].end_point
@property
def bbox(self):
"""compute bounding box (min/max points) of the sketch"""
all_points = np.concatenate([child.bbox for child in self.children], axis=0)
return np.stack([np.min(all_points, axis=0), np.max(all_points, axis=0)], axis=0)
@property
def bbox_size(self):
"""compute bounding box size (max of height and width)"""
bbox_min, bbox_max = self.bbox[0], self.bbox[1]
bbox_size = np.max(np.abs(np.concatenate([bbox_max - self.start_point, bbox_min - self.start_point])))
return bbox_size
@property
def global_trans(self):
"""start point + sketch size (bbox_size)"""
return np.concatenate([self.start_point, np.array([self.bbox_size])])
def transform(self, translate, scale):
"""linear transformation"""
for child in self.children:
child.transform(translate, scale)
def flip(self, axis):
for child in self.children:
child.flip(axis)
self.reorder()
def numericalize(self, n=256):
"""quantize curve parameters into integers"""
for child in self.children:
child.numericalize(n)
def normalize(self, size=256):
"""normalize within the given size, with start_point in the middle center"""
cur_size = self.bbox_size
scale = (size / 2 * NORM_FACTOR - 1) / cur_size # prevent potential overflow if data augmentation applied
#self.transform(-self.start_point, scale)
#self.transform(np.array((size / 2, size / 2)), 1)
def denormalize(self, bbox_size, size=256):
"""inverse procedure of normalize method"""
scale = bbox_size / (size / 2 * NORM_FACTOR - 1)
#self.transform(-np.array((size / 2, size / 2)), scale)
def to_vector(self):
"""convert to vector representation"""
raise NotImplementedError
def draw(self, ax):
"""draw sketch on matplotlib ax"""
raise NotImplementedError
def to_image(self):
"""convert to image"""
fig, ax = plt.subplots()
self.draw(ax)
ax.axis('equal')
fig.canvas.draw()
X = np.array(fig.canvas.renderer.buffer_rgba())[:, :, :3]
plt.close(fig)
return X
def sample_points(self, n=32):
"""uniformly sample points from the sketch"""
raise NotImplementedError
####################### loop & profile #######################
class Loop(SketchBase):
"""Sketch loop, a sequence of connected curves."""
@staticmethod
def from_dict(stat):
all_curves = [construct_curve_from_dict(item) for item in stat['profile_curves']]
this_loop = Loop(all_curves)
this_loop.is_outer = stat['is_outer']
return this_loop
def __str__(self):
return "Loop:" + "\n -" + "\n -".join([str(curve) for curve in self.children])
@staticmethod
def from_vector(vec, start_point=None, is_numerical=True):
all_curves = []
if start_point is None:
# FIXME: explicit for loop can be avoided here
for i in range(vec.shape[0]):
if vec[i][0] == EOS_IDX:
start_point = vec[i - 1][1:3]
break
for i in range(vec.shape[0]):
type = vec[i][0]
if type == SOL_IDX:
continue
elif type == EOS_IDX:
break
else:
curve = construct_curve_from_vector(vec[i], start_point, is_numerical=is_numerical)
start_point = vec[i][1:3] # current curve's end_point serves as next curve's start_point
all_curves.append(curve)
return Loop(all_curves)
def reorder(self):
"""reorder by starting left most and counter-clockwise"""
if len(self.children) <= 1:
return
start_curve_idx = -1
sx, sy = 10000, 10000
# correct start-end point order
if np.allclose(self.children[0].start_point, self.children[1].start_point) or \
np.allclose(self.children[0].start_point, self.children[1].end_point):
self.children[0].reverse()
# correct start-end point order and find left-most point
for i, curve in enumerate(self.children):
if i < len(self.children) - 1 and np.allclose(curve.end_point, self.children[i + 1].end_point):
self.children[i + 1].reverse()
if round(curve.start_point[0], 6) < round(sx, 6) or \
(round(curve.start_point[0], 6) == round(sx, 6) and round(curve.start_point[1], 6) < round(sy, 6)):
start_curve_idx = i
sx, sy = curve.start_point
self.children = self.children[start_curve_idx:] + self.children[:start_curve_idx]
# ensure mostly counter-clock wise
if isinstance(self.children[0], Circle) or isinstance(self.children[-1], Circle): # FIXME: hard-coded
return
start_vec = self.children[0].direction()
end_vec = self.children[-1].direction(from_start=False)
if np.cross(end_vec, start_vec) <= 0:
for curve in self.children:
curve.reverse()
self.children.reverse()
def to_vector(self, max_len=None, add_sol=True, add_eos=True):
loop_vec = np.stack([curve.to_vector() for curve in self.children], axis=0)
if add_sol:
loop_vec = np.concatenate([SOL_VEC[np.newaxis], loop_vec], axis=0)
if add_eos:
loop_vec = np.concatenate([loop_vec, EOS_VEC[np.newaxis]], axis=0)
if max_len is None:
return loop_vec
if loop_vec.shape[0] > max_len:
return None
elif loop_vec.shape[0] < max_len:
pad_vec = np.tile(EOS_VEC, max_len - loop_vec.shape[0]).reshape((-1, len(EOS_VEC)))
loop_vec = np.concatenate([loop_vec, pad_vec], axis=0) # (max_len, 1 + N_ARGS)
return loop_vec
def draw(self, ax):
colors = ['red', 'blue', 'green', 'brown', 'pink', 'yellow', 'purple', 'black'] * 10
for i, curve in enumerate(self.children):
curve.draw(ax, colors[i])
def sample_points(self, n=32):
points = np.stack([curve.sample_points(n) for curve in self.children], axis=0) # (n_curves, n, 2)
return points
class Profile(SketchBase):
"""Sketch profilea closed region formed by one or more loops.
The outer-most loop is placed at first."""
@staticmethod
def from_dict(stat):
all_loops = [Loop.from_dict(item) for item in stat['loops']]
return Profile(all_loops)
def __str__(self):
return "Profile:" + "\n -".join([str(loop) for loop in self.children])
@staticmethod
def from_vector(vec, start_point=None, is_numerical=True):
all_loops = []
command = vec[:, 0]
end_idx = command.tolist().index(EOS_IDX)
indices = np.where(command[:end_idx] == SOL_IDX)[0].tolist() + [end_idx]
for i in range(len(indices) - 1):
loop_vec = vec[indices[i]:indices[i + 1]]
loop_vec = np.concatenate([loop_vec, EOS_VEC[np.newaxis]], axis=0)
if loop_vec[0][0] == SOL_IDX and loop_vec[1][0] not in [SOL_IDX, EOS_IDX]:
all_loops.append(Loop.from_vector(loop_vec, is_numerical=is_numerical))
return Profile(all_loops)
def reorder(self):
if len(self.children) <= 1:
return
all_loops_bbox_min = np.stack([loop.bbox[0] for loop in self.children], axis=0).round(6)
ind = np.lexsort(all_loops_bbox_min.transpose()[[1, 0]])
self.children = [self.children[i] for i in ind]
def draw(self, ax):
for i, loop in enumerate(self.children):
loop.draw(ax)
ax.text(loop.start_point[0], loop.start_point[1], str(i))
def to_vector(self, max_n_loops=None, max_len_loop=None, pad=True):
loop_vecs = [loop.to_vector(None, add_eos=False) for loop in self.children]
if max_n_loops is not None and len(loop_vecs) > max_n_loops:
return None
for vec in loop_vecs:
if max_len_loop is not None and vec.shape[0] > max_len_loop:
return None
profile_vec = np.concatenate(loop_vecs, axis=0)
profile_vec = np.concatenate([profile_vec, EOS_VEC[np.newaxis]], axis=0)
if pad:
pad_len = max_n_loops * max_len_loop - profile_vec.shape[0]
profile_vec = np.concatenate([profile_vec, EOS_VEC[np.newaxis].repeat(pad_len, axis=0)], axis=0)
return profile_vec
def sample_points(self, n=32):
points = np.concatenate([loop.sample_points(n) for loop in self.children], axis=0)
return points

31
Bethany/lib/timeout.py Normal file
View File

@@ -0,0 +1,31 @@
import signal
# 定义超时异常
class TimeoutException(Exception):
pass
# 处理超时信号
def handler(signum, frame):
raise TimeoutException()
# 设置超时时间(秒)
timeout = 30
# 使用装饰器设置超时
def timeout_decorator(func):
def wrapper(*args, **kwargs):
# 设置信号处理器
signal.signal(signal.SIGALRM, handler)
# 启动闹钟
signal.alarm(timeout)
try:
result = func(*args, **kwargs)
except TimeoutException:
print("Function timed out!")
result = None
finally:
# 关闭闹钟
signal.alarm(0)
return result
return wrapper

197
Bethany/lib/visualize.py Normal file
View File

@@ -0,0 +1,197 @@
from OCC.Core.gp import gp_Pnt, gp_Dir, gp_Circ, gp_Pln, gp_Vec, gp_Ax3, gp_Ax2, gp_Lin
from OCC.Core.BRepBuilderAPI import (BRepBuilderAPI_MakeEdge, BRepBuilderAPI_MakeFace, BRepBuilderAPI_MakeWire)
from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakePrism
from OCC.Core.BRepAlgoAPI import BRepAlgoAPI_Cut, BRepAlgoAPI_Fuse, BRepAlgoAPI_Common
from OCC.Core.GC import GC_MakeArcOfCircle
from OCC.Extend.DataExchange import write_stl_file
from OCC.Core.Bnd import Bnd_Box
from OCC.Core.BRepBndLib import brepbndlib_Add
from copy import copy
from .extrude import *
from .sketch import Loop, Profile
from .curves import *
import os
import trimesh
from trimesh.sample import sample_surface
import random
from OCC.Core.Quantity import Quantity_Color, Quantity_TOC_RGB
from OCC.Core.TDocStd import TDocStd_Document
from OCC.Core.XCAFDoc import XCAFDoc_DocumentTool, XCAFDoc_ColorGen
from OCC.Core.AIS import AIS_Shape
# 创建不同颜色
red = Quantity_Color(1.0, 0.1, 0.1, Quantity_TOC_RGB)
green = Quantity_Color(0.1, 1.0, 0.1, Quantity_TOC_RGB)
blue = Quantity_Color(0.1, 0.1, 1.0, Quantity_TOC_RGB)
white = Quantity_Color(1.0, 1.0, 1.0, Quantity_TOC_RGB)
gray = Quantity_Color(0.1, 0.1, 0.1, Quantity_TOC_RGB)
import random
def generate_random_color():
r = random.uniform(0, 1)
g = random.uniform(0, 1)
b = random.uniform(0, 1)
return Quantity_Color(r, g, b, Quantity_TOC_RGB)
import numpy as np
def color_distance(color1, color2):
rgb1 = np.array([color1.Red(), color1.Green(), color1.Blue()])
rgb2 = np.array([color2.Red(), color2.Green(), color2.Blue()])
return np.linalg.norm(rgb1 - rgb2)
def vec2CADsolid(vec, is_numerical=True, n=256):
cad = CADSequence.from_vector(vec, is_numerical=is_numerical, n=256)
cad = create_CAD(cad)
return cad
from copy import deepcopy
def create_CAD_index(doc: TDocStd_Document, cad_seq: CADSequence, index = 0, color = red):
"""create a 3D CAD model from CADSequence. Only support extrude with boolean operation."""
if len(cad_seq.seq) != 1:
_ = create_CAD(doc, cad_seq)
extrude_op = cad_seq.seq[index]
profile = copy(extrude_op.profile) # use copy to prevent changing extrude_op internally
profile.denormalize(extrude_op.sketch_size)
sketch_plane = copy(extrude_op.sketch_plane)
#sketch_plane.origin = extrude_op.sketch_pos
face = create_profile_face(profile, sketch_plane)
normal = gp_Dir(*extrude_op.sketch_plane.normal)
ext_vec = gp_Vec(normal).Multiplied(extrude_op.extent_one)
body = BRepPrimAPI_MakePrism(face, ext_vec).Shape()
shape_tool = XCAFDoc_DocumentTool.ShapeTool(doc.Main())
color_tool = XCAFDoc_DocumentTool.ColorTool(doc.Main())
label = shape_tool.AddShape(body)
color_tool.SetColor(label, red, XCAFDoc_ColorGen)
if extrude_op.extent_type == EXTENT_TYPE.index("SymmetricFeatureExtentType"):
body_sym = BRepPrimAPI_MakePrism(face, ext_vec.Reversed()).Shape()
body = BRepAlgoAPI_Fuse(body, body_sym).Shape()
label_sym = shape_tool.AddShape(body_sym)
color_tool.SetColor(label_sym, red, XCAFDoc_ColorGen)
if extrude_op.extent_type == EXTENT_TYPE.index("TwoSidesFeatureExtentType"):
ext_vec = gp_Vec(normal.Reversed()).Multiplied(extrude_op.extent_two)
body_two = BRepPrimAPI_MakePrism(face, ext_vec).Shape()
body = BRepAlgoAPI_Fuse(body, body_two).Shape()
label_two = shape_tool.AddShape(body_two)
color_tool.SetColor(label_two, red, XCAFDoc_ColorGen)
return body
def create_CAD(doc: TDocStd_Document, cad_seq: CADSequence):
"""create a 3D CAD model from CADSequence. Only support extrude with boolean operation."""
body = create_by_extrude(doc, cad_seq.seq[0])
for extrude_op in cad_seq.seq[1:]:
new_body = create_by_extrude(doc, extrude_op)
if extrude_op.operation == EXTRUDE_OPERATIONS.index("NewBodyFeatureOperation") or \
extrude_op.operation == EXTRUDE_OPERATIONS.index("JoinFeatureOperation"):
body = BRepAlgoAPI_Fuse(body, new_body).Shape()
elif extrude_op.operation == EXTRUDE_OPERATIONS.index("CutFeatureOperation"):
body = BRepAlgoAPI_Cut(body, new_body).Shape()
elif extrude_op.operation == EXTRUDE_OPERATIONS.index("IntersectFeatureOperation"):
body = BRepAlgoAPI_Common(body, new_body).Shape()
shape_tool = XCAFDoc_DocumentTool.ShapeTool(doc.Main())
_ = shape_tool.AddShape(body)
return body
def create_by_extrude(doc: TDocStd_Document, extrude_op: Extrude):
"""create a solid body from Extrude instance."""
profile = copy(extrude_op.profile) # use copy to prevent changing extrude_op internally
profile.denormalize(extrude_op.sketch_size)
sketch_plane = copy(extrude_op.sketch_plane)
#sketch_plane.origin = extrude_op.sketch_pos
face = create_profile_face(profile, sketch_plane)
normal = gp_Dir(*extrude_op.sketch_plane.normal)
ext_vec = gp_Vec(normal).Multiplied(extrude_op.extent_one)
body = BRepPrimAPI_MakePrism(face, ext_vec).Shape()
if extrude_op.extent_type == EXTENT_TYPE.index("SymmetricFeatureExtentType"):
body_sym = BRepPrimAPI_MakePrism(face, ext_vec.Reversed()).Shape()
body = BRepAlgoAPI_Fuse(body, body_sym).Shape()
if extrude_op.extent_type == EXTENT_TYPE.index("TwoSidesFeatureExtentType"):
ext_vec = gp_Vec(normal.Reversed()).Multiplied(extrude_op.extent_two)
body_two = BRepPrimAPI_MakePrism(face, ext_vec).Shape()
body = BRepAlgoAPI_Fuse(body, body_two).Shape()
return body
def create_profile_face(profile: Profile, sketch_plane: CoordSystem):
"""create a face from a sketch profile and the sketch plane"""
origin = gp_Pnt(*sketch_plane.origin)
normal = gp_Dir(*sketch_plane.normal)
x_axis = gp_Dir(*sketch_plane.x_axis)
gp_face = gp_Pln(gp_Ax3(origin, normal, x_axis))
all_loops = [create_loop_3d(loop, sketch_plane) for loop in profile.children]
topo_face = BRepBuilderAPI_MakeFace(gp_face, all_loops[0])
for loop in all_loops[1:]:
topo_face.Add(loop.Reversed())
return topo_face.Face()
def create_loop_3d(loop: Loop, sketch_plane: CoordSystem):
"""create a 3D sketch loop"""
topo_wire = BRepBuilderAPI_MakeWire()
for curve in loop.children:
topo_edge = create_edge_3d(curve, sketch_plane)
if topo_edge == -1: # omitted
continue
topo_wire.Add(topo_edge)
return topo_wire.Wire()
def create_edge_3d(curve: CurveBase, sketch_plane: CoordSystem):
"""create a 3D edge"""
if isinstance(curve, Line):
if np.allclose(curve.start_point, curve.end_point):
return -1
start_point = point_local2global(curve.start_point, sketch_plane)
end_point = point_local2global(curve.end_point, sketch_plane)
topo_edge = BRepBuilderAPI_MakeEdge(start_point, end_point)
elif isinstance(curve, Circle):
center = point_local2global(curve.center, sketch_plane)
axis = gp_Dir(*sketch_plane.normal)
gp_circle = gp_Circ(gp_Ax2(center, axis), abs(float(curve.radius)))
topo_edge = BRepBuilderAPI_MakeEdge(gp_circle)
elif isinstance(curve, Arc):
# print(curve.start_point, curve.mid_point, curve.end_point)
start_point = point_local2global(curve.start_point, sketch_plane)
mid_point = point_local2global(curve.mid_point, sketch_plane)
end_point = point_local2global(curve.end_point, sketch_plane)
arc = GC_MakeArcOfCircle(start_point, mid_point, end_point).Value()
topo_edge = BRepBuilderAPI_MakeEdge(arc)
else:
raise NotImplementedError(type(curve))
return topo_edge.Edge()
def point_local2global(point, sketch_plane: CoordSystem, to_gp_Pnt=True):
"""convert point in sketch plane local coordinates to global coordinates"""
g_point = point[0] * sketch_plane.x_axis + point[1] * sketch_plane.y_axis + sketch_plane.origin
if to_gp_Pnt:
return gp_Pnt(*g_point)
return g_point
def CADsolid2pc(shape, n_points, name=None):
"""convert opencascade solid to point clouds"""
bbox = Bnd_Box()
brepbndlib_Add(shape, bbox)
if bbox.IsVoid():
raise ValueError("box check failed")
if name is None:
name = random.randint(100000, 999999)
write_stl_file(shape, "tmp_out_{}.stl".format(name))
out_mesh = trimesh.load("tmp_out_{}.stl".format(name))
os.system("rm tmp_out_{}.stl".format(name))
out_pc, _ = sample_surface(out_mesh, n_points)
return out_pc

63
Bethany/png2jpg.py Normal file
View File

@@ -0,0 +1,63 @@
import argparse
import sys
import os
import glob
sys.path.append(".")
from PIL import Image
parser = argparse.ArgumentParser()
parser.add_argument('--src', type=str, required=True, help="source folder")
from PIL import Image
import os
parser = argparse.ArgumentParser()
parser.add_argument('--src', type=str, required=True, help="source folder")
args = parser.parse_args()
src_dir = args.src
print(src_dir)
out_paths = sorted(glob.glob(os.path.join(src_dir, "*.{}".format("png"))))
def convert_png_to_jpg_and_delete(png_path, jpg_path):
# 打开PNG文件
png_image = Image.open(png_path)
# 转换为RGB模式
rgb_image = png_image.convert('RGB')
# 保存为JPG文件
rgb_image.save(jpg_path, "JPEG")
# 删除原始的PNG文件
os.remove(png_path)
print(f"{png_path} has been deleted.")
from multiprocessing import Process, cpu_count
num_processes = cpu_count()
def main_process(process_id):
for index in range(process_id, len(out_paths), num_processes):
print(f"{index + 1}/{len(out_paths)}",end='\r')
path = out_paths[index]
name = path.split("/")[-1].split(".")[0]
save_path = os.path.join(src_dir, name + ".jpg")
# 调用函数进行转换并删除原始文件
convert_png_to_jpg_and_delete(path, save_path)
if __name__ == "__main__":
processes = []
for i in range(num_processes):
process = Process(target=main_process, args=(i,))
processes.append(process)
process.start()
# 等待所有进程完成
for process in processes:
process.join()
print('任务完成')

214
Bethany/py2step.py Normal file
View File

@@ -0,0 +1,214 @@
import os
import glob
import numpy as np
import argparse
import sys
sys.path.append(".")
from lib.DataExchange import write_step_file
from lib.visualize import create_CAD
from lib.curves import Line, Arc, Circle
from lib.sketch import Loop, Profile
from lib.math_utils import *
from lib.extrude import CoordSystem, Extrude, CADSequence
# Curves
def add_line(start, end):
start = np.array(start)
end = np.array(end)
return Line(start, end)
def add_arc(start, end, mid):
# get radius and center point
start = np.array(start)
end = np.array(end)
mid = np.array(mid)
center, radius = find_circle_center_and_radius(start, end, mid)
def get_angles_counterclockwise(eps=1e-8):
c2s_vec = (start - center) / (np.linalg.norm(start - center) + eps)
c2m_vec = (mid - center) / (np.linalg.norm(mid - center) + eps)
c2e_vec = (end - center) / (np.linalg.norm(end - center) + eps)
angle_s, angle_m, angle_e = angle_from_vector_to_x(c2s_vec), angle_from_vector_to_x(c2m_vec), \
angle_from_vector_to_x(c2e_vec)
angle_s, angle_e = min(angle_s, angle_e), max(angle_s, angle_e)
if not angle_s < angle_m < angle_e:
angle_s, angle_e = angle_e - np.pi * 2, angle_s
return angle_s, angle_e
angle_s, angle_e = get_angles_counterclockwise()
return Arc(start, end, center, radius, start_angle=angle_s, end_angle=angle_e, mid_point=mid)
def add_circle(center, radius):
center = np.array(center)
return Circle(center, radius)
# Loops
def add_loop(curves):
res = Loop(curves)
res.reorder()
def autofix(loop):
if len(loop.children) <= 1:
return
if isinstance(loop.children[0], Circle):
return
for i in range(0, len(loop.children) - 1):
if not np.allclose(loop.children[i].end_point, loop.children[i+1].start_point):
loop.children[i+1].start_point = loop.children[i].end_point
print("warning: fixing loop")
if not np.allclose(loop.children[len(loop.children) - 1].end_point, loop.children[0].start_point):
loop.children[len(loop.children) - 1].start_point = loop.children[0].end_point
print("warning: fixing loop")
autofix(res)
return res
# Sketch-Profile
def add_profile(loops):
return Profile(loops)
def add_sketchplane(origin, normal, x_axis):#, y_axis):
#print(origin, normal, x_axis)
origin = np.array(origin)
normal = np.array(normal)
x_axis = np.array(x_axis)
y_axis = find_n_from_x_and_y(normal, x_axis)
# get theta and phi
theta, phi, gamma = polar_parameterization(normal, x_axis)
#print(normal_axis, x_axis)
#print(theta, phi, gamma)
return CoordSystem(origin, theta, phi, gamma, y_axis=cartesian2polar(y_axis))
def add_sketchplane_ref(extrude: Extrude, origin, type: str, line: Line = None, reverse = False, angle=0):
origin = np.array(origin)
types_dict = ["sameplane", "extent_one", "extent_two", "line"]
"""
sameplane: 参考Extrude的SketchPlaneangle是以normal为轴向下看逆时针角度原点是在SketchPlane内的2D相对坐标。reverse只在最后反转normal其他参考并不反转。
line默认normal为y轴line start to end 为x轴它们的叉积为方向向量normal'原点是在该默认平面的2D相对坐标。angle是以normal'为轴向下看逆时针角度。reverse只在最后反转normal',其他参考并不反转。
"""
if type not in types_dict:
raise ValueError
ref_plane = extrude.sketch_plane
ref_x_axis = unit_vector(ref_plane.x_axis)
ref_y_axis = unit_vector(ref_plane.y_axis)
ref_n_axis = unit_vector(ref_plane.normal)
ref_origin = ref_plane.origin
if type == "sameplane":
real_origin = map_2d_to_3d(ref_origin, ref_x_axis, ref_y_axis, origin)
elif type == "extent_one":
ref_origin_ = ref_origin + extrude.extent_one * ref_n_axis
real_origin = map_2d_to_3d(ref_origin_, ref_x_axis, ref_y_axis, origin)
elif type == "extent_two":
ref_origin_ = ref_origin - extrude.extent_two * ref_n_axis
real_origin = map_2d_to_3d(ref_origin_, ref_x_axis, ref_y_axis, origin)
if type in types_dict[:3]:
real_x_axis = rotate_vector(ref_x_axis, ref_n_axis, angle)
return add_sketchplane(real_origin, ref_n_axis if not reverse else -ref_n_axis, real_x_axis)
if type == "line":
if line is None:
raise TypeError
start_point = map_2d_to_3d(ref_origin, ref_x_axis, ref_y_axis, line.start_point)
end_point = map_2d_to_3d(ref_origin, ref_x_axis, ref_y_axis, line.end_point)
default_x_axis = unit_vector(end_point - start_point)
real_origin = map_2d_to_3d(start_point, default_x_axis, ref_n_axis, origin) # ref_n_axis is y axis of default plane
default_normal = find_n_from_x_and_y(default_x_axis, ref_n_axis)
real_x_axis = rotate_vector(default_x_axis, default_normal, angle)
return add_sketchplane(real_origin, default_normal if not reverse else -default_normal, real_x_axis)
raise ValueError
class Sketch(object):
def __init__(self, sketch_plane, profile, sketch_position, sketch_size):
self.sketch_plane = sketch_plane
self.profile = profile
self.sketch_position = sketch_position
self.sketch_size = sketch_size
def add_sketch(sketch_plane, profile, sketch_position=[0.0,0.0,0.0], sketch_size=0):
return Sketch(sketch_plane, profile, np.array(sketch_position), sketch_size)
cad_seq = []
def add_extrude(sketch: Sketch, operation, type, extent_one, extent_two):
res = Extrude(
sketch.profile,
sketch.sketch_plane,
np.intc(operation), np.intc(type), np.double(extent_one), np.double(extent_two),
np.double(sketch.sketch_position),
np.double(sketch.sketch_size)
)
cad_seq.append(res)
return res
from OCC.Core.TDocStd import TDocStd_Document
from OCC.Core.TCollection import TCollection_ExtendedString
def _process(path, path_o):
global cad_seq
cad_seq.clear()
with open(path, 'r') as file:
codes = file.read()
# 执行读取到的代码
codes = codes.split("\n")
i = 0
last_curves_list, last_loops_list = None, None
while i < len(codes):
code = codes[i]
last_curve_name, last_loop_name = None, None
if codes[i].startswith('Curves'):
last_curves_list = codes[i].split('=', 1)[0].split()[0]
elif codes[i].startswith('Loops'):
last_loops_list = codes[i].split('=', 1)[0].split()[0]
elif codes[i].startswith('Arc') or codes[i].startswith('Line') or codes[i].startswith('Circle'):
last_curve_name = codes[i].split('=', 1)[0].split()[0]
elif codes[i].startswith('Loop'):
last_loop_name = codes[i].split('=', 1)[0].split()[0]
for j in range(i + 1, len(codes)):
if codes[j].startswith('\t') or codes[j].startswith(' '):
code += '\n' + codes[j]
i += 1
else:
break
exec(code)
if last_curve_name is not None:
exec(f"{last_curves_list}.append({last_curve_name})")
elif last_loop_name is not None:
exec(f"{last_loops_list}.append({last_loop_name})")
i += 1
doc_name = TCollection_ExtendedString("pythonocc-doc")
doc = TDocStd_Document(doc_name)
cad = CADSequence(cad_seq)
#print(cad)
out_shape = create_CAD(doc, cad)
write_step_file(doc, path_o)
error_list = []
from lib.file_utils import ensure_dir
parser = argparse.ArgumentParser()
parser.add_argument('--src', type=str, required=True, help="source folder")
parser.add_argument('-o', '--outputs', type=str, default=None, help="save folder")
args = parser.parse_args()
src_dir = args.src
print(src_dir)
out_paths = sorted(glob.glob(os.path.join(src_dir, "*.{}".format("py"))))
save_dir = args.src + "_step" if args.outputs is None else args.outputs
ensure_dir(save_dir)
import traceback
for path in out_paths:
name = path.split("/")[-1].split(".")[0]
try:
save_path = os.path.join(save_dir, name + ".step")
_process(path, save_path)
except Exception as e:
print("load and create failed.")
traceback.print_exc()
print(name)
error_list.append(name)
for error in error_list:
print(error)

6
Bethany/requirements.txt Normal file
View File

@@ -0,0 +1,6 @@
matplotlib==3.9.1
numpy==1.26.4
Pillow==8.3.2
trimesh==3.23.5
count-tokens==0.7.0
opencv-python==4.10.0.84

248
Bethany/step2img.py Normal file
View File

@@ -0,0 +1,248 @@
import argparse
import sys
import os
import glob
import json
sys.path.append(".")
from lib.file_utils import ensure_dir
import random
from OCC.Core.STEPControl import STEPControl_Reader
from OCC.Core.IFSelect import IFSelect_RetDone
from OCC.Display.SimpleGui import init_display
from OCC.Core.Bnd import Bnd_Box
from OCC.Core.BRepBndLib import brepbndlib_Add
from OCC.Extend.DataExchange import read_step_file_with_names_colors
from OCC.Core.Quantity import Quantity_Color, Quantity_TOC_RGB
from OCC.Core.AIS import AIS_Shape
from OCC.Core.Aspect import Aspect_TOL_SOLID, Aspect_TOL_DASH, Aspect_TOL_DOT
from OCC.Core.Prs3d import Prs3d_Drawer, Prs3d_LineAspect, Prs3d_Root
from PIL import Image
import traceback
os.environ["PYTHONOCC_OFFSCREEN_RENDERER"] = "1"
parser = argparse.ArgumentParser()
parser.add_argument('--src', type=str, required=True, help="source folder")
parser.add_argument('--idx', type=int, default=0, help="export n files starting from idx.")
parser.add_argument('--num', type=int, default=-1, help="number of shapes to export. -1 exports all shapes.")
parser.add_argument('-o', '--outputs', type=str, default=None, help="save folder")
parser.add_argument('--mode', type=str, default="default", help="mode of generation")
args = parser.parse_args()
src_dir = args.src
print(src_dir)
out_paths = sorted(glob.glob(os.path.join(src_dir, "*.{}".format("step"))))
if args.num != -1:
out_paths = out_paths[args.idx:args.idx+args.num]
save_dir = args.src + "_images" if args.outputs is None else args.outputs
ensure_dir(save_dir)
from lib.timeout import timeout_decorator
from multiprocessing import Process, cpu_count
num_processes = 4 #cpu_count()
def main_process(process_id):
HasTarget = False
for index in range(process_id, len(out_paths), num_processes):
HasTarget = True
break
if not HasTarget:
return
# 初始化显示窗口
display, start_display, add_menu, add_function_to_menu = init_display()
display.View.SetBgGradientColors(Quantity_Color(1.0, 1.0, 1.0, Quantity_TOC_RGB), Quantity_Color(1.0, 1.0, 1.0, Quantity_TOC_RGB), 2, True)
# 加载3D模型
def load_step_file(filename):
step_reader = STEPControl_Reader()
status = step_reader.ReadFile(filename)
if status == IFSelect_RetDone:
step_reader.TransferRoots()
shape = step_reader.OneShape()
shapes_labels_colors = read_step_file_with_names_colors(filename)
return shapes_labels_colors, shape
else:
raise IOError("Error: cannot read file.")
# 计算模型包围盒
def compute_bounding_box(shape):
box = Bnd_Box()
brepbndlib_Add(shape, box)
return box
# 渲染并保存图片
def render_and_save(display, shapes_labels_colors, view_name):
#display.DisplayShape(shape, update=True)
for shpt_lbl_color in shapes_labels_colors:
label, c = shapes_labels_colors[shpt_lbl_color]
if args.mode == "segment":
color = Quantity_Color(c.Red() , c.Green() , c.Blue() , Quantity_TOC_RGB)
ais_shape = AIS_Shape(shpt_lbl_color)
ais_shape.SetColor(color)
if color == Quantity_Color(1.0 , 0.1 , 0.1 , Quantity_TOC_RGB):
display.Context.SetTransparency(ais_shape, 0.0, False)
else:
display.Context.SetTransparency(ais_shape, 1.0, False)
display.Context.Display(ais_shape, False)
elif args.mode == "transparent":
ais_shape = AIS_Shape(shpt_lbl_color)
color = Quantity_Color(c.Red() * 0.25, c.Green() * 0.25, c.Blue() * 0.25, Quantity_TOC_RGB)
ais_shape.SetColor(color)
display.Context.SetTransparency(ais_shape, 0.25, False)
display.Context.Display(ais_shape, False)
ais_shape = AIS_Shape(shpt_lbl_color)
ais_shape.SetWidth(2.0)
display.Context.SetTransparency(ais_shape, 1.0, False)
display.Context.Display(ais_shape, False)
else:
ais_shape = AIS_Shape(shpt_lbl_color)
color = Quantity_Color(c.Red() * 0.25, c.Green() * 0.25, c.Blue() * 0.25, Quantity_TOC_RGB)
ais_shape.SetColor(color)
display.Context.SetTransparency(ais_shape, 0.0, False)
display.Context.Display(ais_shape, False)
ais_shape = AIS_Shape(shpt_lbl_color)
ais_shape.SetWidth(2.0)
display.Context.SetTransparency(ais_shape, 1.0, False)
display.Context.Display(ais_shape, False)
#display.DisplayColoredShape(
# shpt_lbl_color,
# color=Quantity_Color(c.Red() * 0.25, c.Green() * 0.25, c.Blue() * 0.25, Quantity_TOC_RGB),
#)
display.FitAll()
display.View.Dump(view_name)
# 设置视角并保存图片
def save_views_from_angles(shapes_labels_colors, proj_directions, output_dir, name):
if not os.path.exists(output_dir):
os.makedirs(output_dir)
image_paths = []
for proj_direction in proj_directions:
x, y, z = proj_direction
display.View_Front()
#display.View_Iso()
display.View.SetProj(x, y, z)
display.View.FitAll()
if args.mode == "orthographic":
if x * y * z > 0: d = 'o'
elif x > 0: d = 'x'
elif y > 0: d = 'y'
else: d = 'z'
view_name = os.path.join(output_dir, f'{name}_{d}.jpg')
else:
view_name = os.path.join(output_dir, f'{name}.jpg')
render_and_save(display, shapes_labels_colors, view_name)
image_paths.append(view_name)
return image_paths
def merge_images(image_paths, output_path):
# 打开所有图片
images = [Image.open(image_path) for image_path in image_paths]
# 获取单张图片的宽度和高度(假设所有图片大小相同)
width, height = images[0].size
# 创建一个新图像,大小为 2x2 布局的总大小
merged_image = Image.new('RGB', (2 * width, 2 * height))
# 将每张图片粘贴到新图像的正确位置
positions = [(0, 0), (width, 0), (0, height), (width, height)]
for pos, img in zip(positions, images):
merged_image.paste(img, pos)
# 保存拼接后的图像
merged_image.save(output_path)
# 删除原图
for image_path in image_paths:
os.remove(image_path)
for index in range(process_id, len(out_paths), num_processes):
step_file = out_paths[index]
@timeout_decorator
def main__():
name = step_file.split("/")[-1].split(".")[0]
view_name = os.path.join(save_dir, f'{name}.jpg')
if os.path.isfile(view_name): return
# 加载模型
shapes_labels_colors, shape = load_step_file(step_file)
# 计算包围盒
bounding_box = compute_bounding_box(shape)
# 定义方向矢量
if args.mode == "default":
proj_directions = [
(random.random() * 0.25 + 0.75, random.random() * 0.25 + 0.75, random.random() * 0.25 + 0.75)
]
elif args.mode == "orthographic":
proj_directions = [
(1, 1, 1),
(1, 0, 0),
(0, 1, 0),
(0, 0, 1)
]
else:
proj_directions = [
(1, 1, 1)
]
# 保存多角度视图
image_paths = save_views_from_angles(shapes_labels_colors, proj_directions, save_dir, name=name)
if args.mode == "orthographic":
output_path = os.path.join(save_dir, f'{name}.jpg')
merge_images(image_paths, output_path)
# 结束显示
display.EraseAll()
#display.FitAll()
#start_display()
sub_folder = os.path.join(src_dir, name)
sub_output_dir = os.path.join(save_dir, name)
if os.path.exists(sub_folder) and args.mode == "segment":
ensure_dir(sub_output_dir)
sub_steps = sorted(glob.glob(os.path.join(sub_folder, "*.{}".format("step"))))
for sub_step in sub_steps:
sub_shapes_labels_colors, sub_shape = load_step_file(sub_step)
bounding_box = compute_bounding_box(sub_shape)
sub_proj_directions = [(1, 1, 1)]
sub_name = sub_step.split("/")[-1].split(".")[0] + "." + sub_step.split("/")[-1].split(".")[1]
image_paths = save_views_from_angles(sub_shapes_labels_colors, sub_proj_directions, sub_output_dir, name=sub_name)
display.EraseAll()
try:
main__()
display.EraseAll()
except Exception as e:
print("load and create failed.")
traceback.print_exc()
display.EraseAll()
continue
if __name__ == "__main__":
processes = []
for i in range(num_processes):
process = Process(target=main_process, args=(i,))
processes.append(process)
process.start()
# 等待所有进程完成
for process in processes:
process.join()
print('任务完成')