How to use the k3d.geometry.selection 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.modifier.NurbsDegreeElevateCurve.py View on Github external
#python

import k3d
import testing

setup = testing.setup_mesh_modifier_test("NurbsCurve","NurbsCurveDegreeElevation")

mesh_selection = k3d.geometry.selection.create(0)
uniform_selection = k3d.geometry.primitive_selection.create(mesh_selection, k3d.selection.type.CURVE)
k3d.geometry.primitive_selection.append(uniform_selection, 1)

setup.modifier.mesh_selection = mesh_selection
setup.modifier.degree = 1


testing.require_valid_mesh(setup.document, setup.modifier.get_property("output_mesh"))
testing.require_similar_mesh(setup.document, setup.modifier.get_property("output_mesh"), "mesh.modifier.NurbsDegreeElevateCurve", 1)
github K-3D / k3d / tests / parallel.thread_count.ScalePoints.py View on Github external
#python

import k3d
import testing

# Create a mesh source and our test modifier ...
setup = testing.setup_mesh_modifier_test("PolyGrid", "ScalePoints")
setup.source.rows = 300
setup.source.columns = 300

selection = k3d.geometry.selection.create(0)
selection.points = k3d.geometry.point_selection.create(selection, 1)
setup.modifier.mesh_selection = selection

# Force an update of the mesh source output, so it doesn't interfere with our timing
mesh = setup.source.output_mesh

for thread_count in range(1, 9):
	k3d.parallel.set_grain_size(10000)
	k3d.parallel.set_thread_count(thread_count)
	setup.modifier.x = 1.0
	setup.modifier.x = 2.0

	timer = testing.timer()
	mesh = setup.modifier.output_mesh
	print "Thread Count:", thread_count, "Time:", timer.elapsed()
github K-3D / k3d / tests / mesh / mesh.modifier.NurbsExtrudePatch.py View on Github external
#python

import testing
import k3d

setup = testing.setup_mesh_modifier_test("NurbsDisk", "NurbsExtrudePatch")
setup.modifier.mesh_selection = k3d.geometry.selection.create(1)

testing.require_valid_mesh(setup.document, setup.modifier.get_property("output_mesh"))
testing.require_similar_mesh(setup.document, setup.modifier.get_property("output_mesh"), "mesh.modifier.NurbsExtrudePatch", 2, ["Darwin-i386"])
github K-3D / k3d / tests / mesh / mesh.modifier.NurbsSplitPatch.py View on Github external
#python

import k3d
import testing

setup = testing.setup_mesh_modifier_test("NurbsGrid","NurbsSplitPatch")
#testing.add_point_attributes_test(setup, True, True, True)

setup.modifier.mesh_selection = k3d.geometry.selection.create(1)
setup.modifier.u_value = 0.567
setup.modifier.insert_to_v = False

testing.require_valid_mesh(setup.document, setup.modifier.get_property("output_mesh"))
#testing.require_valid_point_attributes(setup.document, setup.modifier.output_mesh)
#testing.require_valid_vertex_attributes(setup.document, setup.modifier.output_mesh)
#testing.require_valid_parameter_attributes(setup.document, setup.modifier.output_mesh)
testing.require_similar_mesh(setup.document, setup.modifier.get_property("output_mesh"), "mesh.modifier.NurbsSplitPatch1", 2)
github K-3D / k3d / tests / mesh / mesh.modifier.RotatePoints.py View on Github external
#python

import k3d
import testing

setup = testing.setup_mesh_modifier_test("PolyCube", "RotatePoints")

selection = k3d.geometry.selection.create(0)
selection.points = k3d.geometry.point_selection.create(selection, 1)

setup.modifier.mesh_selection = selection
setup.modifier.z = 1.0


testing.require_valid_mesh(setup.document, setup.modifier.get_property("output_mesh"))
testing.require_similar_mesh(setup.document, setup.modifier.get_property("output_mesh"), "mesh.modifier.RotatePoints", 1)
github K-3D / k3d / tests / ngui / RotateTool.py View on Github external
#python
import k3d
import testing

#Create a polycube
k3d.atk.root().frame("Untitled Document 1").filler("vbox").panel("main").split_pane("main").panel("NGUIToolbarPanel").filler(0).panel(0).filler(0).filler(0).page_tab_list(0).page_tab("Create").filler(0).filler(0).push_button(0).click()

# Switch to point selection mode
k3d.atk.root().frame("Untitled Document 1").filler("vbox").panel("main").split_pane("main").panel("NGUIToolbarPanel").filler("vbox").panel("content").filler("vbox").filler("toolbox").filler("main_toolbar").filler("row1").toggle_button("Select Nodes").click()
k3d.atk.root().frame("Untitled Document 1").filler("vbox").panel("main").split_pane("main").panel("NGUIToolbarPanel").filler("vbox").panel("content").filler("vbox").filler("toolbox").filler("main_toolbar").filler("row1").toggle_button("Select Points").click()

doc = k3d.documents()[0]
cube_instance = k3d.node.lookup_one(doc, "PolyCube Instance")

# set the selection on the PolyCube instance
selection = k3d.geometry.selection.create(0)
point_selection = k3d.geometry.point_selection.create(selection)
k3d.geometry.point_selection.append(point_selection, 0, 4, 1)
cube_instance.mesh_selection = selection

# Switch to rotate tool
k3d.atk.root().frame("Untitled Document 1").filler("vbox").panel("main").split_pane("main").panel("NGUIToolbarPanel").filler("vbox").panel("content").filler("vbox").filler("toolbox").filler("main_toolbar").filler("row0").toggle_button("selection_tool").click()
k3d.atk.root().frame("Untitled Document 1").filler("vbox").panel("main").split_pane("main").panel("NGUIToolbarPanel").filler("vbox").panel("content").filler("vbox").filler("toolbox").filler("main_toolbar").filler("row0").toggle_button("rotate_tool").click()

# Activate the move tool properties and change the parameters
k3d.atk.root().frame("Untitled Document 1").filler("vbox").panel("main").split_pane("main").split_pane("bottom").split_pane("top").split_pane("left").split_pane("bottom").panel("NGUINodePropertiesPanel").filler("vbox").filler("decorations").combo_box("panel_type").menu(0).menu_item("NGUIToolPropertiesPanel").click()
k3d.atk.root().frame("Untitled Document 1").filler("vbox").panel("main").split_pane("main").split_pane("bottom").split_pane("top").split_pane("left").split_pane("bottom").panel("NGUIToolPropertiesPanel").filler("vbox").panel("content").filler(0).filler("vbox").scroll_pane(0).viewport(0).filler("rotate_tool").panel("Builtin Properties").panel(0).panel("rotation_control").panel(2).push_button("up").click()
k3d.atk.root().frame("Untitled Document 1").filler("vbox").panel("main").split_pane("main").split_pane("bottom").split_pane("top").split_pane("left").split_pane("bottom").panel("NGUIToolPropertiesPanel").filler("vbox").panel("content").filler(0).filler("vbox").scroll_pane(0).viewport(0).filler("rotate_tool").panel("Builtin Properties").panel(0).panel("rotation_control").panel(2).push_button("up").click()
k3d.atk.root().frame("Untitled Document 1").filler("vbox").panel("main").split_pane("main").split_pane("bottom").split_pane("top").split_pane("left").split_pane("bottom").panel("NGUIToolPropertiesPanel").filler("vbox").panel("content").filler(0).filler("vbox").scroll_pane(0).viewport(0).filler("rotate_tool").panel("Builtin Properties").panel(0).panel("rotation_control").panel(2).push_button("up").click()
k3d.atk.root().frame("Untitled Document 1").filler("vbox").panel("main").split_pane("main").split_pane("bottom").split_pane("top").split_pane("left").split_pane("bottom").panel("NGUIToolPropertiesPanel").filler("vbox").panel("content").filler(0).filler("vbox").scroll_pane(0).viewport(0).filler("rotate_tool").panel("Builtin Properties").panel(0).panel("rotation_control").panel(2).push_button("up").click()
k3d.atk.root().frame("Untitled Document 1").filler("vbox").panel("main").split_pane("main").split_pane("bottom").split_pane("top").split_pane("left").split_pane("bottom").panel("NGUIToolPropertiesPanel").filler("vbox").panel("content").filler(0).filler("vbox").scroll_pane(0).viewport(0).filler("rotate_tool").panel("Builtin Properties").panel(0).panel("rotation_control").panel(2).push_button("up").click()
github K-3D / k3d / tests / mesh / mesh.modifier.NurbsRuledSurface.py View on Github external
import testing
import k3d
from math import pi

document = k3d.new_document()

curve1 = k3d.plugin.create("NurbsCurve", document)
curve2 = k3d.plugin.create("NurbsCircle", document)
transform = k3d.plugin.create("RotatePoints", document)
merge_mesh = k3d.plugin.create("MergeMesh", document)
modifier = k3d.plugin.create("NurbsRuledSurface", document)

merge_mesh.create_property("k3d::mesh*", "input_mesh1", "Input Mesh 1", "")
merge_mesh.create_property("k3d::mesh*", "input_mesh2", "Input Mesh 2", "")

transform_selection = k3d.geometry.selection.create(0)
k3d.geometry.point_selection.create(transform_selection, 1)
transform.mesh_selection = transform_selection
transform.y = 0.5*pi

modifier.mesh_selection = k3d.geometry.selection.create(1)

k3d.property.connect(document, curve2.get_property("output_mesh"), transform.get_property("input_mesh"))
k3d.property.connect(document, curve1.get_property("output_mesh"), merge_mesh.get_property("input_mesh1"))
k3d.property.connect(document, transform.get_property("output_mesh"), merge_mesh.get_property("input_mesh2"))
k3d.property.connect(document, merge_mesh.get_property("output_mesh"), modifier.get_property("input_mesh"))


testing.require_valid_mesh(document, modifier.get_property("output_mesh"))
testing.require_similar_mesh(document, modifier.get_property("output_mesh"), "mesh.modifier.NurbsRuledSurface", 1)
github K-3D / k3d / tests / mesh / mesh.modifier.NurbsSkinnedSurface.py View on Github external
curve3 = k3d.plugin.create("NurbsCurve", document)
transform1 = k3d.plugin.create("TranslatePoints", document)
transform2 = k3d.plugin.create("TranslatePoints", document)
merge_mesh = k3d.plugin.create("MergeMesh", document)
modifier = k3d.plugin.create("NurbsSkinnedSurface", document)

merge_mesh.create_property("k3d::mesh*", "input_mesh1", "Input Mesh 1", "")
merge_mesh.create_property("k3d::mesh*", "input_mesh2", "Input Mesh 2", "")
merge_mesh.create_property("k3d::mesh*", "input_mesh3", "Input Mesh 3", "")

transform1.mesh_selection = k3d.geometry.selection.create(1)
transform1.y = 3
transform2.mesh_selection = k3d.geometry.selection.create(1)
transform2.z = 3

modifier.mesh_selection = k3d.geometry.selection.create(1)

k3d.property.connect(document, curve2.get_property("output_mesh"), transform1.get_property("input_mesh"))
k3d.property.connect(document, curve3.get_property("output_mesh"), transform2.get_property("input_mesh"))
k3d.property.connect(document, curve1.get_property("output_mesh"), merge_mesh.get_property("input_mesh1"))
k3d.property.connect(document, transform1.get_property("output_mesh"), merge_mesh.get_property("input_mesh2"))
k3d.property.connect(document, transform2.get_property("output_mesh"), merge_mesh.get_property("input_mesh3"))
k3d.property.connect(document, merge_mesh.get_property("output_mesh"), modifier.get_property("input_mesh"))

testing.require_valid_mesh(document, modifier.get_property("output_mesh"))
testing.require_similar_mesh(document, modifier.get_property("output_mesh"), "mesh.modifier.NurbsSkinnedSurface", 1)
github K-3D / k3d / tests / mesh / mesh.modifier.NurbsAddTrimCurve.py View on Github external
#python

import testing
import k3d

document = k3d.new_document()

patch = k3d.plugin.create("NurbsGrid", document)
curve = k3d.plugin.create("NurbsCircle", document)
merge_mesh = k3d.plugin.create("MergeMesh", document)
modifier = k3d.plugin.create("NurbsAddTrimCurve", document)

k3d.property.create(merge_mesh, "k3d::mesh*", "input_mesh1", "Input Mesh 1", "")
k3d.property.create(merge_mesh, "k3d::mesh*", "input_mesh2", "Input Mesh 2", "")

modifier.mesh_selection = k3d.geometry.selection.create(1)
modifier.offset_u = 0.5
modifier.offset_v = 0.5

k3d.property.connect(document, patch.get_property("output_mesh"), merge_mesh.get_property("input_mesh1"))
k3d.property.connect(document, curve.get_property("output_mesh"), merge_mesh.get_property("input_mesh2"))
k3d.property.connect(document, merge_mesh.get_property("output_mesh"), modifier.get_property("input_mesh"))

testing.require_valid_mesh(document, modifier.get_property("output_mesh"))
testing.require_similar_mesh(document, modifier.get_property("output_mesh"), "mesh.modifier.NurbsAddTrimCurve", 1, ["Darwin-i386"]
)
github K-3D / k3d / tests / mesh.modifier.CenterPoints.py View on Github external
#python

import k3d
import testing

setup = testing.setup_mesh_modifier_test2("PolyCube", "TranslatePoints", "CenterPoints")

selection = k3d.geometry.selection.create(0)
selection.points = k3d.geometry.point_selection.create(selection, 1)

setup.modifier1.mesh_selection = selection
setup.modifier1.x = 1.0
setup.modifier1.y = 2.0
setup.modifier1.z = 3.0

setup.modifier2.mesh_selection = selection
setup.modifier2.center_x = True
setup.modifier2.center_y = True
setup.modifier2.center_z = True


testing.require_valid_mesh(setup.document, setup.modifier2.get_property("output_mesh"))
testing.require_similar_mesh(setup.document, setup.modifier2.get_property("output_mesh"), "mesh.modifier.CenterPoints", 1)