How do I copy a TextObject to a new headless document?
This script works perfectly for curves but not for Text Objects - how do i handle them?
using System;
using System.Linq;
using System.Collections.Generic;
using Rhino;
var mainDoc = RhinoDoc.ActiveDoc;
var selectedObjects = mainDoc.Objects.GetSelectedObjects(false, false);
var newDoc = RhinoDoc.CreateHeadless(null);
foreach (var obj in selectedObjects) {
var newGeom = obj.Geometry.Duplicate();
newDoc.Objects.Add(newGeom);
}
newDoc.SaveAs(@"C:\temp\TextExport.3dm");
Ah! i think i need to copy the dimension styles first? is that the correct process?
using System;
using System.Linq;
using System.Collections.Generic;
using Rhino;
var mainDoc = RhinoDoc.ActiveDoc;
var selectedObjects = mainDoc.Objects.GetSelectedObjects(false, false);
var newDoc = RhinoDoc.CreateHeadless(null);
// first copy dimension styles?
foreach(var s in mainDoc.DimStyles) {
var s2 = s.Duplicate();
newDoc.DimStyles.Add(s2,false);
}
// then copying text objects appears to work
foreach (var obj in selectedObjects) {
var newGeom = obj.DuplicateGeometry();
newDoc.Objects.Add(newGeom);
}
newDoc.SaveAs(@"C:\temp\TextExport.3dm");