- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey Everyone, Im trying to create pipes from a list of points. however i want to create the pipes between only between the closest points. Right now it will connect the points from the element in the order that it gets created.
EX:
i know im not iterating through the points correctly to do so. but i cant figure out search the list for the closest points and then draw the pipe between those...
Thanks ahead of time for any responses/guidance.
Here is my code so far:
if (form.ShowDialog() == DialogResult.OK)
{
//gets the level from form
ElementId slvlId = null;
if (form.sLevel.SelectedIndex > -1)
{
slvlId = (form.sLevel.SelectedItem as Level).Id;
}
//gets the system type from form
ElementId sysTypeId = null;
if (form.pSysType.SelectedIndex > -1)
{
sysTypeId = (form.pSysType.SelectedItem as PipingSystemType).Id;
}
//gets the pipe type from form
ElementId pTypeId = null;
if (form.pType.SelectedIndex > -1)
{
pTypeId = (form.pType.SelectedItem as PipeType).Id;
}
using (Transaction tx = new Transaction(doc))
{
tx.Start("Create Pipes");
List<XYZ> points = new List<XYZ>();
foreach (ElementId elemId in selectedIds)
{
Element elem = uidoc.Document.GetElement(elemId);
//bounding box around solid
BoundingBoxXYZ elemBB = elem.get_BoundingBox(doc.ActiveView);
//gets center of bounding box
XYZ bbCentroid = (elemBB.Max + elemBB.Min) / 2;
//add centroid points to list
points.Add(bbCentroid);
}
XYZ startPt = null;
XYZ endPt = null;
foreach (XYZ pt in points)
{
startPt = pt;
if (startPt != null && endPt != null)
{
Pipe pipe = Pipe.Create(doc, sysTypeId, pTypeId, slvlId, startPt, endPt);
endPt = pt;
}
else
{
endPt = pt;
}
}
tx.Commit();
}
}
Solved! Go to Solution.
Link copied