Revit编程修改板的边界转
来源:互联网 发布:仿真分析软件 matlab 编辑:程序博客网 时间:2024/06/08 06:11
Revit didn’t expose the API to edit floors/slabs boundary by now. Here introduce a trick to edit the boundary.
For a Revit slab or floor, there are mapping model lines to representing the boundary of tha slab. If a floor boundary has 6 segments, there are 6 corresponding model lines for this floor. When we change those model line's position or shape, the slab or floor's shape will be updated accordingly.
There probably are many model lines in a document. How can we find the model lines that representing the slab is the key point.
Here is the solution: You need to create a tempt transaction. During this temp transaction, delete the target slab by Document.Delete() method. This method will return all the deleted elements' ids after the slab is deleted. So the slab's boundary model line can be find by iterating all the return id (get the element from those ids and compare the object type if they are ModelLine class). Finally abort this temp transaction.
After get the boundary's boundary model lines, you can change the model line's shape by changing those ModelLine object ( use this method
LocationCurve lCurve = modelLine.Location as LocationCurve;
lCurve.Curve = newcurve.
I just did a very quick test, this works.
Here is the complete command code.
For simplicity, it just moves the floor by creating new boundary lines by moving the old segment. Here suppose the segment lines are all straight lines.
[Autodesk.Revit.Attributes.Transaction(
Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class ChangeFloor : IExternalCommand
{
public Autodesk.Revit.UI.Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
Document doc = commandData.Application.ActiveUIDocument.Document;
Autodesk.Revit.UI.Selection.Selection sel =
commandData.Application.ActiveUIDocument.Selection;
Reference ref1 = sel.PickObject (Autodesk.Revit.UI.Selection.ObjectType.Element,
"Please pick a floor to edit");
Floor f = doc.GetElement(ref1) as Floor;
Transaction transTemp = new Transaction(doc);
transTemp.Start ("tempDelete");
ICollection<ElementId> ids = doc.Delete(f);
transTemp.RollBack ();
List<ModelLine> mLines = new List<ModelLine>();
foreach (ElementId id in ids)
{
Element ele = doc.GetElement (id);
if (ele is ModelLine)
{
mLines.Add(ele as ModelLine);
}加盟网www.30jm.com加盟网
}
Transaction trans = new Transaction(doc);
trans.Start("ChangeFloor");
//
foreach (ModelLine mline in mLines)
{
LocationCurve lCurve = mline.Location as LocationCurve;
Line c = lCurve.Curve as Line;
XYZ pt1 = c.GetEndPoint(0);
XYZ pt2 = c.GetEndPoint(1);
Transform transform = Transform.CreateTranslation(
new XYZ(1, 1, 0)); //move the line.
XYZ pt1New = transform.OfPoint (pt1);
XYZ pt2New = transform.OfPoint (pt2);
Line newLine = Line.CreateBound(pt1New, pt2New);
lCurve.Curve = newLine;
}
trans.Commit ();
return Result.Succeeded;
}
}
}
- Revit编程修改板的边界转
- Revit编程修改板的边界(含完整源代码)
- 如何编程访问和修改Revit项目的单位信息
- 编程如何修改Revit族类型名称
- Revit开发之参数的修改实例
- 编程调用Revit自己提供的命令
- 编程调用Revit自己提供的命令
- Building Coder(Revit 二次开发)- 关于楼板边界的重新思考
- Revit开发之获取房间边界
- revit 二次开发 如何修改元素的表面颜色
- Revit 编程获取墙侧面的两种方法
- 如何编程创建Revit里面的视图过滤器对象
- 编程读取Revit中材料的渲染属性
- Revit编程如何获取内置参数对应的中文字符串?
- Building Coder(Revit 二次开发)- 图形化显示区域边界
- Revit中Dynamo编程——Python脚本编程与RevitAPI交互的注意事项
- Revit 二次开发视频讲座下载: Revit界面编程
- 如何修改Revit中墙,梁,管道等的端点位置。实例代码演示修改管道的倾斜角度
- C++文件读写详解(ofstream,ifstream,fstream)
- JAVA 中的四种解析XML方式
- 转载个天气的信息把
- Lowering the Latency
- Azure学习笔记:Cloud Service(4)
- Revit编程修改板的边界转
- JAVA 中的四种解析XML方式
- 用Linux命令行生成随机密码的十种方法
- MyEclipse10.1正式版官网下载(附Win+Llinux激活方法、汉化包)
- Activity的四种launchMode
- JAVA 中的四种解析XML方式
- QOS流量整形
- Centos6.4 nginx启动错误
- C++临时对象