Skip to content

line

DmDbLine

线类型

Source code in dimine_python_sdk\lib\types\line.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class DmDbLine:
    """线类型"""
    def __init__(self):
        """构造函数,初始化数据库线对象"""
        self._obj = Dm.dmDbLine()

    def get_graph_data(self) -> list[DmDPoint]:
        """
        获取该线的图形数据(起点和终点)
        :return: 包含起点和终点的列表,每个元素为DmDPoint实例

        example:
        ```python
        line = DmDbLine()
        graph_data = line.get_graph_data()
        print("线的起点:", graph_data[0])
        print("线的终点:", graph_data[1])
        ```
        """
        cpp_list = self._obj.GetGraphData()
        return [DmDPoint._from_obj(item) for item in cpp_list]

    @classmethod
    def _from_obj(cls, obj):
        """
        :param obj: 原生dmDbLine对象
        :return: DmDbLine实例
        """
        instance = cls.__new__(cls)
        instance._obj = obj
        return instance

__init__()

构造函数,初始化数据库线对象

Source code in dimine_python_sdk\lib\types\line.py
7
8
9
def __init__(self):
    """构造函数,初始化数据库线对象"""
    self._obj = Dm.dmDbLine()

get_graph_data()

获取该线的图形数据(起点和终点) :return: 包含起点和终点的列表,每个元素为DmDPoint实例

example:

line = DmDbLine()
graph_data = line.get_graph_data()
print("线的起点:", graph_data[0])
print("线的终点:", graph_data[1])
Source code in dimine_python_sdk\lib\types\line.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
def get_graph_data(self) -> list[DmDPoint]:
    """
    获取该线的图形数据(起点和终点)
    :return: 包含起点和终点的列表,每个元素为DmDPoint实例

    example:
    ```python
    line = DmDbLine()
    graph_data = line.get_graph_data()
    print("线的起点:", graph_data[0])
    print("线的终点:", graph_data[1])
    ```
    """
    cpp_list = self._obj.GetGraphData()
    return [DmDPoint._from_obj(item) for item in cpp_list]

DmDbPolyline

三维多段线类型

Source code in dimine_python_sdk\lib\types\line.py
 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
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
class DmDbPolyline:
    """三维多段线类型"""

    def __init__(self):
        """
        构造函数
        :return: None
        """
        self._obj = Dm.dmDbPolyline()

    def get_graph_data(self) -> list[DmDPoint]:
        """
        获取多段线的所有顶点坐标
        :return: 顶点列表,每个元素为DmDPoint实例

        example:
        ```python
        polyline = DmDbPolyline()
        graph_data = polyline.get_graph_data()
        for point in graph_data:
            print(point)
        ```
        """
        cpp_list = self._obj.GetGraphData()
        return [DmDPoint._from_obj(item) for item in cpp_list]

    def __repr__(self) -> str:
        """
        字符串表示
        :return: 多段线的标准字符串表示
        """
        return self._obj.__repr__()

    def set_color(self, red: int, green: int, blue: int) -> None:
        """
        设置多段线的颜色
        :param red: 红色分量(0-255)
        :param green: 绿色分量(0-255)
        :param blue: 蓝色分量(0-255)
        :return: None

        example:
        ```python
        polyline = DmDbPolyline()
        polyline.set_color(255, 0, 0)  # 设置为红色
        ```
        """
        self._obj.SetColor(red, green, blue)

    def is_closed(self, tolerance: float = 1e-10) -> bool:
        """
        判断多段线是否闭合(起点与终点在容差范围内重合)
        :param tolerance: 浮点容差阈值,默认1e-10
        :return: 闭合返回True,否则返回False

        example:
        ```python
        polyline = DmDbPolyline()
        is_closed = polyline.is_closed()
        if is_closed:
            print("多段线闭合")
        else:
            print("多段线不闭合")
        ```
        """
        return self._obj.IsClosed(tolerance)

    @classmethod
    def _from_obj(cls, obj):
        """
        :param obj: 原生dmDbPolyline对象
        :return: DmDbPolyline实例
        """
        instance = cls.__new__(cls)
        instance._obj = obj
        return instance

__init__()

构造函数 :return: None

Source code in dimine_python_sdk\lib\types\line.py
41
42
43
44
45
46
def __init__(self):
    """
    构造函数
    :return: None
    """
    self._obj = Dm.dmDbPolyline()

__repr__()

字符串表示 :return: 多段线的标准字符串表示

Source code in dimine_python_sdk\lib\types\line.py
64
65
66
67
68
69
def __repr__(self) -> str:
    """
    字符串表示
    :return: 多段线的标准字符串表示
    """
    return self._obj.__repr__()

get_graph_data()

获取多段线的所有顶点坐标 :return: 顶点列表,每个元素为DmDPoint实例

example:

polyline = DmDbPolyline()
graph_data = polyline.get_graph_data()
for point in graph_data:
    print(point)
Source code in dimine_python_sdk\lib\types\line.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
def get_graph_data(self) -> list[DmDPoint]:
    """
    获取多段线的所有顶点坐标
    :return: 顶点列表,每个元素为DmDPoint实例

    example:
    ```python
    polyline = DmDbPolyline()
    graph_data = polyline.get_graph_data()
    for point in graph_data:
        print(point)
    ```
    """
    cpp_list = self._obj.GetGraphData()
    return [DmDPoint._from_obj(item) for item in cpp_list]

is_closed(tolerance=1e-10)

判断多段线是否闭合(起点与终点在容差范围内重合) :param tolerance: 浮点容差阈值,默认1e-10 :return: 闭合返回True,否则返回False

example:

polyline = DmDbPolyline()
is_closed = polyline.is_closed()
if is_closed:
    print("多段线闭合")
else:
    print("多段线不闭合")
Source code in dimine_python_sdk\lib\types\line.py
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
def is_closed(self, tolerance: float = 1e-10) -> bool:
    """
    判断多段线是否闭合(起点与终点在容差范围内重合)
    :param tolerance: 浮点容差阈值,默认1e-10
    :return: 闭合返回True,否则返回False

    example:
    ```python
    polyline = DmDbPolyline()
    is_closed = polyline.is_closed()
    if is_closed:
        print("多段线闭合")
    else:
        print("多段线不闭合")
    ```
    """
    return self._obj.IsClosed(tolerance)

set_color(red, green, blue)

设置多段线的颜色 :param red: 红色分量(0-255) :param green: 绿色分量(0-255) :param blue: 蓝色分量(0-255) :return: None

example:

polyline = DmDbPolyline()
polyline.set_color(255, 0, 0)  # 设置为红色
Source code in dimine_python_sdk\lib\types\line.py
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
def set_color(self, red: int, green: int, blue: int) -> None:
    """
    设置多段线的颜色
    :param red: 红色分量(0-255)
    :param green: 绿色分量(0-255)
    :param blue: 蓝色分量(0-255)
    :return: None

    example:
    ```python
    polyline = DmDbPolyline()
    polyline.set_color(255, 0, 0)  # 设置为红色
    ```
    """
    self._obj.SetColor(red, green, blue)

DmMatrix4x4

二次封装dmMatrix4x4New类

Source code in dimine_python_sdk\lib\types\line.py
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
class DmMatrix4x4:
    """二次封装dmMatrix4x4New类"""
    def __init__(self):
        """构造函数,初始化4x4矩阵"""
        self._obj = Dm.dmMatrix4x4()

    def align_coord_sys(
        self,
        from_origin: DmDPoint,
        from_x_axis: DmDPoint,
        from_y_axis: DmDPoint,
        from_z_axis: DmDPoint,
        to_origin: DmDPoint,
        to_x_axis: DmDPoint,
        to_y_axis: DmDPoint,
        to_z_axis: DmDPoint
    ) -> None:
        """
        对齐坐标系,将一个坐标系映射到另一个坐标系
        :param from_origin: 源坐标系原点(DmDPoint实例)
        :param from_x_axis: 源坐标系X轴方向(DmDPoint实例)
        :param from_y_axis: 源坐标系Y轴方向(DmDPoint实例)
        :param from_z_axis: 源坐标系Z轴方向(DmDPoint实例)
        :param to_origin: 目标坐标系原点(DmDPoint实例)
        :param to_x_axis: 目标坐标系X轴方向(DmDPoint实例)
        :param to_y_axis: 目标坐标系Y轴方向(DmDPoint实例)
        :param to_z_axis: 目标坐标系Z轴方向(DmDPoint实例)
        :return: None

        example:
        ```python
        matrix = DmMatrix4x4()
        matrix.align_coord_sys(
            from_origin=DmDPoint(0, 0, 0),
            from_x_axis=DmDPoint(1, 0, 0),
            from_y_axis=DmDPoint(0, 1, 0),
            from_z_axis=DmDPoint(0, 0, 1),
            to_origin=DmDPoint(100, 100, 100),
            to_x_axis=DmDPoint(0, 0, 1),
            to_y_axis=DmDPoint(0, 1, 0),
            to_z_axis=DmDPoint(1, 0, 0)
        )
        ```
        """
        self._obj.AlignCoordSys(
            from_origin._obj,
            from_x_axis._obj,
            from_y_axis._obj,
            from_z_axis._obj,
            to_origin._obj,
            to_x_axis._obj,
            to_y_axis._obj,
            to_z_axis._obj
        )

    def transform_point(self, pt_source: DmDPoint) -> DmDPoint:
        """
        对三维点应用矩阵变换
        :param pt_source: 待变换的源点(DmDPoint实例)
        :return: 变换后的点(DmDPoint实例)

        example:
        ```python
        matrix = DmMatrix4x4()
        pt = DmDPoint(1, 2, 3)
        transformed_pt = matrix.transform_point(pt)
        print("变换后的点:", transformed_pt)
        ```
        """
        cpp_result = self._obj.TransformPoint(pt_source._obj)
        result = DmDPoint()
        result._obj = cpp_result
        return result

__init__()

构造函数,初始化4x4矩阵

Source code in dimine_python_sdk\lib\types\line.py
118
119
120
def __init__(self):
    """构造函数,初始化4x4矩阵"""
    self._obj = Dm.dmMatrix4x4()

align_coord_sys(from_origin, from_x_axis, from_y_axis, from_z_axis, to_origin, to_x_axis, to_y_axis, to_z_axis)

对齐坐标系,将一个坐标系映射到另一个坐标系 :param from_origin: 源坐标系原点(DmDPoint实例) :param from_x_axis: 源坐标系X轴方向(DmDPoint实例) :param from_y_axis: 源坐标系Y轴方向(DmDPoint实例) :param from_z_axis: 源坐标系Z轴方向(DmDPoint实例) :param to_origin: 目标坐标系原点(DmDPoint实例) :param to_x_axis: 目标坐标系X轴方向(DmDPoint实例) :param to_y_axis: 目标坐标系Y轴方向(DmDPoint实例) :param to_z_axis: 目标坐标系Z轴方向(DmDPoint实例) :return: None

example:

matrix = DmMatrix4x4()
matrix.align_coord_sys(
    from_origin=DmDPoint(0, 0, 0),
    from_x_axis=DmDPoint(1, 0, 0),
    from_y_axis=DmDPoint(0, 1, 0),
    from_z_axis=DmDPoint(0, 0, 1),
    to_origin=DmDPoint(100, 100, 100),
    to_x_axis=DmDPoint(0, 0, 1),
    to_y_axis=DmDPoint(0, 1, 0),
    to_z_axis=DmDPoint(1, 0, 0)
)
Source code in dimine_python_sdk\lib\types\line.py
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
def align_coord_sys(
    self,
    from_origin: DmDPoint,
    from_x_axis: DmDPoint,
    from_y_axis: DmDPoint,
    from_z_axis: DmDPoint,
    to_origin: DmDPoint,
    to_x_axis: DmDPoint,
    to_y_axis: DmDPoint,
    to_z_axis: DmDPoint
) -> None:
    """
    对齐坐标系,将一个坐标系映射到另一个坐标系
    :param from_origin: 源坐标系原点(DmDPoint实例)
    :param from_x_axis: 源坐标系X轴方向(DmDPoint实例)
    :param from_y_axis: 源坐标系Y轴方向(DmDPoint实例)
    :param from_z_axis: 源坐标系Z轴方向(DmDPoint实例)
    :param to_origin: 目标坐标系原点(DmDPoint实例)
    :param to_x_axis: 目标坐标系X轴方向(DmDPoint实例)
    :param to_y_axis: 目标坐标系Y轴方向(DmDPoint实例)
    :param to_z_axis: 目标坐标系Z轴方向(DmDPoint实例)
    :return: None

    example:
    ```python
    matrix = DmMatrix4x4()
    matrix.align_coord_sys(
        from_origin=DmDPoint(0, 0, 0),
        from_x_axis=DmDPoint(1, 0, 0),
        from_y_axis=DmDPoint(0, 1, 0),
        from_z_axis=DmDPoint(0, 0, 1),
        to_origin=DmDPoint(100, 100, 100),
        to_x_axis=DmDPoint(0, 0, 1),
        to_y_axis=DmDPoint(0, 1, 0),
        to_z_axis=DmDPoint(1, 0, 0)
    )
    ```
    """
    self._obj.AlignCoordSys(
        from_origin._obj,
        from_x_axis._obj,
        from_y_axis._obj,
        from_z_axis._obj,
        to_origin._obj,
        to_x_axis._obj,
        to_y_axis._obj,
        to_z_axis._obj
    )

transform_point(pt_source)

对三维点应用矩阵变换 :param pt_source: 待变换的源点(DmDPoint实例) :return: 变换后的点(DmDPoint实例)

example:

matrix = DmMatrix4x4()
pt = DmDPoint(1, 2, 3)
transformed_pt = matrix.transform_point(pt)
print("变换后的点:", transformed_pt)
Source code in dimine_python_sdk\lib\types\line.py
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
def transform_point(self, pt_source: DmDPoint) -> DmDPoint:
    """
    对三维点应用矩阵变换
    :param pt_source: 待变换的源点(DmDPoint实例)
    :return: 变换后的点(DmDPoint实例)

    example:
    ```python
    matrix = DmMatrix4x4()
    pt = DmDPoint(1, 2, 3)
    transformed_pt = matrix.transform_point(pt)
    print("变换后的点:", transformed_pt)
    ```
    """
    cpp_result = self._obj.TransformPoint(pt_source._obj)
    result = DmDPoint()
    result._obj = cpp_result
    return result