how to generate easy to share 3d plots?
You use plotly. This is a test and it needs improvement but the script below generates a 3D plot and saves it to an html.
from ansys.dpf import core as dpf import numpy as np import plotly import plotly.graph_objects as go import plotly.io as pio pio.renderers.default='browser' myModel = r'set to a small .rst file for testing' ############### # create dpf's datasource ds= dpf.DataSources(myModel) # Get all time points # Extract model from RST model=dpf.Model(data_sources=ds) rst_mesh=model.metadata.meshed_region disp = model.results.displacement().outputs.fields_container()[0] dispX = np.array(disp.data)[:,0] dispXNorm = dispX/np.linalg.norm(dispX) # Get node ids and coordinates from mesh node_ids = rst_mesh.nodes.scoping.ids node_coords = rst_mesh.nodes.coordinates_field node_coords_list = np.array(node_coords.data)#_as_list x = node_coords_list[:,0] y = node_coords_list[:,1] z = node_coords_list[:,2] fig = go.Figure(data=[go.Mesh3d(x=x, y=y, z=z, alphahull=5, opacity=1, intensity=dispXNorm, colorscale='rainbow')]) fig.show() plotly.offline.plot(fig, filename='D:\myPlot.html')
Have to work on the coloring though....
Tagged:
0
Answers
-
For PyDPF, another possibility is to use the gltf plugin:
4