Programmatically extend Pipe length

Programmatically extend Pipe length

Anonymous
Not applicable
3,014 Views
2 Replies
Message 1 of 3

Programmatically extend Pipe length

Anonymous
Not applicable

I have a very particular circumstance in which I need to be able to extend the length of a pipe by a particular magnitude.   I've tried various methods - none of which work.  They include:

 

 

 

 

Pipe.Location.Move(XYZ fVector);       //This moves a Pipe element by the specified vector    
XYZ.Add(XYZ source);                   //I have no idea what this does, but it didn't move my XYZ variable that was my pipe end point

 

...And I know there's more things I've tried, but I can't recall them at the moment.  I've searched online and have come up empty-handed as well.  If anyone knows of a good way to extend a Pipe's length by any means, it would be a monumental help!

0 Likes
Accepted solutions (1)
3,015 Views
2 Replies
Replies (2)
Message 2 of 3

matthew_taylor
Advisor
Advisor
Accepted solution

Hi @Anonymous,

You probably need to cast the pipe's location as a LocationCurve, then set its curve to what you want.

Here's a bit of code I cribbed from the SDK that should get you started:

             Autodesk.Revit.DB.LocationCurve lineLoc;
                    lineLoc = element.Location as LocationCurve;

                    if (null == lineLoc)
                    {
                        TaskDialog.Show("MoveLinear", "Please select an element which based on a Line");
                        trans.Commit();
                        return res;
                    }

                    Autodesk.Revit.DB.Line line;
                    //get start point via "get_EndPoint(0)"
                    Autodesk.Revit.DB.XYZ newStart = new XYZ(
                        lineLoc.Curve.GetEndPoint(0).X + 100,
                        lineLoc.Curve.GetEndPoint(0).Y,
                        lineLoc.Curve.GetEndPoint(0).Z);
                    //get end point via "get_EndPoint(1)"
                    Autodesk.Revit.DB.XYZ newEnd = new XYZ(
                        lineLoc.Curve.GetEndPoint(1).X,
                        lineLoc.Curve.GetEndPoint(1).Y + 100,
                        lineLoc.Curve.GetEndPoint(1).Z);


                    //get a new line and use it to move current element 
                    //with property "Autodesk.Revit.DB.LocationCurve.Curve"
                    line = Line.CreateBound(newStart, newEnd);
                    lineLoc.Curve = line;

 

Cheers,

 

-Matt


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 3 of 3

Anonymous
Not applicable

Hey Matt,

 

Thanks!  You're absolutely right.  We figured this out:

ConnectorSet lNeighborConn = Connection.DisconnectPipe(pDoc, pPipe);
LocationCurve pLocCurve = pPipe.Location as LocationCurve;
pLocCurve.Curve = Line.CreateBound(pStart, pEnd);                          
// try reconnecting to old neighbours      
bool bConSuccess = Connection.ConnectConnectorSets(pDoc, pPipe.ConnectorManager.Connectors, lNeighborConn);