Set Karamba BasicDisplay properties through C#

Hi,

I am trying to set the karamba display properties by C# in visual studio, however the field displayDisp of Karamba.Models.BasicDisplay is missing in KarambaCommon.2.2.0.142. While the online API of KarambaCommon 1.3.3 shows the property [BasicDisplay Class (karamba3d.com)]
Is there a other way to reach this property? See images for clarification.

image

Thanks, Max

I try to play around with the properties, however:

  1. Karamba.Models.ModelResult.CollectElement1DCrossSectionForces(model, meshesKaramba, curvesKaramba) method returns no results.
  2. Karamba.Models.ModelResult.CollectCroSecForceOutput_OLD(model, meshesKaramba, curvesKaramba) method returns straight lines, which does not correspond with the numerical results of the Karamba.Results.BeamForces.solve() method.

Am I missing something?

At the moment I have the following code:

public void DisplayModel(out List<Polyline> curves, out List<Mesh> meshes)
        {
            Model model = this.Model_0;

            // Build and clone model 
            model.buildFEModel();  
            model.deepCloneFEModel();
            model = model.Clone();
            model.fe2model(); 
            
            // Model properties
            model.dp = (Karamba.Models.ModelDisplay)model.dp.Clone();

            List<PolyLine3> curvesKaramba = new List<PolyLine3>();
            List<IMesh> meshesKaramba = new List<IMesh>();

            // Display properties Basic ??
            Karamba.Models.BasicDisplay display = new Karamba.Models.BasicDisplay();
            display.DisplayLoads = true;
            display.DisplaySupports = true;
            display.DisplayElementsID = true;
            display.DisplayLocalAxes = true;

            //  Set display properties
            model.dp.basic = display;

            // Display properties for beams
            Karamba.Models.BeamDisplay beamDisplay = new Karamba.Models.BeamDisplay();
            beamDisplay.DisplayCrossSectionForceNumbers = true;
            beamDisplay.displayCroSecForces = new bool[] { true, true, true, true, true, true };
            beamDisplay.fillCSF = true; // make the cross section forces diagram filled
            model.dp.beam = beamDisplay;

            // Add meshes and curves of Forces [2] and [4]
            Karamba.Models.ModelResult.CollectElement1DCrossSectionForces(model, meshesKaramba, curvesKaramba);
            //Karamba.Models.ModelResult.CollectCroSecForceOutput_OLD(model, meshesKaramba, curvesKaramba); // Shows straight lines??

            Rhino.RhinoApp.WriteLine("Curves: " + curvesKaramba.Count.ToString());
            Rhino.RhinoApp.WriteLine("Meshes: " + meshesKaramba.Count.ToString());

            List<Mesh> meshesOut = new List<Mesh>();
            meshesKaramba.ForEach(t =>
            {   
                Mesh mesh = new Mesh();
                Rhino.RhinoApp.WriteLine("Vertices: " + t.Vertices.Count.ToString());
                Rhino.RhinoApp.WriteLine("Faces: " + t.Faces.Count.ToString());
                mesh.Vertices.AddVertices(t.Vertices.Select(v => new Point3d(v.X, v.Y, v.Z)));
                for (int i = 0; i < t.Faces.Count; i++)
                {
                    if (t.Faces[i].IsQuad)
                        mesh.Faces.AddFace(new MeshFace(t.Faces[i].A, t.Faces[i].B, t.Faces[i].C, t.Faces[i].D));
                    else
                        mesh.Faces.AddFace(new MeshFace(t.Faces[i].A, t.Faces[i].B, t.Faces[i].C));
                }
                meshesOut.Add(mesh);
            });

            curves = curvesKaramba.Select(t => new Polyline(t.Points.Select(p => new Point3d(p.X, p.Y, p.Z)))).ToList();
            meshes = meshesOut;
        }

Hi @maxhamelynck,
if “karamba.Models.BasicDisplay.DisplacementScale =! 0” then displacements will be plotted, otherwise not.
Thanks for the hint regarding the API documentation! I will update it in the coming days.
– Clemens

Did you calculate the model before retrieving results? I think the tests here could help you further.
– Clemens