Hi everyone,
I am working on a C# component.
My goal is to write a C# component in Grasshopper that allows me to bake in Rhino and then export in a single .dwg file several 3Dtexts, at different locations.
I tried to adapt a similar C# component that I wrote, that perform the same operation, but on surfaces, and that C# component works.
I have a problem with this C# script unfortunately. I do not know why, but the export operation is repeated once for every text in the list.
Here is the code:
private void RunScript(string File, List<Plane> plane, List<string> text, double fontHeight, System.Drawing.Color Text_color, bool bake, List<Surface> Rect, System.Drawing.Color Rect_colors)
{
if (bake)
{
List<Guid> guids = new List<Guid>();
for (int i = 0; i < Rect.Count; i++)
{
var _text = new TextEntity();
Rhino.DocObjects.ObjectAttributes att = new Rhino.DocObjects.ObjectAttributes();
att.ObjectColor = Text_color;
att.ColorSource = Rhino.DocObjects.ObjectColorSource.ColorFromObject;
_text.Plane = plane[i];
_text.PlainText = text[i];
_text.TextHeight = fontHeight;
var guid = Rhino.RhinoDoc.ActiveDoc.Objects.AddText(_text, att);
guids.Add(guid);
}
Rhino.RhinoDoc.ActiveDoc.Objects.Select(guids);
string filepath = File;
string cmd = "_-Export " + "\"" + filepath + "\"" + " _Enter";
Rhino.RhinoApp.RunScript(cmd, false);
Rhino.RhinoDoc.ActiveDoc.Objects.Delete(guids, true);
}
Thanks, but I do not think that’s the problem. Actually, the last 2 inputs of the script are unused at the moment, but I have in mind to improve the script by adding other features.
Yes, they are unused in the code, but that doesn’t prevent the component from looping the inputs on them. Have you tried setting those as list as well ? Rect is actually used here so don’t change it.
If the issue remains, please post your GH definition with internalized geometry
Hi @STEFANO6 its very useful! I just wonder if it is possible to add an option if you can overwrite or not its destination file. For example you have a file with the same name. then you just want to add the tags. you export it on the same file name. I hope it just have an overwrite option so that the original file for the same file name will not be overwritten if that make sense.