Ask Your Question
1

How to ignore pssplot's error message

asked 2022-05-07 21:52:20 -0500

sugui_ gravatar image

Hello everyone, I want to create .jpg file automatically using python, this is my code:

for i in range(0,10):
filename = "case" + str(i+1)
pssplot.openchandatafile(path+filename+""".out""")

pssplot.dragdropplotdata(filename,r"""2 - ANGL   11[GEN#1      22.000]1""")
pssplot.dragdropplotdata(filename,r"""3 - ANGL   21[GEN#2    16.500]1""")
pssplot.dragdropplotdata(filename,r"""4 - ANGL   31[GEN#3      16.500]1""")

pssplot.exportplot(path+filename+"""-A.jpg""",3)
pssplot.deleteselplot()
pssplot.insertplot()

When running this code, sometimes an error message(Axis Maximum Value must be >= Minimum) will come out and I need to skip the case manually. Is there any way to ignore this error message and the code still running well?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2023-10-10 17:23:02 -0500

Enclosing the statement with a Try Catch block should solve this issue, but you need to only enclose the lines that cause the issue and then find an appropriate way for the rest of your code to work with the fact that you are now "skipping" these codes when they have errors

try:
   # enter problematic code here
except:
   # enter the code of what to do when the issue happens here 
   #(maybe a "warning" print, or assign dummy values to the variables)

Hope this solves your issue

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

1 follower

Stats

Asked: 2022-05-07 21:52:20 -0500

Seen: 1,478 times

Last updated: Oct 10 '23