Create Points with name

Hi,

I need read a txt file with coordinate points and draw this points into Rhino.

Each point has a different name in the txt file, so I need set this name in Rhino’s points.

So, for each line in the txt file I want create a point and set the name.

I try create the point thereby:

  • Point3d: It hasn’t attribute property, so I can set the name
  • Point: I can’t locate the attribute property
  • ObjectPopint: It hasn’t constructor?

What can I do?

I’m using c# and Rhinocommon

Hi,
Here is a sample that shows how to add a point to the Rhino Document and assign a name to the point object:

// create a point
Rhino.Geometry.Point3d pt = new Rhino.Geometry.Point3d(1, 2, 3);
//name
String name = “ABC”;
//create new object attribute
var att = doc.CreateDefaultAttributes();
att.Name = name;
//add the point to the document
doc.Objects.AddPoint(pt, att);

1 Like

Hi, thanks for the answer, but I need create 400 points, for example.

I would like set the name in the point constructor, and also, I need save the point reference in a List and query the name’s point

I can do this:

// create a point
Rhino.Geometry.Point3d pt = new Rhino.Geometry.Point3d(1, 2, 3);
//name
String name = “ABC”;
//create new object attribute
var att = doc.CreateDefaultAttributes();
att.Name = name;
//add the point to the document
doc.Objects.AddPoint(pt, att);

Guid guidPto = RhinoDoc.ActiveDoc.Objects.MostRecentObject().Id;
PointObject pto =  (PointObject)RhinoDoc.ActiveDoc.Objects.Find(guidPto).
list.add(pto)

I don’t like this code, and I need do it 400 times.

The “AddPoint(…)” returns the Guid of the object added to document. You can say:
Guid guidPto = doc.Objects.AddPoint(pt, att);

1 Like

Oki, thank you very much