Skip to content

plot

工程数据绘图相关 CLI 命令(本地操作,无需 Dimine 运行)。

cmd_project_plot(fmt, input_path, origin, normal, x_axis, y_axis, thicknesses, title, scale, output_path)

工程数据绘图(本地操作)。

Source code in dimine_python_sdk\cli\commands\plot.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
def cmd_project_plot(fmt: str, input_path: str, origin: str, normal: str,
                      x_axis: str, y_axis: str, thicknesses: str,
                      title: str, scale: float, output_path: str) -> None:
    """工程数据绘图(本地操作)。"""
    err = require_local_sdk()
    if err:
        output_error(err, fmt)

    input_file = resolve_path(input_path)
    output_file = resolve_path(output_path)
    scale = safe_float(scale)

    try:
        origin_vals = parse_point3d(origin)
        normal_vals = parse_point3d(normal)
        x_axis_vals = parse_point3d(x_axis)
        y_axis_vals = parse_point3d(y_axis)
        thicknesses_vals = _parse_thicknesses(thicknesses)
    except ValueError as e:
        output_error(str(e), fmt)

    from dimine_python_sdk.lib.visualization.plot import LayoutParam, SetupParams, project_data_plotting

    try:
        layout_param = LayoutParam(
            origin=origin_vals,
            normal=normal_vals,
            x_axis=x_axis_vals,
            y_axis=y_axis_vals,
            thicknesses=thicknesses_vals,
        )
        setup_param = SetupParams(title=title, scale=scale)
        result = project_data_plotting(input_file, layout_param, setup_param, output_file)
        output_result({
            "success": True,
            "input": input_file,
            "output": output_file,
            "result": str(result),
            "message": f"绘图完成: {output_file}",
        }, fmt)
    except Exception as e:
        output_error(f"绘图失败: {e}", fmt)

register_commands(subparsers, format_parent)

向 subparsers 注册绘图相关子命令。

Source code in dimine_python_sdk\cli\commands\plot.py
71
72
73
74
75
76
77
78
79
80
81
82
def register_commands(subparsers, format_parent) -> None:
    """向 subparsers 注册绘图相关子命令。"""
    p = subparsers.add_parser("project-plot", parents=[format_parent], help="工程数据绘图")
    p.add_argument("--input", required=True, help="输入文件路径")
    p.add_argument("--origin", required=True, help="绘图原点 x,y,z")
    p.add_argument("--normal", required=True, help="投影法线方向 x,y,z")
    p.add_argument("--x-axis", required=True, help="X 轴方向 x,y,z")
    p.add_argument("--y-axis", required=True, help="Y 轴方向 x,y,z")
    p.add_argument("--thicknesses", required=True, help="逗号分隔的各层厚度,如 '0,10,20'")
    p.add_argument("--title", default="工程平面图", help="图纸标题")
    p.add_argument("--scale", type=float, default=1000, help="比例尺")
    p.add_argument("--output", required=True, dest="output_path", help="输出文件路径")