Get started
Last updated
Last updated
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.
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"
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
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;
}
}
}