Export Model#
![]() |
In this example we will demonstrate how to:
|
import os
from math import inf
from dlubal.api import rstab, common
def define_structure() -> list:
"""Define and return a list of structural objects."""
return [
# Define material
rstab.structure_core.Material(
no=1,
name='S235',
),
# Define section
rstab.structure_core.Section(
no=1,
name='HE 300 A',
material=1,
),
# Define nodes
rstab.structure_core.Node(
no=1,
),
rstab.structure_core.Node(
no=2,
coordinate_1=6.0,
),
# Define member
rstab.structure_core.Member(
no=1,
node_start=1,
node_end=2,
section_start=1,
),
# Define nodal support at Node 1 (fully fixed)
rstab.types_for_nodes.NodalSupport(
no=1,
nodes=[1],
spring_x=inf,
spring_y=inf,
spring_z=inf,
rotational_restraint_x=inf,
rotational_restraint_y=inf,
rotational_restraint_z=inf,
),
]
def define_loading() -> list:
"""Define and return a list of loading objects."""
return [
# Static analysis settings
rstab.loading.StaticAnalysisSettings(
no=1,
analysis_type=rstab.loading.StaticAnalysisSettings.ANALYSIS_TYPE_GEOMETRICALLY_LINEAR
),
# Define load cases
rstab.loading.LoadCase(
no=1,
static_analysis_settings=1,
),
rstab.loading.LoadCase(
no=2,
static_analysis_settings=1,
),
# Define nodal loads
rstab.loads.NodalLoad(
no=1,
load_case=1,
nodes=[2],
load_type=rstab.loads.NodalLoad.LOAD_TYPE_COMPONENTS,
components_force_y=5000, # Force in Y direction (N)
components_force_z=10000, # Force in Z direction (N)
),
rstab.loads.MemberLoad(
no=1,
load_case=2,
members=[1],
load_type=rstab.loads.MemberLoad.LOAD_TYPE_FORCE,
magnitude=10000,
),
# Define design situation
rstab.loading.DesignSituation(
no=1,
design_situation_type=rstab.loading.DesignSituation.DESIGN_SITUATION_TYPE_STR_PERMANENT_AND_TRANSIENT_6_10,
),
# Define load combination
rstab.loading.LoadCombination(
no=1,
name='CO1',
items = rstab.loading.LoadCombination.ItemsTable(
rows=[
rstab.loading.LoadCombination.ItemsRow(
load_case=1,
factor=1.35,
),
rstab.loading.LoadCombination.ItemsRow(
load_case=2,
factor=1.5,
)
]
),
design_situation=1,
),
rstab.loading.LoadCombination(
no=2,
name='CO2',
items = rstab.loading.LoadCombination.ItemsTable(
rows=[
rstab.loading.LoadCombination.ItemsRow(
load_case=1,
factor=0.85,
),
rstab.loading.LoadCombination.ItemsRow(
load_case=2,
factor=1.0,
)
]
),
design_situation=1,
),
]
"""Runs the structural analysis example."""
with rstab.Application() as rstab_app:
# Step 1: Create a model
rstab_app.create_model(name='cantilever')
rstab_app.delete_all_objects()
rstab_app.create_object_list(
objs=define_structure() + define_loading()
)
# Step 2: Export the model to Python script
rstab_app.export_to(
filepath=os.path.abspath('./model_export.py'),
export_attributes=common.import_export.PythonGrpcExportAttributes()
)
# Step 3: Export the model to IFC
rstab_app.export_to(
filepath=os.path.abspath('./model_export.ifc'),
export_attributes=common.import_export.IfcExportAttributes()
)
using Rstab = Dlubal.Api.Rstab;
using Common = Dlubal.Api.Common;
using Google.Protobuf.WellKnownTypes;
using Google.Protobuf;
// Returns a list of structural objects to be created.
static List<IMessage> DefineStructure()
{
return new List<IMessage>
{
new Rstab.StructureCore.Material{
Name="S235"
},
new Rstab.StructureCore.Section{
Name="HE 300 A",
Material=1,
},
new Rstab.StructureCore.Node{
No=1,
Coordinate1=0,
},
new Rstab.StructureCore.Node{
No = 2,
Coordinate1 = 6,
},
new Rstab.StructureCore.Member{
No = 1,
Type = Rstab.StructureCore.Member.Types.Type.Beam,
NodeStart = 1,
NodeEnd = 2,
SectionStart = 1
},
new Rstab.TypesForNodes.NodalSupport{
No=1,
SpringX = double.PositiveInfinity,
SpringY = double.PositiveInfinity,
SpringZ = double.PositiveInfinity,
RotationalRestraintX = double.PositiveInfinity,
RotationalRestraintY = double.PositiveInfinity,
RotationalRestraintZ = double.PositiveInfinity,
Nodes = { 1 }
},
};
}
static List<IMessage> DefineLoading()
{
return new List<IMessage>
{
new Rstab.Loading.StaticAnalysisSettings{
No=1,
AnalysisType=Rstab.Loading.StaticAnalysisSettings.Types.AnalysisType.GeometricallyLinear,
},
new Rstab.Loading.LoadCase{
No=1,
StaticAnalysisSettings=1,
},
new Rstab.Loading.LoadCase{
No=2,
StaticAnalysisSettings=1,
},
new Rstab.Loads.NodalLoad{
No=1,
LoadCase=1,
Nodes={2},
LoadType=Rstab.Loads.NodalLoad.Types.LoadType.Components,
ComponentsForceY=5000,
ComponentsForceZ=10000,
},
new Rstab.Loads.MemberLoad{
No=1,
LoadCase=2,
Members={1},
LoadDistribution=Rstab.Loads.MemberLoad.Types.LoadDistribution.Uniform,
LoadType=Rstab.Loads.MemberLoad.Types.LoadType.Force,
Magnitude=10000,
},
new Rstab.Loading.DesignSituation{
No=1,
DesignSituationType=Rstab.Loading.DesignSituation.Types.DesignSituationType.StrPermanentAndTransient610,
},
new Rstab.Loading.LoadCombination{
No=1,
Name = "CO1",
DesignSituation=1,
CombinationRuleStr="1.35*LC1+1.5*LC2",
},
new Rstab.Loading.LoadCombination{
No=2,
Name = "CO2",
DesignSituation=1,
Items=new Rstab.Loading.LoadCombination.Types.ItemsTable{
Rows={
new Rstab.Loading.LoadCombination.Types.ItemsRow{
LoadCase=1,
Factor=0.85,
},
new Rstab.Loading.LoadCombination.Types.ItemsRow{
LoadCase=2,
Factor=1.0,
},
},
},
},
};
}
ApplicationRstab? RstabApp = null;
try
{
RstabApp = new ApplicationRstab();
// Step 1: Create a model
await RstabApp.create_model("Cantilever");
await RstabApp.delete_all_objects();
await RstabApp.create_object_list(DefineStructure());
await RstabApp.create_object_list(DefineLoading());
// Step 2: Export the model to Python script
await RstabApp.export_to(
filepath: Path.GetFullPath("./model_export.py"),
exportAttributes: Any.Pack(new Common.ImportExport.PythonGrpcExportAttributes())
);
// Step 3: Export the model to IFC
await RstabApp.export_to(
filepath: Path.GetFullPath("./model_export.ifc"),
exportAttributes: Any.Pack(new Common.ImportExport.IfcExportAttributes())
);
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
finally
{
if (RstabApp != null) await RstabApp.close_connection();
}