forked from hlorus/CAD_Sketcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathidentifiers.py
51 lines (28 loc) · 1.26 KB
/
identifiers.py
1
2
3
4
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from typing import Union, Type
from .group_entities import type_from_index
from .categories import POINT, SEGMENT, LINE, CURVE, ELEMENT_2D
from .types import SlvsSketch, SlvsCircle, SlvsGenericEntity
EntityRef = Union[SlvsGenericEntity, int]
def _get_type(value: EntityRef) -> Type[SlvsGenericEntity]:
index = value if isinstance(value, int) else value.slvs_index
return type_from_index(index)
def is_2d(entity: EntityRef) -> bool:
return _get_type(entity) in ELEMENT_2D
def is_3d(entity: EntityRef) -> bool:
return not is_2d(entity)
def is_point(entity: EntityRef) -> bool:
return _get_type(entity) in POINT
def is_line(entity: EntityRef) -> bool:
return _get_type(entity) in LINE
def is_curve(entity: EntityRef) -> bool:
return _get_type(entity) in CURVE
def is_segment(entity: EntityRef) -> bool:
return _get_type(entity) in SEGMENT
def is_path(entity: EntityRef) -> bool:
return _get_type(entity) in (*SEGMENT, SlvsCircle)
def is_closed(entity: EntityRef) -> bool:
return _get_type(entity) == SlvsCircle
def is_sketch(entity: EntityRef) -> bool:
return _get_type(entity) == SlvsSketch
def is_circle(entity: EntityRef) -> bool:
return _get_type(entity) == SlvsCircle