Revit API: HostedSweep

在研究屋顶的时候,发现了封檐带、檐沟和楼板边缘。他们都是继承自 HostedSweep
在这里插入图片描述
他们的创建方式:

namespace Autodesk.Revit.Creation
{
    
    
    public class Document : ItemFactoryBase
    {
    
    
        public Fascia NewFascia(FasciaType FasciaType, Reference reference);
        public Fascia NewFascia(FasciaType FasciaType, ReferenceArray references);
        public Gutter NewGutter(GutterType GutterType, ReferenceArray references);
        public Gutter NewGutter(GutterType GutterType, Reference reference);
        public SlabEdge NewSlabEdge(SlabEdgeType SlabEdgeType, Reference reference);
        public SlabEdge NewSlabEdge(SlabEdgeType SlabEdgeType, ReferenceArray references);
    }
}

如果想要找到例子,可以参考 SDK:

// Revit 2021 SDK\Samples\NewHostedSweep\CS\Creators\HostedSweepCreator.cs
/// <summary>
/// Create a hosted-sweep according to the CreationData parameter.
/// </summary>
/// <param name="creationData">CreationData parameter</param>
/// <returns>ModificationData which contains the created hosted-sweep</returns>
public ModificationData Create(CreationData creationData)
{
    
    
	ReferenceArray refArr = new ReferenceArray();
	foreach (Edge edge in creationData.EdgesForHostedSweep)
	{
    
    
		refArr.Append(edge.Reference);
	}

	ModificationData modificationData = null;
	Transaction transaction = new Transaction(m_rvtDoc, "CreateHostedSweep");
	try
	{
    
    
		transaction.Start();
		HostedSweep createdHostedSweep = CreateHostedSweep(creationData.Symbol, refArr);

		if (transaction.Commit() == TransactionStatus.Committed)
		{
    
    
			m_rvtUIDoc.ShowElements(createdHostedSweep);

			// just only end transaction return true, we will create the hosted sweep.                    
			modificationData =
				new ModificationData(createdHostedSweep, creationData);
			m_createdHostedSweeps.Add(modificationData);
            }
	}
	catch
	{
    
    
		transaction.RollBack();
	}
	return modificationData;
}

获取 reference 的方法 edge.Reference

猜你喜欢

转载自blog.csdn.net/weixin_44153630/article/details/121363187
今日推荐