How to use the k3d.filesystem.generic_path function in k3d

To help you get started, we’ve selected a few k3d examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github K-3D / k3d / tests / mesh / mesh.source.MeshSourceScript.teapots.py View on Github external
#python

import k3d
import testing

script_path = k3d.share_path() / k3d.filesystem.generic_path("scripts/MeshSourceScript/teapots.py")
script_file = file(str(script_path), "r")

setup = testing.setup_mesh_source_test("MeshSourceScript")
setup.source.script = script_file.read()


testing.require_valid_mesh(setup.document, setup.source.get_property("output_mesh"))
testing.require_similar_mesh(setup.document, setup.source.get_property("output_mesh"), "mesh.source.MeshSourceScript.teapots", 2)
github K-3D / k3d / tests / bitmap / bitmap.modifier.BitmapAdd.py View on Github external
#python

import k3d
import testing

setup = testing.setup_bitmap_modifier_test("BitmapReader", "BitmapAdd")
setup.source.file = k3d.filesystem.generic_path(testing.source_path() + "/bitmaps/" + "test_rgb_8.png")
setup.modifier.value = 0.5 

testing.require_similar_bitmap(setup.document, setup.modifier.get_property("output_bitmap"), "BitmapAdd", 0)
github K-3D / k3d / tests / mesh / modifier.DeleteComponents.complex.py View on Github external
#python

import k3d
import testing

setup = testing.setup_mesh_modifier_test("K3DMeshReader", "DeleteComponents")
setup.source.file = k3d.filesystem.generic_path(testing.source_path() + "/meshes/polyhedron.hole.k3d")
setup.source.center = False
setup.source.scale_to_size = False

selection = k3d.geometry.selection.create(0)

point_selection = k3d.geometry.point_selection.create(selection)
k3d.geometry.point_selection.append(point_selection, 0, 10000, 0)
k3d.geometry.point_selection.append(point_selection, 7, 8, 1)

face_selection = k3d.geometry.primitive_selection.create(selection, k3d.selection.type.FACE)
k3d.geometry.primitive_selection.append(face_selection, 0, 10000, 0)
k3d.geometry.primitive_selection.append(face_selection, 6, 7, 1)
k3d.geometry.primitive_selection.append(face_selection, 8, 9, 1)
k3d.geometry.primitive_selection.append(face_selection, 13, 15, 1)
k3d.geometry.primitive_selection.append(face_selection, 16, 17, 1)
k3d.geometry.primitive_selection.append(face_selection, 19, 20, 1)
github K-3D / k3d / tests / mesh / mesh.modifier.SubdivideFaces.CenterMidpoints.py View on Github external
#python

import k3d
import testing

setup = testing.setup_mesh_modifier_test("K3DMeshReader", "SubdivideFaces")
# load a mesh that has multiple polyhedra, triangles, quads, n-sided polygons and holes. (i.e. a mesh from hell)
setup.source.file = k3d.filesystem.generic_path(testing.source_path() + "/meshes/polyhedron.hole.k3d")
setup.source.center = False
setup.source.scale_to_size = False

#testing.add_point_attributes_test(setup, True, True, False)

# select some faces, distributed along polyhedra
selection = k3d.geometry.selection.create(0)
face_selection = k3d.geometry.primitive_selection.create(selection, k3d.selection.type.FACE)
k3d.geometry.primitive_selection.append(face_selection, 0, 6, 0)
k3d.geometry.primitive_selection.append(face_selection, 6, 7, 1)
k3d.geometry.primitive_selection.append(face_selection, 7, 8, 0)
k3d.geometry.primitive_selection.append(face_selection, 8, 9, 1)
k3d.geometry.primitive_selection.append(face_selection, 9, 13, 0)
k3d.geometry.primitive_selection.append(face_selection, 13, 15, 1)
k3d.geometry.primitive_selection.append(face_selection, 15, 16, 0)
k3d.geometry.primitive_selection.append(face_selection, 16, 17, 1)
github K-3D / k3d / tests / mesh / mesh.modifier.SubdivideFaces.Midpoints.py View on Github external
#python

import k3d
import testing

setup = testing.setup_mesh_modifier_test("K3DMeshReader", "SubdivideFaces")

# load a mesh that has multiple polyhedra, triangles, quads, n-sided polygons and holes. (i.e. a mesh from hell)
setup.source.file = k3d.filesystem.generic_path(testing.source_path() + "/meshes/polyhedron.hole.k3d")
setup.source.center = False
setup.source.scale_to_size = False

# select some faces, distributed along polyhedra
selection = k3d.geometry.selection.create(0)
face_selection = k3d.geometry.primitive_selection.create(selection, k3d.selection.type.FACE)
k3d.geometry.primitive_selection.append(face_selection, 0, 6, 0)
k3d.geometry.primitive_selection.append(face_selection, 6, 7, 1)
k3d.geometry.primitive_selection.append(face_selection, 7, 8, 0)
k3d.geometry.primitive_selection.append(face_selection, 8, 9, 1)
k3d.geometry.primitive_selection.append(face_selection, 9, 13, 0)
k3d.geometry.primitive_selection.append(face_selection, 13, 15, 1)
k3d.geometry.primitive_selection.append(face_selection, 15, 16, 0)
k3d.geometry.primitive_selection.append(face_selection, 16, 17, 1)
k3d.geometry.primitive_selection.append(face_selection, 17, 19, 0)
k3d.geometry.primitive_selection.append(face_selection, 19, 20, 1)
github K-3D / k3d / tests / ngui / icons.unexpected.py View on Github external
#python
import k3d
import glob
import os
import testing

factories = []
for factory in k3d.plugin.factory.lookup():
	factories.append(factory.name())

scalable_icons = []
for icon in glob.glob(str(k3d.share_path() / k3d.filesystem.generic_path("ngui/scalable/*.svg"))):
	scalable_icons.append(os.path.splitext(os.path.basename(icon))[0])

factories.sort()
scalable_icons.sort()

exceptions = ['BevelFaces', 'BitmapSequenceIn', 'BitmapSequenceOut', 'EXRBitmapExporter', 'ImageMagickBitmapExporter', 'Viewport', 'cant_connect_property_cursor', 'center', 'connect_property_cursor', 'connected_plug', 'convert_selection', 'element', 'keep_selection', 'knife_cursor', 'move_cursor', 'move_cursor_screen_xy', 'move_cursor_x', 'move_cursor_xy', 'move_cursor_xz', 'move_cursor_y', 'move_cursor_yz', 'move_cursor_z', 'move_tool', 'node_history_panel', 'node_list_panel', 'node_properties_panel', 'parent_cursor', 'plug_tool', 'render_animation', 'render_frame', 'render_preview', 'rotate_tool', 'scale_cursor', 'scale_cursor_x', 'scale_cursor_xy', 'scale_cursor_xyz', 'scale_cursor_xz', 'scale_cursor_y', 'scale_cursor_yz', 'scale_cursor_z', 'scale_tool', 'select_add_cursor', 'select_cursor', 'select_curve', 'select_face', 'select_group', 'select_node', 'select_patch', 'select_split_edge', 'select_subtract_cursor', 'select_tool', 'select_uniform', 'select_vertex', 'soft_selection', 'undo_tree_panel', 'unparent', 'viewport_panel']

unexpected_icons = []
for icon in scalable_icons:
	if icon not in factories:
		if icon in exceptions:
			continue
		unexpected_icons.append(icon)

if len(unexpected_icons):
	print "Unexpected icons without factories:", unexpected_icons
github K-3D / k3d / tests / testing.py View on Github external
def require_similar_bitmap(document, image_property, image_name, threshold):
	output_file = k3d.filesystem.generic_path(binary_path() + "/bitmaps/" + image_name + ".reference.png")
	reference_file = k3d.filesystem.generic_path(source_path() + "/bitmaps/" + image_name + ".reference.png")
	difference_file = k3d.filesystem.generic_path(binary_path() + "/bitmaps/differences/" + image_name + ".png")

	reference = k3d.plugin.create("PNGBitmapReader", document)
	reference.file = reference_file
	reference_property = reference.get_property("output_bitmap")

	difference = k3d.plugin.create("BitmapPerceptualDifference", document)
	difference.field_of_view = 10.0
	difference.luminance = 100
	difference_property = difference.get_property("output_bitmap")
	k3d.property.connect(document, image_property, difference.get_property("input_a"))
	k3d.property.connect(document, reference_property, difference.get_property("input_b"))

	image_writer = k3d.plugin.create("PNGBitmapWriter", document)
	image_writer.file = output_file
github K-3D / k3d / tests / mesh / mesh.modifier.CARVEBoolean.ply.py View on Github external
#python

import k3d
import testing

document = k3d.new_document()

small_cylinder = k3d.plugin.create("PLYMeshReader", document)
small_cylinder.file = k3d.filesystem.generic_path(testing.source_path() + "/meshes/mesh.modifier.CARVEBoolean.input.b.ply")
small_cylinder.center = False
small_cylinder.scale_to_size = False
big_cylinder = k3d.plugin.create("PLYMeshReader", document)
big_cylinder.file = k3d.filesystem.generic_path(testing.source_path() + "/meshes/mesh.modifier.CARVEBoolean.input.a.ply")
big_cylinder.center = False
big_cylinder.scale_to_size = False

carve_boolean = k3d.plugin.create("CARVEBoolean", document)
carve_boolean.type = "difference"
carve_boolean.create_property("k3d::mesh*", "input_1", "Input 1", "")
carve_boolean.create_property("k3d::mesh*", "input_2", "Input 2", "")

k3d.property.connect(document, big_cylinder.get_property("output_mesh"), carve_boolean.get_property("input_1"))
k3d.property.connect(document, small_cylinder.get_property("output_mesh"), carve_boolean.get_property("input_2"))

testing.require_valid_mesh(document, carve_boolean.get_property("output_mesh"))
testing.require_similar_mesh(document, carve_boolean.get_property("output_mesh"), "mesh.modifier.CARVEBoolean.ply", 10)