forked from CADacombs/rhinopython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxInput.py
More file actions
133 lines (105 loc) · 4.03 KB
/
xInput.py
File metadata and controls
133 lines (105 loc) · 4.03 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
"""
160601: Created by importing functions from other scripts.
160611-12: _
160618: Import-related update.
160721: Shortened sticky code.
160822: Minor changes.
190129-0605: Import-related update.
200107-08: Import-related update and various minor changes.
"""
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
import xBrepFace_contiguousFilletFaces
def getChainFilletFaces(bDebug=False):
# Load sticky.
stickyKeys = [
'bSameRad({})'.format(__file__),
'fRadTol({})({})'.format(__file__, sc.doc.Name),
'bTan({})'.format(__file__),
'fAngleTol({})({})'.format(__file__, sc.doc.Name),
]
stickyValues = [
True,
10.0*rs.UnitAbsoluteTolerance(),
True,
10.0*rs.UnitAngleTolerance(),
]
for i, stickyKey in enumerate(stickyKeys):
if sc.sticky.has_key(stickyKey): stickyValues[i] = sc.sticky[stickyKey]
(
bSameRad,
fRadTol,
bTan,
fAngleTol,
) = stickyValues
#
# Get constant radius (rolling ball) fillet face of brep.
go = Rhino.Input.Custom.GetObject()
go.SetCommandPrompt("Select starting face")
go.GeometryFilter = Rhino.DocObjects.ObjectType.Surface
go.GeometryAttributeFilter = (
Rhino.Input.Custom.GeometryAttributeFilter.SubSurface) # Doesn't allow single surfaces to be selected.
optT_SameRad = Rhino.Input.Custom.OptionToggle(bSameRad, 'No', 'Yes')
optD_RadTol = Rhino.Input.Custom.OptionDouble(
fRadTol, True, Rhino.RhinoMath.ZeroTolerance)
optT_Tan = Rhino.Input.Custom.OptionToggle(bTan, 'No', 'Yes')
optD_AngleTol = Rhino.Input.Custom.OptionDouble(
fAngleTol, True, Rhino.RhinoMath.ZeroTolerance)
go.AddOptionToggle('SameRad', optT_SameRad)
if optT_SameRad.CurrentValue:
go.AddOptionDouble('RadTol', optD_RadTol)
go.AddOptionToggle('TanContinuity', optT_Tan)
if optT_Tan.CurrentValue:
go.AddOptionDouble('AngleTol', optD_AngleTol)
go.EnableClearObjectsOnEntry(False) # If not set to False, faces will be unselected when result == Rhino.Input.GetResult.Object
while go.Get() != Rhino.Input.GetResult.Object:
if sc.escape_test(False): break
res = go.CommandResult()
if res != Rhino.Commands.Result.Success:
go.Dispose()
return
bSameRad = optT_SameRad.CurrentValue
bTan = optT_Tan.CurrentValue
go.ClearCommandOptions()
go.AddOptionToggle('SameRadius', optT_SameRad)
if optT_SameRad.CurrentValue:
fRadTol = optD_RadTol.CurrentValue
go.AddOptionDouble('RadiusTolerance', optD_RadTol)
go.AddOptionToggle('Tangent', optT_Tan)
if bTan:
fAngleTol = optD_AngleTol.CurrentValue
go.AddOptionDouble('AngleTolerance', optD_AngleTol)
bSameRad = optT_SameRad.CurrentValue
bTan = optT_Tan.CurrentValue
# Save sticky
stickyValues = bSameRad, fRadTol, bTan, fAngleTol
for i, stickyKey in enumerate(stickyKeys):
sc.sticky[stickyKey] = stickyValues[i]
rdORef = go.Object(0)
rgFace = rdORef.Face()
fPlanarTol = rs.UnitAbsoluteTolerance()
if rgFace.IsPlanar(fPlanarTol):
print "Planar face selected."
go.Dispose()
return
rdBrep0 = rdORef.Object() # Parent
rgBrep0 = rdORef.Brep()
idxFace_Sel = rdORef.GeometryComponentIndex.Index
rc = xBrepFace_contiguousFilletFaces.indicesOfContiguousFilletFaces(
rgBrep0,
idxFace_Sel,
bSameRad,
fRadTol,
bTan,
fAngleTol)
if rc is None:
print "Non-fillet face selected."
go.Dispose()
return
idxFaces_Pass = sorted(rc)
idBrep0 = rdORef.ObjectId
go.Dispose()
return idBrep0, idxFaces_Pass
# Tester
if __name__ == '__main__': print getChainFilletFaces(bDebug=True)