Our homepage and quickstart page is hosted on readthedocs.
Our github page can be found here.
Releases are hosted on PyPi.
Wrap up VTK (python 3D graphics library) into an easy to use 3D equivalent of matplotlib
License: MIT License
Our homepage and quickstart page is hosted on readthedocs.
Our github page can be found here.
Releases are hosted on PyPi.
Hello,
Is there maybe a way to improve the overall renderer performance for handling lot of actors within a vpl.QtFigure2.
Below i attached some images as an example. In the first image you see a model i want to prepare for 3d metal printing.
For the preparation i need to attach support structures and i visualised these support structures by plotting each of them with the vpl.mesh_plot function. For sure i could concatenate the support structures to one mesh, but i want to have the opportunity to manually delete and add support structures before combining them to one mesh.
There are about 2500 actors within the figure and i got the issue that it starts lagging while handling these amount of actors.
Best regards,
Marcel
I am using Ubuntu 18.04 to run an application, which takes screenshots of a mesh. I am using Nvidia Quadro P5000 GPU with nvidia 435 proprietary driver (I also tried with with Nouveau driver which gives the same issue).
Have you encountered this before, or aware of what causes the problem? The application runs fine on windows servers, and has been tested extensively, but gives this problem in Ubuntu.
I'm trying to get an isometric view of an stl and save it to an image. Is there any way to orient the mesh to see all 3 planes? Any examples of how to use image_io.write to save a vpl.mesh_plot to a png or jpg?
Im trying to display the coordinates I clicked on in the bottom left corner.
I used the OnClick function to put the current coordinates as 2d text on the plot.
The issue is, that when I click again the next coordinates get written ontop of the others. Is there a way to delete the old coordinates?
Hi!,
I am starting to use vtkplotlib for plotting STL files in a Programming subject in the first year of a Mechanical Engineering degree because it is super-simple and nice to use!!. But non interactive visualization seems to be not working (window never opens). Wouldn't these sentences be enough?
...
vpl.mesh_plot(some_mesh)
vpl.gcf().update()
vpl.show(block=False)
...
Regards,
Jose.
Btw, great library!
I was not able to save a 3D mesh into a 2D PNG with transparent background. Tried:
vpl.gcf() is fig
vpl.mesh_plot(mesh)
fig.background_color = [0, 0., 0., 0.]
vpl.save_fig('fig.png', magnification=1, off_screen=True)
Did I miss something?
Thanks.
I am trying to display a mesh and "highlight" a part of the mesh in a different color.
The highlighted part of the mesh has been anotated as a separate STL file.
When I run the following code,
import vtkplotlib as vpl
from stl.mesh import Mesh
# path = "if you have an STL file then put it's path here."
# Otherwise vtkplotlib comes with a small STL file for demos/testing.
path = vpl.data.get_rabbit_stl()
# Read the STL using numpy-stl
mesh = Mesh.from_file(path)
mesh2 = Mesh.from_file(r"\path\to\part_of_stl.stl")
# Plot the mesh
vpl.mesh_plot(mesh)
vpl.mesh_plot(mesh2, color="orange")
# Show the figure
vpl.show()
it produces the result captured in this screenshot
I understand that VTK tries to display both meshes on top of each other and since they have the same coordinates there is a display artefact.
How would you implement a method to avoid such problems?
Many thanks
Additionnal info
Python: 3.7.0
vtkplotlib : 1.4.0
VTK : 9.0.1
numpy : 1.19.5
I use anaconda but I installed vtkplotlib with pip
Tested on Windows 10
If you want to reporduce the bug, the file part_of_stl.stl is the following :
https://github.com/redoules/vtkplotlib/raw/master/part_of_stl.stl
Are there any method to add stl display to tkinter window?
I need to display images (2D) as 3D objects. My idea was to use the images as textures for simple rectangles consisting of two triangles each.
I tried to use plain vtkPolyData for that as suggested .
I used the following code to test the basic idea:
import skimage as ski
import numpy as np
import vtkplotlib as vpl
image = ski.io.imread("image_AP.png") # uint8 gray scale image
rgb_image = ski.color.gray2rgb(image)
texmap = vpl.colors.TextureMap(rgb_image, interpolate=True)
image_PolyData = vpl.PolyData()
# four vertices forming a square
image_PolyData.points = np.array([
[0.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[1.0, 1.0, 0.0],
[1.0, 0.0, 0.0]], dtype=float)
# rectangle consisting of two triangles
image_PolyData.polygons = np.array([
[0, 1, 3],
[1, 2, 3]])
image_PolyData.texture_map = texmap
# UV coordinates for the four vertices
image_PolyData.point_colors = np.array([
[0.0, 0.0],
[0.0, 1.0],
[1.0, 1.0],
[1.0, 0.0]])
image_PolyData.quick_show()
This works, in principle, however it seems that pixels in between the vertices are simply interpolated between the vertices instead of using the actual texture information.
Is this by design or a bug? Is it possible to actually map the texture onto the polydata faces?
Steps to reproduce:
pipenv install
to create a pipenvpipenv install '-e .[test]'
to get pipenv to create an environment with required dependenciesResult:
ModuleNotFoundError: No module named 'sys.version_info'; 'sys' is not a package
Excuse me, I'm new to setup.py and I might be missing something here. Any suggestions on what extra I could do to easily make a pipenv environment capable of running the unit tests in this repo?
Hey,
first i have to say thank you for this library. It is working really good and easy to use. Now my issue:
Is there any easy to user opportunity to implement something like an object manipulation (only translation) with draggable arrows for an object? So in case of clicking on an object, these arrows will appear around the model and i can move it along either the x, y or z axis.
Hi! I am currently working on a 3D to 2D ASCII art plotter and am using your library for it. You can read more information about that here:
https://github.com/TheRealVira/asciisight
Anyways... The rotation seems to be a bit broken and I am just very confused as of why. Another solution would have been to rotate the figure itself, but I don't seem to find any function for that inside your API. Feedback would be very appreciated π
Looking forward to hearing from you!
estoy trabajando en n simulador de robot de 6gdl pero no logro que los movimientos sean fluidos
que es lo que estoy haciendo mal ????
import vtkplotlib as vpl
from stl.mesh import Mesh
import numpy as np
import math
global a
global b
global c
global d
global e
global f
def ZWOL_2_Pose(xyzrpw):
[x,y,z,r,p,w] = xyzrpw
a = r*np.pi/180.0
b = p*np.pi/180.0
c = w*np.pi/180.0
ca = np.cos(a)
sa = np.sin(a)
cb = np.cos(b)
sb = np.sin(b)
cc = np.cos(c)
sc = np.sin(c)
return np.array([[cb*ca, ca*sc*sb - cc*sa, sc*sa + cc*ca*sb, x],[cb*sa, cc*ca + sc*sb*sa, cc*sb*sa - ca*sc, y],[-sb, cb*sc, cc*cb, z],[0.0,0.0,0.0,1.0]])
mesh = Mesh.from_file("base.stl")
mesh2 = Mesh.from_file(r"J1_.stl")
mesh3 = Mesh.from_file(r"J2_.stl")
mesh4 = Mesh.from_file(r"J3_.stl")
mesh5 = Mesh.from_file(r"J4_.stl")
mesh6 = Mesh.from_file(r"J5_.stl")
mesh7 = Mesh.from_file(r"J6_.stl")
TITA = 0,-40,30,-50,30,0
pos = (0,0,0,TITA[0],0,0)
pos = ZWOL_2_Pose(pos)
mesh2.transform(pos)
pos1 = (0,0,376.21,0,TITA[1],0)
pos1 = ZWOL_2_Pose(pos1)
pos2 = np.dot(pos,pos1)
mesh3.transform(pos2)
pos3 = (0,0,400,0,TITA[2],0)
pos3 = ZWOL_2_Pose(pos3)
pos3 = np.dot(pos2,pos3)
mesh4.transform(pos3)
pos5 = (218,0,50.78,0,0,TITA[3])
pos5 = ZWOL_2_Pose(pos5)
pos5 = np.dot(pos3,pos5)
mesh5.transform(pos5)
pos6 = (187,0,0,0,TITA[4],0)
pos6 = ZWOL_2_Pose(pos6)
pos6 = np.dot(pos5,pos6)
mesh6.transform(pos6)
pos7 = (89.55,0,0,TITA[5],0,0)
pos7 = ZWOL_2_Pose(pos7)
pos7 = np.dot(pos6,pos7)
mesh7.transform(pos7)
vpl.mesh_plot(mesh, color="lightblue")
a=vpl.mesh_plot(mesh2, color="lightblue")
b=vpl.mesh_plot(mesh3, color="lightblue")
c=vpl.mesh_plot(mesh4, color="lightblue")
d=vpl.mesh_plot(mesh5, color="lightblue")
e=vpl.mesh_plot(mesh6, color="lightblue")
f=vpl.mesh_plot(mesh7, color="lightblue")
figure = vpl.gcf()
figure.update()
figure = vpl.gcf()
figure.update()
figure.camera.Yaw(45)
figure.camera.Pitch(35)
figure.camera.Roll(-45)
figure.reset_camera()
figure.update()
#time.sleep(2)
def inicio():
global a
global b
global c
global d
global e
global f
def imprimo(ss):
global A
global B
global C
global D
global E
global F
figure = vpl.gcf()
figure.update()
try:
figure.remove_plot(A)
figure.remove_plot(B)
figure.remove_plot(C)
figure.remove_plot(D)
figure.remove_plot(E)
figure.remove_plot(F)
except:
pass
#print('remuevo')
figure.remove_plot(a)
figure.remove_plot(b)
figure.remove_plot(c)
figure.remove_plot(d)
figure.remove_plot(e)
figure.remove_plot(f)
W = vpl.mesh_plot(mesh, color="lightblue")
A = vpl.mesh_plot(ss[0], color="lightblue")
B = vpl.mesh_plot(ss[1], color="lightblue")
C = vpl.mesh_plot(ss[2], color="lightblue")
D = vpl.mesh_plot(ss[3], color="lightblue")
E = vpl.mesh_plot(ss[4], color="lightblue")
F = vpl.mesh_plot(ss[5], color="lightblue")#vpl.mesh_plot(ss[5], color="lightblue")
def Robot(TITA):
mesh = Mesh.from_file("base.stl")
mesh2 = Mesh.from_file(r"J1_.stl")
mesh3 = Mesh.from_file(r"J2_.stl")
mesh4 = Mesh.from_file(r"J3_.stl")
mesh5 = Mesh.from_file(r"J4_.stl")
mesh6 = Mesh.from_file(r"J5_.stl")
mesh7 = Mesh.from_file(r"J6_.stl")
pos = (0,0,0,TITA[0],0,0)
pos = ZWOL_2_Pose(pos)
mesh2.transform(pos)
pos1 = (0,0,376.21,0,TITA[1],0)
pos1 = ZWOL_2_Pose(pos1)
pos2 = np.dot(pos,pos1)
mesh3.transform(pos2)
pos3 = (0,0,400,0,TITA[2],0)
pos3 = ZWOL_2_Pose(pos3)
pos3 = np.dot(pos2,pos3)
mesh4.transform(pos3)
pos5 = (218,0,50.78,0,0,TITA[3])
pos5 = ZWOL_2_Pose(pos5)
pos5 = np.dot(pos3,pos5)
mesh5.transform(pos5)
pos6 = (187,0,0,0,TITA[4],0)
pos6 = ZWOL_2_Pose(pos6)
pos6 = np.dot(pos5,pos6)
mesh6.transform(pos6)
pos7 = (89.55,0,0,TITA[5],0,0)
pos7 = ZWOL_2_Pose(pos7)
pos7 = np.dot(pos6,pos7)
mesh7.transform(pos7)
Angulos = mesh2,mesh3,mesh4,mesh5,mesh6,mesh7
return Angulos
TITA = 0,-40,30,-50,30,0
#i=0
i = 0
while i <(10):
i +=0.5)
TITA = i,-40,30,-50,30,0
ss=Robot(TITA)
imprimo(ss)
for i in range(10):
#i=i+1
TITA = 10,-40+i,30,-50,30,0
ss=Robot(TITA)
imprimo(ss)
for i in range(10):
#i=i+1
TITA = 10,-30,30-i,-50,30,0
ss=Robot(TITA)
imprimo(ss)
for i in range(50+1):
#i=i+1
TITA = 10,-30,20,-50+i,30,0
ss=Robot(TITA)
imprimo(ss)
inicio()
# Show the figure
vpl.show()
Hi and thank you for your great codes!
Can you tell me how can I save the rendered stl data into image files and set the camera position with some example codes?
Thankyou π
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.