#
#   An example Python script for use with supy.
#

print "This is an example Python script."

def cylinder(x, y, z, r, h):
	p = Point3d(x, y, z)
	v = Vector3d(0, 0, 1)
	model = Sketchup.active_model()
	entities = model.entities()
	model.start_operation("Cylinder")
	edges = entities.add_circle(p, v, r)
	face = entities.add_face(edges)
	if not face:
		print "No face created, maybe it already exists?"
		return
	face.pushpull(-h, False)
	face.reverse()
	color = "Yellow"
	face.material = color
	for face2 in face.all_connected():
		face2.material = color
	model.commit_operation()

#
#  Example of usage from Ruby Console:
#
#    Py.example.cylinder(0, 0, 0, 10, 30)
#

#
#  Adding menu items
#

def test_cylinder():
	cylinder(0, 0, 0, 10, 30)

import menus
plugins_menu = menus.get_menu("Plugins")
example_submenu = plugins_menu.add_submenu("SuPy Examples")
example_submenu.add_item("Cylinder", test_cylinder)
