<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Adding couplings on pipe. in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/adding-couplings-on-pipe/m-p/5587915#M73141</link>
    <description>Dear Anusha, is it duplicated with this? &lt;A href="http://forums.autodesk.com/t5/revit-api/adding-couplings-to-pipe/m-p/5564601#U5564601" target="_blank"&gt;http://forums.autodesk.com/t5/revit-api/adding-couplings-to-pipe/m-p/5564601#U5564601&lt;/A&gt;</description>
    <pubDate>Mon, 13 Apr 2015 04:59:42 GMT</pubDate>
    <dc:creator>Aaron.Lu</dc:creator>
    <dc:date>2015-04-13T04:59:42Z</dc:date>
    <item>
      <title>Adding couplings on pipe.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/adding-couplings-on-pipe/m-p/5564604#M73140</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: 'FrutigerNextW04-Regular',serif; font-size: 10.5pt;"&gt;The below code is splitting the pipe and adding the coupling perfectly, if the line is straight.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: 'FrutigerNextW04-Regular',serif; font-size: 10.5pt;"&gt;Offset is going to negative side, and the pipe diameter is always showing as 200m in the Revit, if i check in the application the pipe diameter is same as the original pipe. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: 'FrutigerNextW04-Regular',serif; font-size: 10.5pt;"&gt;Please can anyone suggest me, how to work if the pipe is having any angles or the pipe is vertical.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: 'FrutigerNextW04-Regular',serif; font-size: 10.5pt;"&gt;Thank you very much in advance.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// code&lt;/P&gt;&lt;P&gt;FilteredElementCollector collector = new FilteredElementCollector(doc);&lt;BR /&gt;collector.OfClass(typeof(PipeType));&lt;BR /&gt;PipeType pipeType = collector.FirstElement() as PipeType;&lt;/P&gt;&lt;P&gt;Selection sel = uidoc.Selection;&lt;BR /&gt;foreach (Element e in sel.Elements)&lt;BR /&gt;{&lt;BR /&gt;Pipe c = e as Pipe;&lt;BR /&gt;if (null != c)&lt;BR /&gt;{&lt;BR /&gt;pipes.Add(c);&lt;BR /&gt;if (2 == pipes.Count)&lt;BR /&gt;{&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;tx.Start("split pipe");&lt;/P&gt;&lt;P&gt;Curve c1 = (pipes[0].Location as LocationCurve).Curve;// selecting one pipe and taking its location.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;XYZ p00 = c1.GetEndPoint(0);&lt;BR /&gt;XYZ p01 = c1.GetEndPoint(1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// finding thte length of the selected pipe.&lt;/P&gt;&lt;P&gt;double len = pipes[0].get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsDouble();&lt;BR /&gt;len = len / 2; //dividing the length.&lt;/P&gt;&lt;P&gt;// creatin first pipe&lt;/P&gt;&lt;P&gt;XYZ q0 = p00;&lt;BR /&gt;XYZ q1 = p01 - len * XYZ.BasisX;&lt;/P&gt;&lt;P&gt;Pipe pipe = null;&lt;BR /&gt;if (null != pipeType)&lt;BR /&gt;{&lt;BR /&gt;pipe = doc.Create.NewPipe(q0, q1, pipeType);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// creatin first pipe&lt;/P&gt;&lt;P&gt;XYZ q2 = p01;&lt;BR /&gt;XYZ q3 = p01 - (len - 1) * XYZ.BasisX;&lt;BR /&gt;&lt;BR /&gt;Pipe pipe1 = null;&lt;BR /&gt;if (null != pipeType)&lt;BR /&gt;{&lt;BR /&gt;pipe1 = doc.Create.NewPipe(q2, q3, pipeType);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Connector pipe2_start = null;&lt;BR /&gt;Connector pipe2_end = null;&lt;/P&gt;&lt;P&gt;double dist = double.MaxValue;&lt;BR /&gt;foreach (Connector c in pipe.ConnectorManager.Connectors)&lt;BR /&gt;{&lt;BR /&gt;XYZ p = c.Origin;&lt;BR /&gt;double d = p.DistanceTo(q1);&lt;/P&gt;&lt;P&gt;if (d &amp;lt; dist)&lt;BR /&gt;{&lt;BR /&gt;dist = d;&lt;BR /&gt;pipe2_start = c;&lt;BR /&gt;}&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;foreach (Connector conn in pipe1.ConnectorManager.Connectors)&lt;BR /&gt;{&lt;BR /&gt;if (conn.Origin.IsAlmostEqualTo(q3))&lt;BR /&gt;{&lt;BR /&gt;pipe2_end = conn;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;FamilyInstance takeoff = doc.Create.NewUnionFitting(pipe2_start, pipe2_end);&lt;BR /&gt;DeleteElement(doc, pipes[0]);&lt;BR /&gt;tx.Commit();&lt;/P&gt;</description>
      <pubDate>Tue, 31 Mar 2015 07:31:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/adding-couplings-on-pipe/m-p/5564604#M73140</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-03-31T07:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: Adding couplings on pipe.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/adding-couplings-on-pipe/m-p/5587915#M73141</link>
      <description>Dear Anusha, is it duplicated with this? &lt;A href="http://forums.autodesk.com/t5/revit-api/adding-couplings-to-pipe/m-p/5564601#U5564601" target="_blank"&gt;http://forums.autodesk.com/t5/revit-api/adding-couplings-to-pipe/m-p/5564601#U5564601&lt;/A&gt;</description>
      <pubDate>Mon, 13 Apr 2015 04:59:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/adding-couplings-on-pipe/m-p/5587915#M73141</guid>
      <dc:creator>Aaron.Lu</dc:creator>
      <dc:date>2015-04-13T04:59:42Z</dc:date>
    </item>
  </channel>
</rss>

