-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlane_tools.py
54 lines (47 loc) · 1.97 KB
/
Plane_tools.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
import adsk.core, adsk.fusion, traceback
import numpy as np
handlers = []
ui = None
app = adsk.core.Application.get()
if app:
ui = app.userInterface
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
rootComp = design.rootComponent
planes = rootComp.constructionPlanes
class plane_tools:
def arithmetic_pro(start,difference,quantity):
try: #等差数列を生成(np.arangeの引数が嫌だったので加工)
nplist = (np.arange(start,start + difference * quantity ,difference))
sendlist = nplist.tolist()
return sendlist
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def plane_builder(pareantplane, dist):
try: #offset平面の生成(一枚分)
distance = adsk.core.ValueInput.createByReal(dist)
planeInput = planes.createInput()
planeInput.setByOffset(pareantplane, distance)
PlaneOne = planes.add(planeInput)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def Excecute(self, parantplane, start, difference, quantity ):
try:
xyplane = rootComp.xYConstructionPlane
yzplane = rootComp.yZConstructionPlane
zxplane = rootComp.xZConstructionPlane
planelist = plane_tools.arithmetic_pro(start,difference,quantity)
if parantplane == xyplane:
for i in range(len(planelist)):
plane_tools.plane_builder(xyplane, planelist[i])
elif parantplane == yzplane:
for i in range(len(planelist)):
plane_tools.plane_builder(yzplane, planelist[i])
else:
for i in range(len(planelist)):
plane_tools.plane_builder(zxplane, planelist[i])
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))