Hello folks
I am creating a gui-enabled script using Pyside2. My goal is to change the line length. The user will select the line to modify and enter the length.
Selected_Line = self.Lines_QComboBox.currentText() #select the line Line_Length = float(self.Min_Line_Length_QLine_Edit.text()) #enter the length. g_i.Selected_Line.Second.y.set(Line_Length) #change the length of the line
However I'm getting "AttributeError: Requested attribute 'Selected_Line' is not present".
In order to overcome this issue, I used the eval function.
Selected_Line = self.Lines_QComboBox.currentText() #select the line Line_Length = float(self.Min_Line_Length_QLine_Edit.text()) #enter the length. eval("g_i.%s.Second.y.set(Line_Length)"% (Selected_Line) #change the length of the line
Is there any alternative to overcome this problem without using eval function?
Thank you
I am glad!
Dear Stefanos
In order to keep my question simple, I did not want to add the all code. Even if my question is not clear, your answer gets the point across and solves my problem.
Thank you so much
Dear John,
The Selected_Line is a variable you introduce so I do not expect it to exist on the g_i, which is the variable that defines the PLAXIS API server.
Unfortunately, the part of the code that you share is not enough for me to fully understand what you do and how you do it.
In general, if you refer to a PLAXIS object, e.g. Line_1, then you need to specify it as: g_i.Line_1. But if you define a variable as follows:selected_line = g_i.Line_1
then, you can simply run:selected_line.Second.y = line_length
Answer Verified By: John