Reputation: 11
I want to move pointer for creating Pipe from one place to another place Programmatically while drawing Pipe from revit.
please refer below image.
while drawing pipe from revit i am able to change offset(Ex. from 15 to 16). but unable to change create pipe pointer location from red point to orange point(refer image) Programatically.
Is this possible?
OR
can we change or access Offset value Programatically while drawing Pipe from Revit.
Refer below image
Please suggest..
Regards
Namit Jain
Upvotes: 0
Views: 1377
Reputation: 1271
Via the Autodesk.Revit.DB.Plumbing
namespace: There is a function:
public static Pipe Create(Document document, ElementId systemTypeId, ElementId pipeTypeId, ElementId levelId, XYZ startPoint, XYZ endPoint);
And you can use that in your code like:
XYZ fStartPoint = new XYZ(0.0, 0.0, 0.0); //Modify these values to your desired coordinates
XYZ fEndPoint = new XYZ(0.0, 0.0, 0.0); //Modify these values to your desired coordinates
ElementId pPipeTypeId = pPreviousPipe.PipeType.Id;
ElementId pPipeLevelId = pPreviousPipe.LevelId;
ElementId pSystemId = pPreviousPipe.MEPSystem.Id;
if (pPipeLevelId == ElementId.InvalidElementId)
{
Level lLevel = null;
using (Transaction pTrans = new Transaction(doc, "Get Level"))
{
pTrans.Start();
lLevel = Level.Create(doc, pPreviousPipe.LevelOffset;
pTrans.Commit();
}
pPipeLevelId = lLevel.Id;
}
Pipe.Create(doc, pSystemId, pPipeTypeId, pPipeLevelId, fStartPoint, fEndPoint);
There are overloads for the Create(...)
function, so take a look at those too. If you're connecting Pipe
s and FamilyInstance
s like fittings, you can use the
public static Pipe Create(Document document, ElementId pipeTypeId, ElementId levelId, Connector startConnector, Connector endConnector);
which will connect them directly via the Connector
s. As for offsetting the pipes, what I did above should suit you best. Good luck!
And the Offset
in your second image refers to the Z
axis of your plane. You want to do something more like
var fTemp = pPreviousPipe.Location as LocationCurve;
var fEnd = fTemp.Curve.GetEndPoint(1);
//Index 0 is the beginning of the pipe (where user started drawing)
//Index 1 is the end of the pipe (where user stopped drawing)
XYZ fStartPoint = new XYZ(fEnd.X, fEnd.Y - .5, fEnd.Z);
double dPipeLength = 10.0;
XYZ fEndPoint = new XYZ(fStartPoint.X + dPipeLength, fStartPoint.Y, fStartPoint.Z);
Upvotes: 0