Highlighting an XYZ point

Highlighting an XYZ point

Anonymous
Not applicable
985 Views
3 Replies
Message 1 of 4

Highlighting an XYZ point

Anonymous
Not applicable

I am trying to highlight a point, which is represented by a class XYZ. So far, I am highlighting a point by creating a sphere around it. 

So, in my project I need to highlighting nodes on a line, nodes are represented by XYZ class. So, at some point, I will have to highlight hundreds of nodes with different color, and creating a sphere around a node is too time consuming, is there a better way to highlight a point in Revit API.

below is my method to highlight a point XYZ, where I am creating a sphere around it.

 

public void CreateSphereDirectShape(Document doc, XYZ center, Color color)
{
/*// delete current sphere
if (Class1.startPointID != null)
{
using (Transaction t = new Transaction(doc, "Delete sphere direct shape"))
{
t.Start();
doc.Delete(Class1.startPointID);
Class1.startPointID = null;
t.Commit();
}
}*/
List<Curve> profile = new List<Curve>();

// first create sphere with 2' radius
double radius = 0.05;
XYZ profile00 = center;
XYZ profilePlus = center + new XYZ(0, radius, 0);
XYZ profileMinus = center - new XYZ(0, radius, 0);

profile.Add(Line.CreateBound(profilePlus, profileMinus));
profile.Add(Arc.Create(profileMinus, profilePlus, center + new XYZ(radius, 0, 0)));

CurveLoop curveLoop = CurveLoop.Create(profile);
SolidOptions options = new SolidOptions(ElementId.InvalidElementId, ElementId.InvalidElementId);

Frame frame = new Frame(center, XYZ.BasisX, -XYZ.BasisZ, XYZ.BasisY);
if (Frame.CanDefineRevitGeometry(frame) == true)
{
Solid sphere = GeometryCreationUtilities.CreateRevolvedGeometry(frame, new CurveLoop[] { curveLoop }, 0, 2 * Math.PI, options);
using (Transaction t = new Transaction(doc, "Create sphere direct shape"))
{
t.Start();
// create direct shape and assign the sphere shape
DirectShape ds = DirectShape.CreateElement(doc, new ElementId(BuiltInCategory.OST_GenericModel));
Class1.startPointID = ds.Id;
ds.ApplicationId = "Application id";
ds.ApplicationDataId = "Geometry object id";
ds.SetShape(new GeometryObject[] { sphere });

// change sphere color
OverrideGraphicSettings ogs = new OverrideGraphicSettings();
ogs.SetProjectionLineColor(color);
ogs.SetSurfaceTransparency(50);
doc.ActiveView.SetElementOverrides(ds.Id, ogs);

t.Commit();
}
}
}

0 Likes
Accepted solutions (1)
986 Views
3 Replies
Replies (3)
Message 2 of 4

jlpgy
Advocate
Advocate

HI:

How about creating three <ModelLine> elements at the point?

单身狗;代码狗;健身狗;jolinpiggy@hotmail.com
0 Likes
Message 3 of 4

jlpgy
Advocate
Advocate
Accepted solution
  1. If you are working in a Plan View, set the <SketchPlane> to a horizontal plane first.
  2. Draw a "cross" with 2 model lines at the point where you want to highlight?

Model line is with better performance than Sphere.

I myself use model lines to draw some solid objects to test my own alogrithms.

单身狗;代码狗;健身狗;jolinpiggy@hotmail.com
0 Likes
Message 4 of 4

Anonymous
Not applicable

Hi, I tried that, and it really is a big time saver over creating a sphere.

Thanks for the help.

0 Likes