Quantcast
Channel: All Revit API Forum posts
Viewing all articles
Browse latest Browse all 67020

An easy way to insert a fitting in a pipe?

$
0
0

Hi!

I have alreadyreadthis topic  by @jeremy_tammik, but i still don't understand how to correctly insert the fitting into the pipe?
I wrote a smallmethod,butitsresults are notwhatIexpected:

 

 

public static void Split(Pipe pipe, out List<Pipe> splittedPipes, out List<FamilyInstance> placedFitings) { splittedPipes = []; placedFitings = []; Document doc = pipe.Document; int numberOfSegments = 5; // Количество сегментов if (doc.GetSymbol("em_NVK_Футляр200", "Сталь", out FamilySymbol pipeAccessorySymbol)) { // Получаем начальную и конечную точки трубы LocationCurve pipeLocation = pipe.Location as LocationCurve; XYZ startPoint = pipeLocation.Curve.GetEndPoint(0); XYZ endPoint = pipeLocation.Curve.GetEndPoint(1); // Вычисляем шаг между аксессуарами double pipeLength = pipeLocation.Curve.Length; double step = pipeLength / (numberOfSegments + 1); // Проходим по каждому участку и вставляем аксессуар for (int i = 1; i <= numberOfSegments; i++) { double distance = step * i; XYZ insertionPoint = startPoint + (endPoint - startPoint).Normalize() * distance; FamilyInstance accessory = doc.Create.NewFamilyInstance(insertionPoint, pipeAccessorySymbol, pipe, StructuralType.NonStructural); } } }

 

 


What do I expect:

ankofl_0-1726060740835.png
WhatIget:
ankofl_1-1726060771921.png

 

I understand that it is possible to create separate pipes, taking into account the indentation of each inserted fitting, put these fittings on the plane of the pipe axis, then look for the matching connectors of the fittings and connectors of the pipe nearest to it, then connect all this, and then removing the original pipe, connect everything that was connected to the original pipe to the resulting fragments of new pipes...

But we can do all this literally in one click, just by clicking the fitting on the pipe, can we do this insertion through the API?

Thanks!


Viewing all articles
Browse latest Browse all 67020

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>