I’m trying to use Karamba from Rhino’s Python3 editor (so not through GH). I was trying to use the ModelCreation example from the Karamba Scripting Guide, https://scripting-1-3.karamba3d.com/v/english_1_3_3/2.-scripting/2.3-how-to-create-structural-models, and convert it to Python3. Should I still use the KarambaCommon.Toolkit? The below does not work. Thank you for your help!
ModelCreation_Python3.py (1.3 KB)
#! python3
import Karamba
import KarambaCommon
from System.Collections.Generic import List, Dictionary, IReadOnlyListdef RunScript():
logger = Karamba.Utilities.MessageLogger()
k3d = KarambaCommon.Toolkit()p0 = Karamba.Geometry.Point3(0, 0, 0) p1 = Karamba.Geometry.Point3(0, 0, 5) L0 = Karamba.Geometry.Line3(p0, p1) nodes = List[Karamba.Geometry.Point3]() elems = k3d.Part.LineToBeam(List[Karamba.Geometry.Line3]([L0]), List[str](["B1"]), List[Karamba.CrossSections.CroSec](), logger, nodes) cond = List[bool]([True, True, True, True, True, True]) support = k3d.Support.Support(0, cond) supports = List[Karamba.Supports.Support]([support]) pload = k3d.Load.PointLoad(1, Karamba.Geometry.Vector3(0, 0, -10), Karamba.Geometry.Vector3()) ploads = List[Karamba.Loads.Load]([pload]) mass = None cog = Karamba.Geometry.Point3() flag = None info = "" model = k3d.Model.AssembleModel(elems, supports, ploads, info, mass, cog, info, flag) # calculate Th.I response max_disp = List[float]() out_g = List[float]() out_comp = List[float]() message = "" model = k3d.Algorithms.AnalyzeThI(model, max_disp, out_g, out_comp, message) ucf = Karamba.Utilities.UnitsConversionFactories.Conv() cm = ucf.cm() print("max disp: " + cm.toUnit(max_disp[0]) + cm.unitB)
RunScript()