Lama
  • LayerManager
  • Fundamentals
    • 📖Main concepts
      • LamaBase
      • LamaData
        • LamaTables
        • LamaCategories
        • LamaView
      • LamaFile
      • LamaDoc
    • 🖥️UI overview
    • 📐Principles
    • ➕LamaExtensions
  • User Manual
    • 🚀Get started
    • 💡How to...
      • General
        • Start/ Stop Lama
        • Create Models/Projects
        • Create templates
        • Connect LamaProject
        • Save LamaFile
        • Version recovery
        • Add a license
      • Management
        • Vert./horiz. panel
        • Create elements
        • Create LamaTables
        • Create attributes
        • Create categories
        • Use table trees
        • Use multiple columns
        • Use object relations
      • Visualization
        • Activate layers
        • Show layers
      • Analysis
        • Create view
        • Modify view
        • Create validation rule
        • Use views
      • Transfer
        • LamaTables
        • LamaView
    • 📄Commands
  • Developer Manual
    • 🚀Get started
    • 💡How to...
      • Install plugin
      • Install toolbar
      • Publish plugin
    • 📑Resources
    • 🔗Compatibility
  • Feedback
  • Apps by Fritz Beck.
Powered by GitBook
On this page
  1. Developer Manual

Get started

Last updated 1 year ago

Prerequisites: Windows; Visual Studio; Rhino 7;

Make sure that the Rhino-Plugin Lama is running and you have loaded a LamaFile with a valid LamaLicense.

Step 1: Create project

Open Visual Studio -> Click "Create a new project" -> -> Search for RhinoCommon -> Select RhinoCommon Plug-In for Rhino 3D (C#) ->

-> Enter a project name and select location -> Click "Create" ->

-> Use standard setting (or customize) -> Click "Finish"

Step 2: Install LayerManager

1) Update RhinoCommon version

Right click on RhinoCommon -> Update ->

-> Search for "RhinoCommon" -> Select Version (see here) -> Update

2) Install LayerManager NuGet-package

Solution Explorer -> Right click on "Packages" -> Click "Manage NuGet Packages" ->

-> Select "Browse" -> Search "LayerManager" ->

-> Scroll down (potentially) -> Select LayerManager -> Click "Install"

3) If not yet set, update C# to version 9.0 or higher

Double click on project -> Update LangVersion

Step 3: Insert code

Replace code in MyFirstLamaCommand:

using Rhino;
using Rhino.Commands;
using Rhino.Geometry;
using Rhino.Input;
using Rhino.Input.Custom;
using LayerManager.Base;
using LayerManager.Data;
using LayerManager.Parser;
using System;
using System.Collections.Generic;

namespace MyFirstLamaPlugIn
{
    public class MyFirstLamaCommand : Command
    {
        public MyFirstLamaCommand()
        {
            // Rhino only creates one instance of each command class defined in a
            // plug-in, so it is safe to store a refence in a static property.
            Instance = this;
        }

        ///<summary>The only instance of this command.</summary>
        public static MyFirstLamaCommand Instance { get; private set; }

        ///<returns>The command name as it appears on the Rhino command line.</returns>
        public override string EnglishName => "CreateLamaTables";

        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            // Get LamaBase
            LamaMainParser lmMainParser = new LamaMainParser();
            LamaBase lmBase = lmMainParser.ReadLama();
            if (lmBase == null)
            {
                RhinoApp.WriteLine("Lama could not be read.");
                return Result.Failure;
            }

            // Create LamaModel
            LamaModel lmModel = lmBase.NewLamaModel();
            lmModel.Name = "MyLamaModel";
            lmBase.Models.Add(lmModel);

            // Create LamaProject
            LamaProject lmProject = lmModel.NewLamaProject();
            lmProject.Name = "MyLamaProject";
            lmModel.Projects.Add(lmProject);

            // Write LamaModel and LamaProject to LamaFile
            lmMainParser.WriteLama(lmBase);

            // Create LamaData
            LamaData lmData = lmProject.NewLamaData();

            // Create Categories
            LamaCategory catGeneral = new LamaCategory("General");
            lmData.LamaCategories.Add(catGeneral);

            // Create Tables      
            DropdownTable tableComponent = new DropdownTable("Component");
            tableComponent.AddLayerRow("ComponentA");
            tableComponent.AddLayerRow("ComponentB");
            tableComponent.AddLayerRow("ComponentC");
            lmData.LamaTables.Add(tableComponent);

            BoolTable tableBearing = new BoolTable("Bearing");
            lmData.LamaTables.Add(tableBearing);

            NumberTable tableThickness = new NumberTable("Thickness");
            lmData.LamaTables.Add(tableThickness);

            TextTable tableCode = new TextTable("Code");
            lmData.LamaTables.Add(tableCode);

            RhinoElementTable tableWall = new("Wall");
            tableWall.AddClassColumn(tableCode, catGeneral, false);
            tableWall.AddClassColumn(tableThickness, catGeneral, false);
            tableWall.AddClassColumn(tableComponent, catGeneral, false);
            tableWall.AddClassColumn(tableBearing, catGeneral, false);
            lmData.LamaTables.Add(tableWall);

            // Write LamaData to LamaFile
            lmMainParser.WriteLamaData(lmData);

            // Start message
            RhinoApp.WriteLine("LamaTables created.");

            return Result.Success;
        }
    }
}
Step 4: Run the plugin

Click on ">[YourProjectName]" or Press "F5" (Debugging) ->

-> Rhino opens -> PlugIn is loaded automatically ->

-> Enter your command "CreateLamaTables"

Result

In the LamaManager (Lama -> Manage), a new LamaModel and a new LamaProject were created.

Set the LamaProject as active (Right click -> Set active).

Now you can modify your LamaTables using the Rhino-PlugIn Lama!

🚀
RhinoCommon templates for VS