revit二次开发小技巧

//获取当前视图的标高 ,操作时只能在平面视图,不然会报错,因为在三维视图无法获取标高。

Level level = document.ActiveView.GenLevel;

//通过某构件获取标高(如放置门时获取墙体标高)

Level level = document.GetElement(wall.LevelId) as Level;

//可以通过Document获取UIdocument.

UIDocument uidoc = new UIDocument(document);

//过滤所有轴网

List<Grid> allgrids = new FilteredElementCollector(doc).OfClass(typeof(Grid)).Cast<Grid>().ToList();

//楼板与管道过滤选择

public class FloorPipeFileter : ISelectionFilter
        {
            public bool AllowElement(Element elem)
            {
                if (elem.Category.Name == "楼板" || elem.Category.Name == "管道")
                {
                    return true;
                }
                return false;
            }

            public bool AllowReference(Reference reference, XYZ position)
            {
                return false;
            }
        }

//IList<T>转 List<T>();

可以先利用IList<T> iList=new List<T>();然后用iList去承接承接生成的集合。

//try catch用法

public class Document_Selection : IExternalCommand
{
    public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
        ref string message, ElementSet elements)
    {
        try
        {
            
        }
        catch (Exception e)
        {
            //message = e.Message;
            //MessageBox.Show(ex.Message);
            return Autodesk.Revit.UI.Result.Failed;
        }

        return Autodesk.Revit.UI.Result.Succeeded;
    }    
}

 

//获取一个面的法向向量

XYZ normal = planarFace.ComputeNormal(new UV(planarFace.Origin.X, planarFace.Origin.Y));

Curve.CreateOffset Method

依据一个曲线偏移后生成另一个曲线。

用其他 方法得到Curve1后,偏移后的

Curve2=Curve1.CreateOffset (double类型偏移距离,XYZ normal);

XYZ normal可以用下面的表示:

new XYZ(0,0,1)表示右或外方偏移,new XYZ(0,0,-1) 表示向左或内偏移,如下图所示:

未完,待完善。。。

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值