Replies: 5 comments 5 replies
-
Update: The example I am running works up to the lines: the final line crashes Excel without warning. I also tried setting the default render value to False in plotting context, but it still crashes. |
Beta Was this translation helpful? Give feedback.
-
@DougAJ4 - Maybe I'm reading the python code wrong (have not had time to test the final v2.0 yet), but doesn't the plot stress functions return the fig object anyway, i.e. you don't need the 'fig ='. All the render=False does is not display the matplotlib figure so you can do something else to the figure following this before potentially plotting it or saving it. Try save the figure or do something else with it afterwards to confirm (after removing the If your code works natively in python then I'm probably wrong here. |
Beta Was this translation helpful? Give feedback.
-
Hi Agent666, With all default setting that line displays a white image briefly, then exits to the command line. With render = False it exits without displaying anything. This is Python 3.9.7 running under Windows 10. |
Beta Was this translation helpful? Give feedback.
-
@DougAJ4 I'm not familiar with pyxll, but by the sounds of the original question you want the For example, modify 06_stress.py to: import sectionproperties.pre.library.steel_sections as steel_sections
from sectionproperties.analysis.section import Section
import matplotlib.pyplot as plt
# %%
# Create a 150x100x6 RHS on its side
geometry = steel_sections.rectangular_hollow_section(d=100, b=150, t=6, r_out=15, n_r=8)
# %%
# Create a mesh and section object. For the mesh, use a maximum area of 2
geometry.create_mesh(mesh_sizes=[2])
section = Section(geometry)
# %%
# Perform a geometry and warping analysis
section.calculate_geometric_properties()
section.calculate_warping_properties()
# %%
# Perform a stress analysis with Mx = 5 kN.m; Vx = 10 kN and Mzz = 3 kN.m
case1 = section.calculate_stress(Mxx=5e6, Vx=10e3, Mzz=3e6)
# %%
# Perform a stress analysis with My = 15 kN.m; Vy = 30 kN and Mzz = 1.5 kN.m
case2 = section.calculate_stress(Myy=15e6, Vy=30e3, Mzz=1.5e6)
# %%
# Plot the bending stress for case1
ax = case1.plot_stress_m_zz(render=False)
fig = ax.get_figure()
print(type(fig))
plt.show() Terminal output:
Also with |
Beta Was this translation helpful? Give feedback.
-
I have just edited the heading because it seems the original problem had nothing to do with transferring the plot to Excel. |
Beta Was this translation helpful? Give feedback.
-
Using pyxll to link Python to Excel, I have found all the sectionproperties plot routines cause a crash in Excel.
For the section and mesh plots I was able to avoid this by removing the code lines intended to display the image, and returning the Matplotlib fig object to the calling routine, where it can be displayed in Excel via pyxll.
For the stress plot routine I haven't been able to get this to work. Is there a way to call the plotting routines that will return the fig object, without trying to send the plot to the display?
Beta Was this translation helpful? Give feedback.
All reactions