Comments (9)
Hi @ZTThomasOberthanner,
thank you for thr question. To query the model you start with initializing the connection. This can be done via Model(False, "model_name")
. Then use any getter you need to retrieve the data. Our unit tests (RFEM_Python_Client/UnitTests/) are good examples of setting values and getting them back for checking correctness. But in the tests we use currently available (active) model, that is why you see just Model()
there.
If you want to see all available model functions and types (prefix ns0:), just initialize class Model and then print(Model.clientModel)
. This is the easiest way SUDS module shows everything it recognizes.
I'll add this process to our Wiki.
from rfem_python_client.
Thanks for the quick reply, i did had a look at test_Member_test.py but I could not find any tests for correctness there.
I am now able to get node/member information from the model. But I cannot figure out how to get the internal forces for a member for a certain loadcase/result combination. Would by happy for another hint.
from rfem_python_client.
is it possible to query a list/table of all nodes, members, ...?
suggestion:
get_node() - function with a default None
get_node(xs=None) -> provides the nodes table as (DataFrame or a Dict)
from rfem_python_client.
this is my implementation for fetching all nodes
def get_nodes(self):
numbers=self.service.get_all_object_numbers(type='E_OBJECT_TYPE_NODE')
return [self.service.get_node(n) for n in numbers]
you cannot copy paste that, because this is part of my own python client, but i think you get the idea...
from rfem_python_client.
got it...thank you!!
here is my minimal working example:
from RFEM.initModel import Model, ConvertStrToListOfInt
from RFEM.BasicObjects.node import Node
Model(new_model=True, model_name="extract")
# model modification
Model.clientModel.service.begin_modification()
Node(1, 0.0, 0.0, 0.0)
Node(2, 1.0, 0.0, 0.0)
Node(3, 2.0, 0.0, 0.0)
Model.clientModel.service.finish_modification()
# extract all nodes
numbers = ConvertStrToListOfInt(
Model.clientModel.service.get_all_object_numbers(type="E_OBJECT_TYPE_NODE")
)
node_list = [Model.clientModel.service.get_node(n) for n in numbers]
from rfem_python_client.
Hey, thanks for bringing this up and ideas. I would like to jump back the question and drop here a suggestion. Here is a function to create DataFrame tables for Node objects.
def getNodeTable():
import pandas as pd
nodeTable = pd.DataFrame(columns=["Node No.", "X", "Y", "Z"])
modelStatus = GetModelInfo()
for i in range(1, modelStatus[0] + 1):
nodeTable.loc[i] = [i, Model.clientModel.service.get_node(i)['coordinate_1'],
Model.clientModel.service.get_node(i)['coordinate_2'],
Model.clientModel.service.get_node(i)['coordinate_3']]
return nodeTable
The same logic will work for another objects (lines, members, surfaces etc.).
Maybe this functions can be added to our static methods. Please let me know about your thoughts ✌️
from rfem_python_client.
here is my suggestion for fetching tables into a pandas dataframe:
import pandas as pd
import numpy as np
from RFEM.initModel import Model, ConvertStrToListOfInt
from RFEM.BasicObjects.node import Node
from RFEM.BasicObjects.material import Material
from RFEM.BasicObjects.section import Section
def load_object(clientModel, type="NODE"):
numbers = ConvertStrToListOfInt(
clientModel.service.get_all_object_numbers(
type="E_OBJECT_TYPE_{}".format(type.upper())
)
)
if type.upper() == "NODE":
return [Model.clientModel.service.get_node(int(n)) for n in numbers]
else:
# todo object types
pass
def load_dataframe(clientModel, type="NODE"):
nodes_list = load_object(clientModel, type)
len_numbers = len(nodes_list)
keys = dict(nodes_list[0]).keys()
dataframe = pd.DataFrame(columns=keys, index=range(len_numbers), dtype=object)
for i, node in enumerate(nodes_list):
node_dict = dict(node)
values = node_dict.values()
dataframe.iloc[i] = np.array([value for value in values], dtype=object)
return dataframe
Model(new_model=True, model_name="extract_dataframe")
# model modification
Model.clientModel.service.begin_modification()
Node(1, 0.0, 0.0, 0.0)
Node(2, 1.0, 0.0, 0.0)
Node(3, 2.0, 0.0, 0.0)
Model.clientModel.service.finish_modification()
# load dataframe
df = load_dataframe(Model.clientModel, type="NODE")
print(df)
from rfem_python_client.
just a reminder:
clientModel.service.get_all_object_numbers already returns a list of int - so no need for ConvertStrToListOfInt...
numbers = ConvertStrToListOfInt(
clientModel.service.get_all_object_numbers(
type="E_OBJECT_TYPE_{}".format(type.upper())
)
)
from rfem_python_client.
Since everyone has a solution, this issue will be closed 😃 Thanks for contribution.
from rfem_python_client.
Related Issues (20)
- BUG: Add psutil to dependencies in setup.py HOT 2
- BUG: Can't Update Global Parameter when Results are available HOT 3
- BUG: ResultTables.NodesSupportForces fails in ConvertResultsToListOfDct HOT 5
- BUG: Structure Modification not yet assignable to loadcombination or resultcombination HOT 1
- BUG: TableExportConfigManager Updated but not used when exporting HOT 6
- BUG: specialObjects → modify_stiffnesses_sections HOT 2
- REQUEST: Set Standards for Addons (e.g. dynamic analysis) HOT 4
- REQUEST: Possibility to edit timber design fire configuration HOT 2
- BUG: Missing definition of modelLst in init.Model.py HOT 1
- BUG: Angle of Layers and Stiffness Reduction are ignored in Multilayer Thicknesses HOT 1
- BUG: SUDS.TypeNotFound: Type not found: 'line' HOT 2
- BUG: Accessing SpectralAnalysisMembersInternalForces for different Envelopes not possible HOT 7
- QUESTION: Clarification on Excessive Results for Member Internal Forces Retrieval HOT 8
- BUG: Function CentreOfGravity HOT 1
- BUG: Failure to connect to server HOT 1
- BUG: LineSetLoad.Force() for "LOAD_DISTRIBUTION_VARYING" error handling issue HOT 2
- REQUEST: Remote access to Webservice
- BUG: Unity for MembersContactForces
- BUG: Excessive Node results HOT 1
- BUG: Unable to Connect to Existing Model Twice. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rfem_python_client.