下载app免费领取会员
文章来源:万联Revit开发

首先说一下Revit体量里的放样都有哪些api:
1、通过轮廓和方向生成几何体
FormNewExtrusionForm(boolisSolid,ReferenceArrayprofile,DB.XYZdirection);
2、通过轮廓线生成面
FormNewFormByCap(boolisSolid,ReferenceArrayprofile);
3、通过面和向量生成体
FormNewFormByThickenSingleSurface(boolisSolid,FormsingleSurfaceForm,DB.XYZthickenDir);
4、通过轮廓组生成体
FormNewLoftForm(boolisSolid,ReferenceArrayArrayprofiles);
5、通过放样路径和轮廓组生成几何体
FormNewSweptBlendForm(boolisSolid,ReferenceArraypath,ReferenceArrayArrayprofiles);
这里我们使用NewSweptBlend来根据某条曲线的路径生成对应截面的体量模型。
方法介绍如下:
public SweptBlend NewSweptBlend(
bool isSolid,
Curve path,
SketchPlane pathPlane,
SweepProfile bottomProfile,
SweepProfile topProfile
)
参数说明
isSolid
类型:System布尔值
指示放样模型是“实心”还是“虚心”。
路径
类型:Autodesk.Revit.DBCurve
放样模型的路径。路径应该是一条曲线。或者,路径可以是一条草绘曲线,并且该曲线不需要引用现有几何图形。
路径平面
类型:Autodesk.Revit.DBSketchPlane
路径的草图平面。当您要创建位于现有平面上的2D路径时,使用此选项。可以是从几何图形获得的曲线,或引用的曲线。
bottomProfile
类型:Autodesk.Revit.DBSweepProfile
放样模型的底部形状。它应该是一个曲线环。轮廓必须位于XY平面中。
topProfile
类型:Autodesk.Revit.DBSweepProfile
放样模型的顶部形状。它应该是一个曲线环。轮廓必须位于XY平面中。
例子:
注意:此方法必须要在族文档里执行,不能在项目文档执行。
private SweptBlend SweptBlend(Autodesk.Revit.DB.Document document, SketchPlane sketchPlane){SweptBlend newSweptBlend = null;// make sure we have a family documentif (true == document.IsFamilyDocument){// top and bottom profiles and path curveXYZ pnt1 = new XYZ(0, 0, 0);XYZ pnt2 = new XYZ(1, 0, 0);XYZ pnt3 = new XYZ(1, 1, 0);XYZ pnt4 = new XYZ(0, 1, 0);XYZ pnt5 = new XYZ(0, 0, 1);CurveArrArray arrarr1 = new CurveArrArray();CurveArray arr1 = new CurveArray();arr1.Append(Line.Bound(pnt1, pnt2));arr1.Append(Line.Bound(pnt2, pnt3));arr1.Append(Line.Bound(pnt3, pnt4));arr1.Append(Line.Bound(pnt4, pnt1));arrarr1.Append(arr1);XYZ pnt6 = new XYZ(0.5, 0, 0);XYZ pnt7 = new XYZ(1, 0.5, 0);XYZ pnt8 = new XYZ(0.5, 1, 0);XYZ pnt9 = new XYZ(0, 0.5, 0);CurveArrArray arrarr2 = new CurveArrArray();CurveArray arr2 = new CurveArray();arr2.Append(Line.Bound(pnt6, pnt7));arr2.Append(Line.Bound(pnt7, pnt8));arr2.Append(Line.Bound(pnt8, pnt9));arr2.Append(Line.Bound(pnt9, pnt6));arrarr2.Append(arr2);SweepProfile bottomProfile = document.Application..NewCurveLoopsProfile(arrarr1);SweepProfile topProfile = document.Application..NewCurveLoopsProfile(arrarr2);XYZ pnt10 = new XYZ(5, 0, 0);XYZ pnt11 = new XYZ(0, 20, 0);Curve curve = Line.Bound(pnt10, pnt11);// here rectangular swept blendnewSweptBlend = document.Family.NewSweptBlend(true, curve, sketchPlane, bottomProfile, topProfile);if (null != newSweptBlend){// move to proper placeXYZ transPoint1 = new XYZ(11, 32, 0);ElementTransformUtils.MoveElement(document, newSweptBlend.Id, transPoint1);}else{throw new Exception("Failed to new SweptBlend.");}}else{throw new Exception("Please open a Family document before invoking this command.");}return newSweptBlend;}

本文版权归腿腿教学网及原创作者所有,未经授权,谢绝转载。
上一篇:CAD教程 | 视频教程:解决CAD偏移距离与实际数据不匹配的问题
推荐专题