Writing tabular data of force result item to list (CPython)
I have a script that writes tabular data to a list that works in IronPython. I am trying to convert the script to CPython in order to do some post processing with numpy and pandas. I am getting an AttributeError message. Is there a way to do this in CPython?
data = [] del data[:] force = Tree.FirstActiveObject force.Activate() Pane=ExtAPI.UserInterface.GetPane(MechanicalPanelEnum.TabularData) Con = Pane.ControlUnknown for R in range(1,Con.RowsCount+1): data.append([]) for C in range(2,Con.ColumnsCount+1): print(Con.cell(R,C).Text) data[-1].append(Con.Cell(R,C).Text)
Traceback (most recent call):
File "Mechanical Scripting Editor", line 31, in
AttributeError : '__ComObject' object has no attribute 'ControlUnknown'
Best Answer
-
I am not sure about the error message you get in C-Python, but I am curious to know why you are reading the table control directly vs. looking into the field data of the Force object. The table should be representing the data stored in various components of the object like 'Force.XComponent'. These "components" are fields that have inputs and outputs. In most cases the inputs are time and the outputs are the values of force (or whatever is appropriate for that load).
Perhaps you can bypass the need for reading the table itself and get the data from the object in question directly?
In addition to this, if you cannot get C-Python working and you really want exactly what the table control says in the UI, you could use your IronPython script to write the data to a file, then parse the same file with C-Python.
1
Answers
-
This script is not originally mine but I found it somewhere. Only upside (that I see) of this script compared to what you propose is with this script there is no need to change DisplayTime and evaluate results if you have many load or substeps you want to export results from. But I think your suggestion is the way to go here.
0 -
The GetPane method is not officially supported. The reason is it doesn't work in linux and likely not in cypthon.
0