Closed gpwood closed 3 months ago
Hi @gpwood ,
What kind of objects do you have? k3d.mesh? k3d.marching_cubes? Can you share a small code snippet with example data to recreate it on my machine?
Hi @artur-trzesiok
This example is from the online documentation and gives 6 objects. One use case I have is to merge two or more of the plot objects together so it appears as only one object in the panel display. So for example, For each level below merge plt_heart and plt_torus together so you have 3 objects in the dropdown menu
import k3d
import numpy as np
t = np.linspace(-1.5, 1.5, 50, dtype=np.float32)
x, y, z = np.meshgrid(t, t, t, indexing='ij')
R = 1
r = 0.5
eq_heart = (x**2 + (9/4 * y**2) + z**2 - 1)**3 - (x**2 * z**3) - (9/200 * y**2 * z**3)
eq_torus = (x**2 + y**2 + z**2 + R**2 - r**2)**2 - 4 * R**2 * (x**2 + y**2)
plot = k3d.plot()
for i in range(3):
level = 0 + i * 1.5
plt_heart = k3d.marching_cubes(eq_heart, level=level,
color=0xe31b23,
xmin=-1.5, xmax=1.5,
ymin=-1.5, ymax=1.5,
zmin=-1.5, zmax=1.5,
translation=[i * 3.5, 0, 0])
plt_torus = k3d.marching_cubes(eq_torus, level=level,
color=0x5aabac,
xmin=-1.5, xmax=1.5,
ymin=-1.5, ymax=1.5,
zmin=-1.5, zmax=1.5,
translation=[i * 3.5, 0, -3.5])
plot += plt_heart
plot += plt_torus
plot.display()
Hi @gpwood !
Sorry for long delay with my response. We have something very simplified - one level of hierarchy in k3d. It's called "groups:
plt_heart = k3d.marching_cubes(eq_heart, level=level,
color=0xe31b23,
xmin=-1.5, xmax=1.5,
ymin=-1.5, ymax=1.5,
zmin=-1.5, zmax=1.5,
translation=[i * 3.5, 0, 0], group='heart', name='Heart {}'.format(i+1))
plt_torus = k3d.marching_cubes(eq_torus, level=level,
color=0x5aabac,
xmin=-1.5, xmax=1.5,
ymin=-1.5, ymax=1.5,
zmin=-1.5, zmax=1.5,
translation=[i * 3.5, 0, -3.5], group='torus', name='Torus {}'.format(i+1))
If you will add group parameter to objects they will be merged in panel:
But still you will have control over each object:
Is it usefull for you?
Hello,
I have a use case where plot objects exist in two parts (one a negative one positive). I'd like to "merge" each part into a single object so it appears as one item in the "objects" panel (rather than two). Is this possible?
So an example of this would be to take the six plots here: https://k3d-jupyter.org/reference/factory.marching_cubes.html#levels and merge all the hearts into one object and all the toruses into another, so that in the panel it displays only two objects rather than 6.