This repository has been archived by the owner on Sep 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathhello_python_world.py
69 lines (61 loc) · 1.5 KB
/
hello_python_world.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import sys
import time
import asyncio
import pythoncom
import win32com.client
# Solidworks Version (write the year) :
SWV = 2022
# API Version
SWAV = SWV-1992
# Elapsed time
elapsed = 0
async def main():
sw = win32com.client.Dispatch("SldWorks.Application.{}".format(SWAV))
print(f" Solidworks API Version : {SWAV}","\n",f"Solidworks Version : {SWV}")
Model = sw.ActiveDoc
ARG_NULL = win32com.client.VARIANT(pythoncom.VT_DISPATCH, None)
ck = Model.Extension.SelectByID2("Front", "PLANE", 0, 0, 0, False, 0, ARG_NULL, 0)
Model.SketchManager.InsertSketch(True)
Model.ClearSelection2(True)
mySketchText = Model.InsertSketchText(
0, 0, 0, "Hello Python World!", 0, 0, 0, 100, 100
)
myFeature = Model.FeatureManager.FeatureExtrusion2(
True,
False,
False,
0,
0,
0.001,
0.001,
False,
False,
False,
False,
0,
0,
False,
False,
False,
False,
True,
True,
True,
0,
0,
False,
)
Model.SelectionManager.EnableContourSelection = False
Model.ClearSelection2(True)
s = time.perf_counter()
elapsed = time.perf_counter() - s
print(f"{__file__} executed in {elapsed:0.2f} seconds until while-loop")
time.sleep(2)
while True:
Model.ViewRotateplusy()
time.sleep(0.1)
try:
if __name__ == "__main__":
asyncio.run(main())
except KeyboardInterrupt:
sys.exit()