Skip to content

Commit ccbb9fd

Browse files
committed
Add examples to function docstrings
Signed-off-by: Michael Brunner <brunner@cadwork.swiss>
1 parent dad2f40 commit ccbb9fd

File tree

2 files changed

+86
-9
lines changed

2 files changed

+86
-9
lines changed

src/bim_controller/__init__.pyi

Lines changed: 84 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ def get_ifc_guid(element_id: int) -> str:
2020
Parameters:
2121
element_id: element_id
2222
23-
Returns:
24-
str
25-
"""
23+
Examples:
24+
>>> import element_controller as ec
25+
>>> import bim_controller as bc
2626
27-
def clear_errors() -> None:
28-
"""clear errors
27+
>>> selected_elements = ec.get_all_identifiable_element_ids()
28+
>>> element = selected_elements[0]
29+
>>> ifc_guid = bc.get_ifc_guid(element)
30+
>>> print(f"IFC GUID: {ifc_guid}")
2931
3032
Returns:
31-
None
33+
str
3234
"""
3335

3436
def get_ifc2x3_element_type(element_id: int) -> ifc_2x3_element_type:
@@ -37,6 +39,15 @@ def get_ifc2x3_element_type(element_id: int) -> ifc_2x3_element_type:
3739
Parameters:
3840
element_id: element_id
3941
42+
Examples:
43+
>>> import element_controller as ec
44+
>>> import bim_controller as bc
45+
>>> import cadwork # needed for ifc_2x3_element_type
46+
47+
>>> selected_elements = ec.get_all_identifiable_element_ids()
48+
>>> element = selected_elements[0]
49+
>>> ifc_type = bc.get_ifc2x3_element_type(element)
50+
4051
Returns:
4152
ifc_2x3_element_type
4253
"""
@@ -50,9 +61,14 @@ def set_ifc2x3_element_type(element_i_ds: List[int], ifc_type: ifc_2x3_element_t
5061
ifc_type: element_type
5162
5263
Examples:
64+
>>> import element_controller as ec
65+
>>> import bim_controller as bc
66+
>>> import cadwork
67+
68+
>>> selected_elements = ec.get_all_identifiable_element_ids()
5369
>>> ifc_entity_type = cadwork.ifc_2x3_element_type()
5470
>>> ifc_entity_type.set_ifc_member()
55-
>>> bimc.set_ifc2x3_element_type([element], ifc_entity_type)
71+
>>> bc.set_ifc2x3_element_type(selected_elements, ifc_entity_type)
5672
5773
Returns:
5874
None
@@ -64,6 +80,14 @@ def import_ifc_as_graphical_object(file_path: str) -> bool:
6480
Parameters:
6581
file_path: file_path
6682
83+
Examples:
84+
>>> import bim_controller as bc
85+
86+
>>> ifc_file_path = r"C:/imports/building_model.ifc"
87+
>>> success = bc.import_ifc_as_graphical_object(ifc_file_path)
88+
>>> if success:
89+
>>> print("IFC imported as graphical object successfully")
90+
6791
Returns:
6892
bool
6993
"""
@@ -74,6 +98,14 @@ def import_bcf(file_path: str) -> bool:
7498
Parameters:
7599
file_path: file_path
76100
101+
Examples:
102+
>>> import bim_controller as bc
103+
104+
>>> bcf_file_path = r"C:/imports/issues.bcf"
105+
>>> success = bc.import_bcf(bcf_file_path)
106+
>>> if success:
107+
>>> print("BCF file imported successfully")
108+
77109
Returns:
78110
bool
79111
"""
@@ -84,6 +116,14 @@ def export_bcf(file_path: str) -> bool:
84116
Parameters:
85117
file_path: file_path
86118
119+
Examples:
120+
>>> import bim_controller as bc
121+
122+
>>> bcf_output_path = r"C:/exports/project_issues.bcf"
123+
>>> success = bc.export_bcf(bcf_output_path)
124+
>>> if success:
125+
>>> print("BCF file exported successfully")
126+
87127
Returns:
88128
bool
89129
"""
@@ -95,6 +135,16 @@ def export_ifc(element_i_ds: List[int], file_path: str) -> bool:
95135
element_i_ds: element_i_ds
96136
file_path: file_path
97137
138+
Examples:
139+
>>> import element_controller as ec
140+
>>> import bim_controller as bc
141+
142+
>>> selected_elements = ec.get_all_identifiable_element_ids()
143+
>>> ifc_output_path = r"C:/exports/building_model.ifc"
144+
>>> success = bc.export_ifc(selected_elements, ifc_output_path)
145+
>>> if success:
146+
>>> print("IFC file exported successfully")
147+
98148
Returns:
99149
bool
100150
"""
@@ -117,6 +167,14 @@ def set_storey_height(building: str, storey: str, height: float) -> None:
117167
storey: storey
118168
height: height
119169
170+
Examples:
171+
>>> import bim_controller as bc
172+
173+
>>> building_name = "Building A"
174+
>>> storey_name = "Ground Floor"
175+
>>> height_millimeters = 3_500
176+
>>> bc.set_storey_height(building_name, storey_name, height_millimeters)
177+
120178
Returns:
121179
None
122180
"""
@@ -212,6 +270,15 @@ def set_building_and_storey(element_id_list: List[int], building: str, storey: s
212270
building: building
213271
storey: storey
214272
273+
Examples:
274+
>>> import element_controller as ec
275+
>>> import bim_controller as bc
276+
277+
>>> selected_elements = ec.get_all_identifiable_element_ids()
278+
>>> building_name = "Building A"
279+
>>> storey_name = "Ground Floor"
280+
>>> bc.set_building_and_storey(selected_elements, building_name, storey_name)
281+
215282
Returns:
216283
None
217284
"""
@@ -325,7 +392,16 @@ def set_ifc_predefined_type(element_i_ds: List[int], predefined_type: ifc_predef
325392
element_i_ds: element_i_ds
326393
predefined_type: predefined_type
327394
395+
Examples:
396+
>>> import element_controller as ec
397+
>>> import bim_controller as bc
398+
>>> import cadwork
399+
400+
>>> selected_elements = ec.get_all_identifiable_element_ids()
401+
>>> predefined_type = cadwork.ifc_predefined_type()
402+
>>> predefined_type.set_member()
403+
>>> bc.set_ifc_predefined_type(selected_elements, predefined_type)
404+
328405
Returns:
329406
None
330407
"""
331-

src/visualization_controller/__init__.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,8 @@ def get_camera_data() -> camera_data:
481481
camera data
482482
"""
483483

484-
def set_camera_data(camera_data: None) -> None:
484+
485+
def set_camera_data(camera_data: camera_data) -> None:
485486
"""Set the camera data - this will override the current camera data
486487
487488
Parameters:

0 commit comments

Comments
 (0)