Revit API画垂直于风管的风管
start
url:http://greatverve.cnblogs.com/p/Curve-Project.html
/// <summary>
/// 选择风管与风管外一点,画与风管垂直的风管。
/// </summary>
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class cmd : IExternalCommand
{
public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elements)
{
UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
UIApplication uiApp = cmdData.Application;
Document doc = uiDoc.Document;
Selection selection = uiDoc.Selection;
Transaction ts = new Transaction(doc, "http://revit.5d6d.com");
ts.Start();
//得到一种风管类型
DuctType ductType = null;
FilteredElementCollector collector = new FilteredElementCollector(doc);
collector.OfClass(typeof(DuctType));
foreach (Element el in collector.ToElements())
{
ductType = el as DuctType;
break;
}
//
Reference refDuct = selection.PickObject(ObjectType.Element, "选择一根风管:");
Duct duct = doc.GetElement(refDuct) as Duct;
XYZ xyz = selection.PickPoint();//选择一点
LocationCurve lCurve = duct.Location as LocationCurve;
IntersectionResult interResult = lCurve.Curve.Project(xyz);//点在直线上的投影
if (interResult != null)
{
doc.Create.NewDuct(xyz, interResult.XYZPoint, ductType);
}
ts.Commit();
return Result.Succeeded;
}
}
/// 选择风管与风管外一点,画与风管垂直的风管。
/// </summary>
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class cmd : IExternalCommand
{
public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elements)
{
UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
UIApplication uiApp = cmdData.Application;
Document doc = uiDoc.Document;
Selection selection = uiDoc.Selection;
Transaction ts = new Transaction(doc, "http://revit.5d6d.com");
ts.Start();
//得到一种风管类型
DuctType ductType = null;
FilteredElementCollector collector = new FilteredElementCollector(doc);
collector.OfClass(typeof(DuctType));
foreach (Element el in collector.ToElements())
{
ductType = el as DuctType;
break;
}
//
Reference refDuct = selection.PickObject(ObjectType.Element, "选择一根风管:");
Duct duct = doc.GetElement(refDuct) as Duct;
XYZ xyz = selection.PickPoint();//选择一点
LocationCurve lCurve = duct.Location as LocationCurve;
IntersectionResult interResult = lCurve.Curve.Project(xyz);//点在直线上的投影
if (interResult != null)
{
doc.Create.NewDuct(xyz, interResult.XYZPoint, ductType);
}
ts.Commit();
return Result.Succeeded;
}
}
我这个博客废弃不用了,今天想寻找外链的时候,突然想到这个博客权重很高。
有需要免费外链的,留言即可,我准备把这个博客变成免费的友情链接站点。