This repository was archived by the owner on Mar 12, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
67 lines (52 loc) · 2 KB
/
Copy pathmain.py
File metadata and controls
67 lines (52 loc) · 2 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import sys
import win32com.client
def save_in_file(file_name, content):
with open(f"C:\\Users\\Prioritet\\PyProjects\\RengaCOM\\{file_name}", 'w') as file:
file.write(content)
def main():
app = win32com.client.Dispatch("Renga.Application.1")
app.Visible = True
if app.OpenProject("D:\\Programs\\Renga Professional\\Projects\\MainProject.rnp") != 0:
print("Error opening project")
sys.exit(1)
project = app.Project
model = project.Model
opening_type = "{fc443d5a-b76c-45e5-b91c-520ef0896109}".upper()
window_type = "{2b02b353-2ca5-4566-88bb-917ea8460174}".upper()
door_type = "{1cfba99c-01e7-4078-ae1a-3e2ff0673599}".upper()
wall_type = "{4329112a-6b65-48d9-9da8-abf1f8f36327}".upper()
room_type = "{f1a805ff-573d-f46b-ffba-57f4bccaa6ed}".upper()
opening_count = 0
window_count = 0
door_count = 0
wall_count = 0
room_count = 0
# Creating and starting an operation before editing the project
operation = project.CreateOperation()
operation.Start()
object_collection = model.GetObjects()
# print(object_collection.Count)
for index in range(object_collection.Count):
obj = object_collection.GetByIndex(index)
# print(obj.Name, obj.ObjectTypeS)
# NOTE: using the S-property
if obj.ObjectTypeS == opening_type:
opening_count += 1
if obj.ObjectTypeS == window_type:
window_count += 1
if obj.ObjectTypeS == door_type:
door_count += 1
if obj.ObjectTypeS == wall_type:
wall_count += 1
if obj.ObjectTypeS == room_type:
room_count += 1
print(room_count)
# print((opening_count, window_count, door_count))
# save_in_file('log.txt', f"Openings: {opening_count} Windows: {window_count} Doors: {door_count}")
# Applying the changes
operation.Apply()
# Closing the project without saving, dumping all the hard work
app.CloseProject(True)
app.Quit()
if __name__ == '__main__':
main()