Sorry about that. That was a silly mistake by me. It does however not fix the underlining issue with my other component. The one I made for myself, is a small par of a bigger mor complex setup, but is fundamentally just the text part for this. Witch is why I need to figure this out.
Here is the code in the component and linked modules:
public class Comp2DText : GH_Component
{
public Comp2DText()
: base("Lag tekst på plan",
"I-tekst",
"Skriver tekst inputt på plassering",
"Ilder",
"A. Ilder verktøy")
{ }
protected override System.Drawing.Bitmap Icon => Icons.IlderText;
public override GH_Exposure Exposure => GH_Exposure.tertiary;
public override Guid ComponentGuid => new Guid("A9E03FD2-AFF3-4E5F-A949-6F34F4134036");
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddTextParameter("Tekst", "T", "Tekst som skal plasseres", GH_ParamAccess.item);
pManager.AddNumberParameter("Størrelse", "S", "Teksthøyde", GH_ParamAccess.item, 0.5);
pManager.AddTextParameter("Font", "F", "Font på tekst", GH_ParamAccess.item, "Calibri");
pManager.AddPlaneParameter("Plan", "P", "Plassering av tekst", GH_ParamAccess.item, Plane.WorldXY);
pManager.AddNumberParameter("Tekst plassering", "Tp", "0 = Topp venstre, 1 = Topp midten, 2 = Topp Høyre, 3 = Midten venstre, 4 = Senter, 5 = Midten, høyre, 6 = Bunn venstre, 7 = Bunn midten, 8 = Bunn høyre", GH_ParamAccess.item, 0);
}
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddParameter(new Param_TextEntity(), "Tekst atributt", "TA", "Tekst plassert i Rhino for informasjon eller for tegninger", GH_ParamAccess.item);
}
protected override void SolveInstance(IGH_DataAccess DA)
{
var tekst_streng = "";
var tekst_font = "";
double størrelse = 1;
Plane plan = new Plane();
double plassering = 0;
DA.GetData(0, ref tekst_streng);
DA.GetData(1, ref størrelse);
DA.GetData(2, ref tekst_font);
DA.GetData(3, ref plan);
DA.GetData(4, ref plassering);
tekst_på_plan tekst = new tekst_på_plan(tekst_streng, tekst_font, størrelse, plan, Int32.Parse(plassering.ToString()));
DA.SetData(0, tekst.TextEntity);
}
}
public class tekst_på_plan
public string Tekst { get; set; }
public string Font { get; set; }
public double Størrelse { get; set; }
public Plane Plan { get; set; }
public int Plassering { get; set; }
public TextEntity TextEntity { get; set; }
public tekst_på_plan(string tekst, string font, double størrelse, Plane plan, int plassering)
{
Tekst = tekst;
Font = font;
Størrelse = størrelse;
Plan = plan;
Plassering = plassering;
if (størrelse <= 0.000001)
{
størrelse = 0.000001;
}
TextEntity = new TextEntity
{
Plane = plan,
PlainText = tekst,
Font = new Font(font),
TextHeight = størrelse,
Justification = tekst_plassering(plassering)
};
}
public static TextJustification tekst_plassering(int plassering)
{
return tekst_plassering_liste()[plassering];
}
public static List<TextJustification> tekst_plassering_liste()
{
var Justification = new List<TextJustification>
{
TextJustification.TopLeft, //0
TextJustification.TopCenter, //1
TextJustification.TopRight, //2
TextJustification.MiddleLeft, //3
TextJustification.MiddleCenter, //4
TextJustification.MiddleRight, //5
TextJustification.BottomLeft, //6
TextJustification.BottomCenter, //7
TextJustification.BottomRight //8
};
return Justification;
}
As you can see the code is basically the same, only divided up in smaller parts (and some in Norwegian).