Revit Family API 添加参数与尺寸标注
使用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 添加参数与尺寸标注的更多相关文章
- Revit Family API 添加类型
FamilyManager.NewType("");添加新类型,然后设置参数,就是为新类型设置参数. [TransactionAttribute(Autodesk.Revit.At ...
- Revit Family API 添加对齐
没测试成功,留待以后研究. [TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)] ; ; i < nV ...
- Revit Family API 添加几何实体
先创建一个封闭曲线createProfileLShape();再创建实体,这里需要手工画一个参考平面; ; i < nVerts; ++i) { Line l ...
- Revit Family API 添加材质参数设置可见性
start //添加类型 void AddType(FamilyManager familyMgr, string name, double w, double d) { FamilyType ...
- [转载]fullPage.js中文api 配置参数~
fullPage.js中文api 配置参数 选项 类型 默认值 说明 verticalCentered 字符串 true 内容是否垂直居中 resize 布尔值 false 字体是否随着窗口缩放而缩放 ...
- Web API的参数、多版本和Filter
一.关于API的参数a) Web API在WebApiConfig.cs中配置了路由模板,默认为"api/{controller}/{id}",这与MVC路由模板的区别在于没有{a ...
- android Observable api请求参数设置注解问题
android Observable api请求参数设置注解问题 2018-10-29 20:05:24.919 11786-11786/xxx E/wxh: getQuote=USD getBase ...
- Revit Family API 创建参考平面
使用API来编辑族时,使用doc.FamilyCreate.NewReferencePlane();创建参考平面. ) { ]; } // canno ...
- RDLC中添加参数,用来显示报表中数据集之外的信息。
我添加了两个参数,首先后台: ReportParameter rp = ,,).ToString()); ReportParameter rp1 = new ReportParameter(" ...
随机推荐
- springboot整合rabbitmq客户端连接报超时异常问题解决:An unexpected connection driver error occured java.net.SocketException: Socket Closed,java.util.concurrent.TimeoutException
我用的是springboot2.0.6版本,对应的ampq也是2.0.6版本,然后启动一直报: 还有java.util.concurrent.TimeoutException, 用户授权什么的都对,很 ...
- 【CTF WEB】服务端请求伪造
服务端请求伪造 如你所愿,这次可以读取所有的图片,但是域名必须是www开头 测试方法 POST /index.php HTTP/1.1 Host: 218.2.197.236:27375 Conten ...
- sort命令的k选项大讨论【转】
本原创文章属于<Linux大棚>博客,博客地址为http://roclinux.cn.文章作者为rocrocket. 为了防止某些网站的恶性转载,特在每篇文章前加入此信息,还望读者体谅. ...
- VMware下centos桥接模式静态ip配置
声明:本文转载自http://blog.csdn.net/ltr15036900300/article/details/48828207,非原创. 一.配置虚拟机centos网络 备份网络文件 [ro ...
- MAVEN:不能互相引用
工程A,工程B,工程C,这三个工程:C依赖B,B依赖A,这是没有问题的. 但是不能A依赖B,B又依赖A,这是不允许的.
- 001_Eclipse编写第一个Java程序
1 下载并安装jdk 2 下载较新版本的eclipse,eclipse都是非安装版的,解压缩即可. 3 双击eclipse.exe,打开elipse软件 4 FileàNewàProject 5 选择 ...
- 把任意exe程序注册成windows系统服务
某gae代理软件每次开机都需要手动启动,就算添加成开机启动项,在win8.1下权限的管理更加严格,开机时并不能成功启动软件(无人值守时开机),因此在网上搜索把exe注册成系统服务的办法,找到论坛两个帖 ...
- Intellij Idea启用Git可视化界面
第一步. 第二步. 然后点击OK 验证
- 【BZOJ】3683: Falsita
题解 这道题维护方法比较简单,也有点奇妙 我们可以很容易求出经过所有点的路径条数,和初始时分子的大小 然后单点修改的时候,相当于给当前点\(v\)加上\(delta * (siz[v] - 1)\) ...
- Linux下多节点SSH无密码互联实现
需求:有3个主机192.168.0.191.192.168.0.192.192.168.0.193,需要实现无密码ssh互联访问 我使用的是root用户进行操作的: 1.每个节点分别检查是否安装ope ...