2.8.3: How to Create Structural Models

The detailed account of the equivalent C# example can be found in section 2.3. Here the Python 3 sourcecode and the Grasshopper definition:

from Karamba.Utilities import MessageLogger
from Karamba.Geometry import *
import Karamba.Loads
from System.Collections.Generic import List
from System import String

import KarambaCommon

logger = MessageLogger()
k3d = KarambaCommon.Toolkit()

p0 = Point3(0, 0, 0)
p1 = Point3(0, 0, 5)
L0 = Line3(p0, p1)

bending = True
limitDist = 0.005
elems, nodes = k3d.Part.LineToBeam(L0, "B1", None, logger)

cond = [True, True, True, True, True, True]
support = k3d.Support.Support(0, cond)
supports = [ support ]

pload = k3d.Load.PointLoad(1, Vector3(0, 0, -10), Vector3())
ploads = [ pload ]

# for Karamba3D Version <= 3.1.41119
model, info, mass, cog, info, runtimeWarning = k3d.Model.AssembleModel(
    elems, 
    supports, 
    List[Karamba.Loads.Load](ploads))

# for Karamba3D Version > 3.1.41119
# model, info, mass, cog, info, runtimeWarning = k3d.Model.AssembleModel(
#     elems, 
#     supports, 
#     ploads)    

# for Karamba3D Version <= 3.1.41119
loadCases = List[String](["LC0"])

# for Karamba3D Version > 3.1.41119
# loadCases = ["LC0"]

model_analysed, maxDisp, outForce, outEnergy, Warning = k3d.Algorithms.Analyze(model, loadCases)

ucf = Karamba.Utilities.UnitsConversionFactory.Conv();
cm = ucf.cm();
print(f"max disp: {cm.toUnit(maxDisp[0])}" + cm.unitB);

Model_out = Karamba.GHopper.Models.GH_Model(model_analysed);

Last updated