使用FamilyManager其他的与普通添加参数与标注没区别。

[TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class cmdAddParam : IExternalCommand
{
    public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
    {
        UIApplication app = commandData.Application;
        Document doc = app.ActiveUIDocument.Document;         Transaction ts = new Transaction(doc, "NewDimension");
        ts.Start();         //添加参数
        FamilyManager m_familyMgr = doc.FamilyManager;
        bool isInstance = false;
        FamilyParameter paramTw = m_familyMgr.AddParameter("Tw", BuiltInParameterGroup.PG_GEOMETRY, ParameterType.Length, isInstance);
        double tw = Util.mmToFeet(150.0);
        m_familyMgr.Set(paramTw, tw);
        m_familyMgr.SetFormula(paramTw, "Width / 4.0");//公式         //添加尺寸标注
        View pViewPlan = Util.findElement(doc, typeof(ViewPlan), "Lower Ref. Level") as View;
        ReferencePlane ref1 = Util.findElement(doc, typeof(ReferencePlane), "Left") as ReferencePlane;
        ReferencePlane ref2 = Util.findElement(doc, typeof(ReferencePlane), "offsetV") as ReferencePlane;
        ReferenceArray pRefArray = new ReferenceArray();
        pRefArray.Append(ref1.Reference);
        pRefArray.Append(ref2.Reference);
        XYZ p0 = ref1.FreeEnd;
        XYZ p1 = ref2.FreeEnd;
        Line pLine = app.Application.Create.NewLineBound(p0, p1);
        Dimension pDimTw = doc.FamilyCreate.NewDimension(pViewPlan, pLine, pRefArray);
        pDimTw.Label = m_familyMgr.get_Parameter("Tw");         ts.Commit();         return Result.Succeeded;
    }
}
public class Util
{
    //Revit内部单位feet转化为mm即毫米
    public static double mmToFeet(double val) { return val / 304.8; }
    public static double feetToMm(double val) { return val * 304.8; }
    //通过类型与名称找Element
    public static Element findElement(Document _rvtDoc, Type targetType, string targetName)
    {
        // get the elements of the given type
        //
        FilteredElementCollector collector = new FilteredElementCollector(_rvtDoc);
        collector.WherePasses(new ElementClassFilter(targetType));         // parse the collection for the given name
        // using LINQ query here. 
        // 
        var targetElems = from element in collector where element.Name.Equals(targetName) select element;
        List<Element> elems = targetElems.ToList<Element>();         if (elems.Count > )
        {  // we should have only one with the given name. 
            return elems[];
        }         // cannot find it.
        return null;
    }
    #region Formatting and message handlers
    public const string Caption = "Revit Family API Labs";     /// <summary>
    /// MessageBox wrapper for informational message.
    /// </summary>
    public static void InfoMsg(string msg)
    {         System.Diagnostics.Debug.WriteLine(msg);
        WinForm.MessageBox.Show(msg, Caption, WinForm.MessageBoxButtons.OK, WinForm.MessageBoxIcon.Information);
    }     /// <summary>
    /// MessageBox wrapper for error message.
    /// </summary>
    public static void ErrorMsg(string msg)
    {
        WinForm.MessageBox.Show(msg, Caption, WinForm.MessageBoxButtons.OK, WinForm.MessageBoxIcon.Error);
    }
    #endregion // Formatting and message handlers
}

url:http://greatverve.cnblogs.com/p/revit-family-api-param.html

Revit Family API 添加参数与尺寸标注的更多相关文章

  1. Revit Family API 添加类型

    FamilyManager.NewType("");添加新类型,然后设置参数,就是为新类型设置参数. [TransactionAttribute(Autodesk.Revit.At ...

  2. Revit Family API 添加对齐

    没测试成功,留待以后研究. [TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)] ; ; i < nV ...

  3. Revit Family API 添加几何实体

    先创建一个封闭曲线createProfileLShape();再创建实体,这里需要手工画一个参考平面; ; i < nVerts; ++i)        {            Line l ...

  4. Revit Family API 添加材质参数设置可见性

    start //添加类型 void AddType(FamilyManager familyMgr, string name, double w, double d) {     FamilyType ...

  5. [转载]fullPage.js中文api 配置参数~

    fullPage.js中文api 配置参数 选项 类型 默认值 说明 verticalCentered 字符串 true 内容是否垂直居中 resize 布尔值 false 字体是否随着窗口缩放而缩放 ...

  6. Web API的参数、多版本和Filter

    一.关于API的参数a) Web API在WebApiConfig.cs中配置了路由模板,默认为"api/{controller}/{id}",这与MVC路由模板的区别在于没有{a ...

  7. android Observable api请求参数设置注解问题

    android Observable api请求参数设置注解问题 2018-10-29 20:05:24.919 11786-11786/xxx E/wxh: getQuote=USD getBase ...

  8. Revit Family API 创建参考平面

    使用API来编辑族时,使用doc.FamilyCreate.NewReferencePlane();创建参考平面. )         {  ];         }         // canno ...

  9. RDLC中添加参数,用来显示报表中数据集之外的信息。

    我添加了两个参数,首先后台: ReportParameter rp = ,,).ToString()); ReportParameter rp1 = new ReportParameter(" ...

随机推荐

  1. BurpSuite中的安全测试插件推荐

    Burp Suite 是用于攻击web 应用程序的集成平台.它包含了许多工具,并为这些工具设计了许多接口,以促进加快攻击应用程序的过程.所有的工具都共享一个能处理并显示HTTP 消息,持久性,认证,代 ...

  2. 使用NSIS制作安装包

    nsis下载地址:http://www.pc6.com/softview/SoftView_14342.html nsis使用: 启动NSIS程序主界面,选择“可视化脚本编辑器(VNISEdit)”菜 ...

  3. elasticsearch常用配置

    允许外网连接network.host,http.port,network.publish_host,network.bind_host别的机器或者网卡才能访问,否则只能是127.0.0.1或者loca ...

  4. VUE之搭建脚手架

    原文转自http://blog.csdn.net/Shiyaru1314/article/details/54963027 目录(?)[-] 1 安装之前需要检查是否已经安装NodeJS的环境 安装文 ...

  5. JavaScript如何获得input元素value值

    转载地址:http://aquarius-zf.iteye.com/blog/605144 在页面中我们最常见的页面元素就是input了,但是我们如何用JavaScript得到网页input中输入的v ...

  6. 用原生js实现ajax

    // 通过createXHR()函数创建一个XHR对象 function createXHR() { if(window.XMLHttpRequest) { // IE7.Firefox.Opera. ...

  7. google closure 笔记-SOY template

    一 使用js模板 closure template 目前支持Java和js.但是模板语法的设计不依赖于任何现成的语言,所以理论上可以支持任何语言,只是暂时只有java编译器. 使用js模板:编写模板文 ...

  8. Linux 基础——权限管理命令chmod

    一.Linux中的文件权限与目录权限 Linux中定义了3种访问权限,分别是r.w.x.其中r表示对象是可读的,w表示对象是可写的,x表示对象是可执行的,这3种权限组成一组rwx分别对应对象的3个安全 ...

  9. .NetCore下使用Polly结合IHttpClientFactory实现聚合服务

    在使用微服务的过程中经常会遇到这样的情况,就目前我遇到的问题做下分析 情况一: 这里服务对于前后端分离情况来说,多使用查询服务,前端直接获取不同服务的数据展示,如果出现其中的服务失败,对业务数据无影响 ...

  10. 结合IdentityServer4配置Ocelot的Json配置文件管理更新

    Ocelot提供了AddAdministration方法来设置配置路由以及授权方式 services.AddOcelot().AddAdministration("/admin", ...