Quantcast
Channel: Rhino Developer - McNeel Forum
Viewing all articles
Browse latest Browse all 8562

File3dmObject Adding User Text and Write to File

$
0
0

@AlanTai wrote:

Hi,

I have trouble adding user text consistently to File3dmbObject and write them to a file. For example, the code below tries to add "k" as key and "v" as value to curves and write them to a file. However, some objects in the resulting 3dm file contains user text and some objects do not. I wonder if I missed anything using the File3dm.Write method.

List<LineCurve> lines = new List<LineCurve>();
for(int i = 0;i < 100;i++)
        lines.Add(new LineCurve(new Point3d(i, 0, 0), new Point3d(i, 1, 0)));
string filepath = "C:\\temp\\test-bake-file.3dm";

Rhino.FileIO.File3dm f = new Rhino.FileIO.File3dm();
foreach(Curve l in lines)
{
   ObjectAttributes att = new ObjectAttributes();
   att.SetUserString("k", "v");
   f.Objects.AddCurve(l, att);
}
f.Polish();
f.Write(filepath, 5);

Thanks,
Alan

Posts: 6

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 8562

Trending Articles