Revit API创建标注NewTag
start
/// <summary>
/// 创建水管管径标注
/// </summary>
[Transaction(TransactionMode.Manual)]
public class CreatPipeDiameterTag : IExternalCommand
{
#region IExternalCommand Members public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Document doc = uiDoc.Document;//当前活动文档
Autodesk.Revit.DB.View view = uiDoc.ActiveView;//当前活动视图
Selection sel = uiDoc.Selection;//选择集
Transaction ts = new Transaction(doc, "水管管径标记");
try
{
ts.Start();
PipeSelectionFilter psf = new PipeSelectionFilter(doc);
Reference refer = sel.PickObject(ObjectType.Element, psf, "请选择要标注的水管:");
Pipe pipe = doc.GetElement(refer) as Pipe;
if (pipe == null)
{
ts.Dispose();
TaskDialog.Show("RevitMassge", "没有选中水管");
return Result.Failed;
}
//Define tag mode and tag orientation for new tag
TagMode tageMode = TagMode.TM_ADDBY_CATEGORY;
TagOrientation tagOri = TagOrientation.Horizontal;
//Add the tag to the middle of duct
LocationCurve locCurve = pipe.Location as LocationCurve;
XYZ pipeMid = locCurve.Curve.Evaluate(0.275, true);
IndependentTag tag = doc.Create.NewTag(view, pipe, false, tageMode, tagOri, pipeMid);
//遍历类型
FilteredElementCollector filterColl = GetElementsOfType(doc, typeof(FamilySymbol), BuiltInCategory.OST_PipeTags);
//WinFormTools.MsgBox(filterColl.ToElements().Count.ToString());
int elId = ;
foreach (Element el in filterColl.ToElements())
{
if (el.Name == "管道尺寸标记")
elId = el.Id.IntegerValue;
}
tag.ChangeTypeId(new ElementId(elId));
ElementId eId = null;
if (tag == null)
{
ts.Dispose();
TaskDialog.Show("RevitMassge", "创建标注失败!");
return Result.Failed;
}
ICollection<ElementId> eSet = tag.GetValidTypes();
foreach (ElementId item in eSet)
{
if (item.IntegerValue == )
{
eId = item;
}
}
tag = doc.get_Element(eId) as IndependentTag;
}
catch (Exception)
{
ts.Dispose();
return Result.Cancelled;
}
ts.Commit(); return Result.Succeeded;
}
FilteredElementCollector GetElementsOfType(Document doc, Type type, BuiltInCategory bic)
{
FilteredElementCollector collector = new FilteredElementCollector(doc); collector.OfCategory(bic);
collector.OfClass(type); return collector;
}
#endregion
} /// <summary>
///水管选择过滤器
/// </summary>
public class PipeSelectionFilter : ISelectionFilter
{
#region ISelectionFilter Members Document doc = null;
public PipeSelectionFilter(Document document)
{
doc = document;
} public bool AllowElement(Element elem)
{
return elem is Pipe;
} public bool AllowReference(Reference reference, XYZ position)
{
return doc.GetElement(reference) is Pipe;
} #endregion
}
end
Revit API创建标注NewTag的更多相关文章
- Revit API 创建带箭头的标注
[Transaction(TransactionMode.Manual)] [Regeneration(RegenerationOption.Manual)] public class cmd : ...
- Revit api 创建族并加载到当前项目
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- Revit API创建墙的保温层修改墙厚度
start [Transaction(TransactionMode.Manual)] [Regeneration(RegenerationOption.Manual)] / ; ; ...
- Revit API创建标高,单位转换
一业内朋友让我写个快速创建标高的插件. ; ; i <= iNum; i++) { Level level = d ...
- Revit API创建一个拷贝房间内对象布局命令
本课程演示创建一个拷贝房间内对象布局命令,完整演示步骤和代码.这个命令把选中房间内的对象复制到其它选中的一个或多个房间中,而且保持与源房间一致的相对位置.通过本讲座使听众知道创建一个二次开发程序很简单 ...
- Revit API创建几何实体Solid并找到与之相交的元素
几何实体的创建方法之一:构成封闭底面,指定拉伸方向与拉伸高度.GeometryCreationUtilities ; , pt.Y - dBoxLength / , pt.Z); ...
- Revit api 创建楼梯图元
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- Revit API创建详图视图
start //创建详图视图 Transaction ts = new Transaction(doc, "http://greatverve.cnblogs.com"); ts. ...
- Revit通过API创建共享参数
Revit共享参数是通过创建一个.txt类型的文件来保存相关信息,一旦与项目保存完毕之后,共享参数也就变成了项目参数(项目参数无法通过API创建),项目参数是保存在Revit项目里面的,所以此时这个. ...
随机推荐
- 单点登录SSO+鉴权
一.单点登录原理 1.登录 2.注销 --------------------------------------------------------------------------------- ...
- python 全栈开发,Day135(爬虫系列之第2章-BS和Xpath模块)
一.BeautifulSoup 1. 简介 简单来说,Beautiful Soup是python的一个库,最主要的功能是从网页抓取数据.官方解释如下: ''' Beautiful Soup提供一些简单 ...
- 步步为营-72-asp.net简单练习(通过webForm实现一些简单实例)
WebForm成功之处在于:实现的代码后置,和asp相比实现了html代码和C#代码分离.但 aspx和aspx.cs之间的强耦合和性能方面(特别是服务器控件)做的不是很好. 参照步步为营-68完成相 ...
- 步步为营-10-string的简单操作
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Tex ...
- ***php进行支付宝开发中return_url和notify_url的区别分析
本文实例分析了php进行支付宝开发中return_url和notify_url的区别.分享给大家供大家参考.具体分析如下: 在支付宝处理业务中return_url,notify_url是返回些什么状态 ...
- [APIO2011]方格染色
题解: 挺不错的一道题目 首先4个里面只有1个1或者3个1 那么有一个特性就是4个数xor为1 为什么要用xor呢? 在于xor能把相同的数消去 然后用一般的套路 看看确定哪些值能确定全部 yy一下就 ...
- [SDOI2014]数数
题解: 做过ac自动机上dp的这题应该就很容易想到了 首先在ac自动机上搞dp 表示当前考虑了i位,在自动机的j位上 然后转移就可以了 考虑限制 显然是一个数位dp 考虑位数小于n显然满足要求 考虑位 ...
- 百度未授权使用地图API
百度地图管理员的回复:这是KEY服务升级的问题, 给您造成的不便,非常抱歉.但我们昨日已修复,你可以再审核一番.若不可以,请提供一下您的系统ak,邮箱或qq发送至(wangwenhai@baidu.c ...
- Codeforces 1114F Please, another Queries on Array? 线段树
Please, another Queries on Array? 利用欧拉函数的计算方法, 用线段树搞一搞就好啦. #include<bits/stdc++.h> #define LL ...
- unbuntu 18.04 LTS 版 安装Samba服务器
首先需要注意的是,此时服务器的版本是乌班图18.04 LTS Server ,安装配置Samba服务器 . 首先来对当前的软件进行更新. 1 sudo apt-get upgrade 2 sudo ...