forked from mcneel/rhino-developer-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SampleDrawBrepEdges.py
51 lines (48 loc) · 1.85 KB
/
SampleDrawBrepEdges.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
################################################################################
# SampleDrawBrepEdges.py
# Copyright (c) 2017 Robert McNeel & Associates.
# See License.md in the root of this repository for details.
################################################################################
import scriptcontext
import rhinoscriptsyntax as rs
import Rhino
import System
# Demonstrates how to draw the edges of selected Breps with
# a special color.
class SampleDrawBrepEdgesConduit(Rhino.Display.DisplayConduit):
# class members
draw_color = System.Drawing.Color.Pink
# class constructor
def __init__(self, brep):
self.brep = brep
# DrawOverlay override
def DrawOverlay(self, e):
for edge in self.brep.Edges:
e.Display.DrawCurve(edge, self.draw_color, 3)
def SampleDrawBrepEdges():
# Pick a Brep
go = Rhino.Input.Custom.GetObject()
go.SetCommandPrompt('Select Brep')
go.GeometryFilter = Rhino.DocObjects.ObjectType.Brep
go.Get()
if (go.CommandResult() == Rhino.Commands.Result.Success):
# Get some stuff...
obj = go.Object(0).Object()
brep = go.Object(0).Brep()
if obj and brep:
# Unselect the object
obj.Select(False)
# Create and enable the conduit
conduit = SampleDrawBrepEdgesConduit(brep)
conduit.Enabled = True
scriptcontext.doc.Views.Redraw()
# Wait for the user...
rs.GetString('Press <Enter> to continue')
# Disable the conduit
conduit.Enabled = False
scriptcontext.doc.Views.Redraw()
# Check to see if this file is being executed as the "main" python
# script instead of being used as a module by some other python script
# This allows us to use the module which ever way we want.
if __name__=="__main__":
SampleDrawBrepEdges()