Source code for compas_rhino.forms.slider
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
from compas_rhino.forms.base import BaseForm
import System
from System.Drawing import Size
from System.Drawing import Point
from System.Drawing import Color
from System.Windows.Forms import TextBox
from System.Windows.Forms import TrackBar
import scriptcontext as sc
__all__ = ['SliderForm']
# ==============================================================================
# Main
# ==============================================================================
if __name__ == '__main__':
import Rhino
from Rhino.Geometry import Point3d
from Rhino.Geometry import Plane
from Rhino.Geometry import Circle
from Rhino.Geometry import Cylinder
from Rhino.Display import DisplayMaterial
class Pipe(Rhino.Display.DisplayConduit):
""""""
def __init__(self, slider):
super(Pipe, self).__init__()
self.slider = slider
self.base = Point3d(0, 0, 0)
self.normal = Point3d(0, 0, 1) - self.base
self.height = 30
self.plane = Plane(self.base, self.normal)
self.color = Color.FromArgb(255, 0, 0)
self.material = DisplayMaterial(self.color)
def DrawForeground(self, e):
radius = self.slider.trackbar.Value
circle = Circle(self.plane, radius)
cylinder = Cylinder(circle, self.height)
brep = cylinder.ToBrep(True, True)
e.Display.DrawBrepShaded(brep, self.material)
try:
slider = SliderForm(0, 10, 1, 3)
pipe = Pipe(slider)
pipe.Enabled = True
sc.doc.Views.Redraw()
slider.show()
except Exception as e:
print(e)
finally:
pipe.Enabled = False
del pipe