“No routing preference for takeoff set for this PipeType” occurred when calling NewTakeoffFitting

“No routing preference for takeoff set for this PipeType” occurred when calling NewTakeoffFitting

sunzj22
Contributor Contributor
2,338 次查看
6 条回复
1 条消息(共 7 条)

“No routing preference for takeoff set for this PipeType” occurred when calling NewTakeoffFitting

sunzj22
Contributor
Contributor

I was trying to generate a tee with two disjoint pipes, but the error was raised as shown in picture. Due to my language level, I was unable to find accurate information about the "routing preference". I want to know what it is and how to debug.屏幕截图 2024-11-27 171956.png

And this is my code.

var pipe_system = new FilteredElementCollector(doc);
pipe_system.OfClass(typeof(PipingSystemType));
var pipe_system_type = pipe_system.ToList().First() as PipingSystemType;

var pipe_type = new FilteredElementCollector(doc);
pipe_type.OfClass(typeof(PipeType));
var type = pipe_type.ToList().First() as PipeType;

var pipe5 = Pipe.Create(doc, pipe_system_type.Id, type.Id, level.Id, new XYZ(10, 10, 15), new XYZ(17, 10, 15));
var pipe8 = Pipe.Create(doc, pipe_system_type.Id, type.Id, level.Id, new XYZ(18, 0, 15), new XYZ(18, 20, 15));
pipe_list = GetMainPipe(pipe5, pipe8);
ConnectWithTakeoff(doc, pipe_list[0], pipe_list[1]);

private static void ConnectWithTakeoff(Document doc, Pipe duct1, Pipe duct2)
{
    double min_distance = double.MaxValue;
    Curve curve1 = (duct1.Location as LocationCurve).Curve;
    Connector connector2 = null;

    foreach (Connector con2 in duct2.ConnectorManager.Connectors)
    {
        var dis = curve1.Distance(con2.Origin);
        if (dis < min_distance)
        {
            min_distance = dis;
            connector2 = con2;
        }
    }

    if (connector2 != null)
    {
        var takeoff = doc.Create.NewTakeoffFitting(connector2, duct1);
    }
}
0 个赞
2,339 次查看
6 条回复
回复 (6)
2 条消息(共 7 条)

scgq425
Advocate
Advocate
已接受的解答

Hi @sunzj22 :

你的代码没有问题,你需要检查一下你的布管系统设置这里的连接是不是使用了接头族,这个方法仅适用于接头族的创建

如果你需要创建三通,四通或是弯头,可以使用 `NewCrossFitting , NewTeeFitting , etc`

scgq425_1-1732716213865.png

 

 

LanHui Xu 徐兰辉
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Blog
LinkedIn
Revit/CAD Development | Steel Product Manager

EESignature

3 条消息(共 7 条)

sunzj22
Contributor
Contributor

我确实是想生成三通,我是看网络上的资料说NewTakeoffFitting可以将管道主动延伸并自动创建一个三通,功能上等同于“修剪/延伸单个图元”,而NewTeeFitting必须要求两个管段的线段是相交的。

您的意思是在首选连接类型这里必须是“接头”才能调用NewTakeoffFitting吗?我看了一下我的首选连接类型是T形三通,但是我用revitlookup查看pipetype的属性,发现Tap这一栏是null。这是不是说明我需要在代码中为Tap指定一个族,或者能否直接调用“修剪/延伸单个图元”这个功能的API?盼复。屏幕截图 2024-11-28 001311.png

0 个赞
4 条消息(共 7 条)

reylorente1
Collaborator
Collaborator
已接受的解答

In the the_building_coder_samples, there is an example (CmdNewCrossFitting)

0 个赞
5 条消息(共 7 条)

scgq425
Advocate
Advocate
已接受的解答

@sunzj22 你好:

1. 昨天我测试了一下确实是只有连接里面设置了两个连接并且有一个接头族才能用这个API,资料上大部分是介绍的没有直接应用的案例。我找到了Jimmy的案例其中的最终效果你可以参照一下,和我昨晚的测试一样  Use of NewTakeOffFitting on a Duct 

2. 如果想要生成三通,还是通过找到connector的方式,像主管到投影获取投影点然后分割成三个管到连接起来的方式进行连接,这个网络上有很多你可以找一个案例学习一下,如果还有其他问题可以继续留言。

 

LanHui Xu 徐兰辉
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Blog
LinkedIn
Revit/CAD Development | Steel Product Manager

EESignature

6 条消息(共 7 条)

sunzj22
Contributor
Contributor

理解了,我昨天实现了手动延长管段然后用NewTeeFitting生成三通,之后我再研究一下这个案例,感谢您的解答。

7 条消息(共 7 条)

sunzj22
Contributor
Contributor

Thank you for the reply! I found where I was wrong.