Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#python
import k3d
import testing
document = k3d.new_document()
time_source = k3d.plugin.create("TimeSource", document)
instance = k3d.plugin.create("MeshInstance", document)
transform = k3d.plugin.create("FrozenMatrix", document)
track = k3d.plugin.create("AnimationTrackDoubleMatrix4", document)
interpolator = k3d.plugin.create("InterpolatorDoubleMatrix4Linear", document)
track.interpolator = interpolator
transform.matrix = k3d.translate3(3, 0, 0)
time = k3d.get_time(document)
document.set_dependency(instance.get_property("input_matrix"), track.get_property("output_value"))
document.set_dependency(track.get_property("value_input"), transform.get_property("output_matrix"))
document.set_dependency(track.get_property("time_input"), time_source.get_property("time"))
time.set_value(0.0)
#python
import k3d
import testing
document = k3d.new_document()
small_cylinder = k3d.plugin.create("PolyCylinder", document)
small_cylinder.radius = 2.0
small_cylinder.zmax = 7.5
small_cylinder.zmin = -7.5
small_cylinder.u_segments = 8
big_cylinder = k3d.plugin.create("PolyCylinder", document)
big_cylinder.u_segments = 8
torus = k3d.plugin.create("PolyTorus", document)
torus.u_segments = 8
torus.v_segments = 4
first_boolean = k3d.plugin.create("CGALBoolean", document)
first_boolean.type = "difference"
first_boolean.create_property("k3d::mesh*", "input_1", "Input 1", "")
first_boolean.create_property("k3d::mesh*", "input_2", "Input 2", "")
#python
import k3d
import testing
doc = k3d.new_document()
axes = doc.new_node("Axes")
edge_painter = doc.new_node("OpenGLEdgePainter")
face_painter = doc.new_node("OpenGLFacePainter")
painter = doc.new_node("OpenGLMultiPainter")
painter.create_property("k3d::gl::imesh_painter*", "edges", "Edges", "Edge Painter")
painter.create_property("k3d::gl::imesh_painter*", "faces", "Faces", "Face Painter")
painter.edges = edge_painter
painter.faces = face_painter
cylinder = doc.new_node("PolyCylinder")
cylinder_instance = doc.new_node("MeshInstance")
cylinder_instance.gl_painter = painter
doc.set_dependency(cylinder_instance.get_property("input_mesh"), cylinder.get_property("output_mesh"))
class dummyStream:
def __init__(self): pass
def write(self,data): pass
def read(self,data): pass
def flush(self): pass
def close(self): pass
for script in scripts:
k3d.log_info("Running " + script)
old_streams = [sys.stdout, sys.stderr]
sys.stdout,sys.stderr = dummyStream(),dummyStream()
try:
document = k3d.new_document()
code = file(script).read()
k3d.execute_script(code, {"Document": document})
except:
failed_scripts.append(script)
sys.stdout,sys.stderr = old_streams
if len(failed_scripts):
k3d.log_error("The following scripts FAILED:")
for script in failed_scripts:
k3d.log_error(" " + script + " (Failed)")
sys.argv.append("K-3D Python Engine")
raise ""
#python
import k3d
doc = k3d.new_document()
memory_pools = k3d.plugin.create("MemoryPools")
memory_pools.execute_command("shuffle", "4000 points")
memory_pools.execute_command("shuffle", "4000 split_edges")
memory_pools.execute_command("shuffle", "4000 faces")
diff = doc.new_node("MeshDiff")
for i in range(100):
cube = doc.new_node("PolyCube")
extrude_faces = doc.new_node("ExtrudeFaces")
extrude_faces.region = False
selection = k3d.geometry.selection.create(0)
selection.faces = [(0, 3, 1), (3, 1000, 0)]
extrude_faces.mesh_selection = selection
#python
import testing
import k3d
from math import pi
document = k3d.new_document()
path = k3d.plugin.create("NurbsCircle", document)
to_sweep = k3d.plugin.create("NurbsCircle", document)
rotate = k3d.plugin.create("RotatePoints", document)
translate = k3d.plugin.create("TranslatePoints", document)
merge_mesh = k3d.plugin.create("MergeMesh", document)
modifier = k3d.plugin.create("NurbsSweepSurface", document)
merge_mesh.create_property("k3d::mesh*", "input_mesh1", "Input Mesh 1", "")
merge_mesh.create_property("k3d::mesh*", "input_mesh2", "Input Mesh 2", "")
rotate.mesh_selection = k3d.geometry.selection.create(1)
translate.mesh_selection = k3d.geometry.selection.create(1)
rotate.x = 0.5*pi
translate.x = 5
#python
import k3d
import testing
document = k3d.new_document()
small_cylinder = k3d.plugin.create("PolyCylinder", document)
small_cylinder.radius = 2.0
small_cylinder.zmax = 7.5
small_cylinder.zmin = -7.5
small_cylinder.u_segments = 8
big_cylinder = k3d.plugin.create("PolyCylinder", document)
big_cylinder.u_segments = 8
torus = k3d.plugin.create("PolyTorus", document)
torus.u_segments = 8
torus.v_segments = 4
first_boolean = k3d.plugin.create("CARVEBoolean", document)
first_boolean.type = "difference"
first_boolean.create_property("k3d::mesh*", "input_1", "Input 1", "")
first_boolean.create_property("k3d::mesh*", "input_2", "Input 2", "")
#python
import k3d
doc = k3d.new_document()
axes = k3d.plugin.create("Axes", doc)
k3d.property.connect(doc, axes.get_property("axes"), axes.get_property("xyplane"));
if doc.get_dependency(axes.get_property("xyplane")).name() != "axes":
raise "xyplane dependency should be axes"
if doc.get_dependency(axes.get_property("yzplane")):
raise "yzplane dependency should be null"
def run_mesh_modifier_benchmark(meshModifierNodeName, benchmarkMesh, numberOfRuns = 1, properties = {}, appendToFile = False, firstInFile=False):
document = k3d.new_document()
profiler = k3d.plugin.create("PipelineProfiler", document)
benchmarkMesh.set_document(document)
inputNode = benchmarkMesh.get_mesh()
selection = k3d.select_all()
benchmarkNode = k3d.plugin.create(meshModifierNodeName, document)
for (p, val) in properties.items():
benchmarkNode.get_property(p).set_value(val)
benchmarkNode.mesh_selection = selection
profilingResults = k3dProfilingProcessor()
#python
import k3d
doc = k3d.new_document()
# Create a simple bicubic patch source ...
source = doc.new_node("Newell")
source.type = "teapot"
# Select some geometry ...
selection = doc.new_node("SelectBicubicPatchByNumber")
selection.index = 0;
doc.set_dependency(selection.get_property("input_mesh"), source.get_property("output_mesh"))
# Run the geometry through a conversion from mesh to legacy-mesh and back ...
convert = doc.new_node("LegacyMeshConversion")
doc.set_dependency(convert.get_property("input_mesh"), selection.get_property("output_mesh"))
# Compare the original to the conversion ...
diff = doc.new_node("MeshDiff")