Hi
I am trying to make an annotative text to place in a model for reference.
VisualARC has a component that does this, but I wanted to make my own to make it easier to integrate with other components I am making.
The VIsualAQR component looks like this:
I have made an TextEntity component, but the text does not get placed at all.
My guess is that I need to convert or define it some how, but I can not find what is wrong.
I have also tried with AddTextParameter, but it did not help.
Hello,
It seems to me the text entity is correctly created. The output of the component shows on object of that type.
If you want the Panel to display the content of the text like VisualARC does, you’ll have to create your own TextEntity class and override the ToString() method (which is called by the Panel, tooltips, …)
AddGenericParameter is correct, AddTextParameter would define the output as a string and therefore convert your text to string and lose geometry.
If you need more help, please post your cs code !
Hi
What I need is to be able to place the text in Rhino, like this
It is nice if the panel shows the text but not as important as getting the text in 3D i Rhino
I got something from somebody that had made there own and got it to work, but I do not have the source for it, and wold like to learn how it is made.
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.AddPlaneParameter("Plan", "P", "Plassering av tekst", GH_ParamAccess.item, Plane.WorldXY);
}
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddParameter(new PropertyTextParameter(), "Tekst ut", "Tu", "Tekst plassert pĂĄ plan", GH_ParamAccess.item);
}
protected override void SolveInstance(IGH_DataAccess DA)
{
String tekst = "";
double størrelse = 1;
Plane plan = new Plane();
DA.GetData(0, ref tekst);
DA.GetData(1, ref størrelse);
DA.GetData(2, ref plan);
DimensionStyle dimensjon = new DimensionStyle();
dimensjon.TextHeight = størrelse;
TextEntity tekstut = TextEntity.Create(tekst, plan, dimensjon, false, 1, 1);
PropertyText pText = new PropertyText(tekstut);
DA.SetData(0, new PropertyTextGoo(pText));
}
This example shows PropertyText, PropertyTextGoo and PropertyTextParam objects, these are data types and parameters. You may want to look at this :
For the display to occur, your parameter need to implement IGH_PreviewData interface on the TextEntityGoo.
And you can override the DrawPreviewWires and DrawPreviewMeshes methods, and insert there a call to DrawAnnotation there.
public class TextEntityGoo : GH_Goo<Rhino.Geometry.TextEntity>, IGH_PreviewData
{
public Rhino.Geometry.TextEntity TextEntity;
public void DrawViewportMeshes(GH_PreviewMeshArgs args)
{
args.Pipeline.DrawAnnotation(TextEntity, args.Material.Diffuse);
}
public void DrawViewportWires(GH_PreviewWireArgs args)
{
args.Pipeline.DrawAnnotation(TextEntity, args.Color);
}
public TextEntityGoo(Rhino.Geometry.TextEntity textEntity)
{
TextEntity = textEntity;
}
}
Note that if you choose to implement your own parameter (PropertyTextParameter), it also needs to implement IGH_PreviewObject. You don’t need it if you use a generic data type as the output of your component.
The sizing doesn’t work though…
TextEntity.cs (5.1 KB)
1 Like