-
Notifications
You must be signed in to change notification settings - Fork 6
/
pipe.py
72 lines (52 loc) · 2.66 KB
/
pipe.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
70
71
72
#Author-Hans Kellner
#Description-Function for generating pipes along sketch lines.
import adsk.core, adsk.fusion, traceback, math, random
# Generate pipes that follow each specified sketch line
# @arg rootComp
# @arg sketchLines
# @arg outerRadius
# @arg innerRadius
def createPipesOnLines(app, ui, sketchLines, outerDiam, innerDiam):
design = app.activeProduct
rootComp = design.rootComponent
sketches = rootComp.sketches
feats = rootComp.features
for line in sketchLines:
try:
if False:
# Command implementation
# NOTE: This crashes Fusion. Possiby because the commands are executed within addin command?
sels :adsk.core.Selections = ui.activeSelections
sels.clear()
sels.add(line) #path)
txtCmds = [
u'Commands.Start PrimitivePipe', # show dialog
u'Commands.SetDouble SWEEP_POP_ALONG 1.0', # input distance
u'Commands.SetDouble SectionRadius 0.5', # input radius
u'NuCommands.CommitCmd' # execute command
]
for cmd in txtCmds:
app.executeTextCommand(cmd)
sels.clear()
else:
# create path
path = feats.createPath(line, True)
# create profile
planes = rootComp.constructionPlanes
planeInput = planes.createInput()
planeInput.setByDistanceOnPath(path, adsk.core.ValueInput.createByReal(0))
plane = planes.add(planeInput)
sketch = sketches.add(plane)
center = sketch.modelToSketchSpace(plane.geometry.origin)
circleOuter = sketch.sketchCurves.sketchCircles.addByCenterRadius(center, outerDiam)
circleInner = None
if innerDiam > 0:
circleInner = sketch.sketchCurves.sketchCircles.addByCenterRadius(center, innerDiam)
profileOuter = sketch.profiles[0]
# create sweep for outer
sweepFeats = feats.sweepFeatures
sweepInputOuter = sweepFeats.createInput(profileOuter, path, adsk.fusion.FeatureOperations.JoinFeatureOperation)
sweepInputOuter.orientation = adsk.fusion.SweepOrientationTypes.PerpendicularOrientationType
sweepFeat = sweepFeats.add(sweepInputOuter)
except:
print("Unexpected error")