Skip to content

Commit

Permalink
Rhino visualization with Eto Form
Browse files Browse the repository at this point in the history
  • Loading branch information
yck011522 committed Nov 1, 2024
1 parent 8dee467 commit 7eeff81
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions docs/examples/rhino/files/visualize_with_eto_form.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import Rhino
import Eto
import Eto.Drawing as drawing
import Eto.Forms as forms

from compas_fab.robots import RobotCellLibrary
from compas.scene import Scene



class EtoFormSliderTest(forms.Dialog[bool]):
def __init__(self):
self.Title = "Sample Slider Eto Test"
self.Padding = drawing.Padding(5)
self.ClientSize = drawing.Size(300,50)
self.Resizable = True

self.slider = forms.Slider()
self.slider.MinValue = 1
self.slider.MaxValue = 50
self.slider.Value = 5
self.slider.ValueChanged += self.OnSliderValueChanged
self.sliderLabelTest = forms.Label(Text = str(self.slider.Value))

layout= forms.DynamicLayout()
layout.AddRow(None)
layout.AddRow(self.slider)
layout.AddRow(self.sliderLabelTest)

self.Content = layout

# Create Robot and Scene Object
robot_cell, robot_cell_state = RobotCellLibrary.ur5(load_geometry=True)
scene = Scene()
self.scene_object = scene.add(robot_cell.robot_model)
self.scene_object.draw()


def OnSliderValueChanged(self,sender,e):
value = self.slider.Value * 0.1
print(value)
self.sliderLabelTest.Text = str(value)
configuration = self.scene_object.item.zero_configuration()
configuration.joint_values[0] = value
self.scene_object.update(configuration)
# self.scene_object.clear_layer()
self.scene_object.draw()


def OpenEtoWindow():
form = EtoFormSliderTest()
Rhino.UI.EtoExtensions.ShowSemiModal(form, Rhino.RhinoDoc.ActiveDoc, Rhino.UI.RhinoEtoApp.MainWindow)

if __name__ == '__main__':
OpenEtoWindow()

0 comments on commit 7eeff81

Please sign in to comment.