/// <summary>
/// 内建模型(放样)
/// </summary>
private static void CreateSphereDirectShape(double MaxHeight, double MinHeight, double Width,
CurveLoop cl)
{
var doc = RvtExternalData.Current.Doc;
var cv = cl.GetByIndexT<Curve>(0);
if (cv == null)
return;
XYZ vec;
if (cv is Arc)
{
Arc ac = cv as Arc;
vec = ac.StartPoint().Subtract(ac.Center).Normalize();
}
else
{
vec = cv.UnitVector().VectorRotate(-Math.PI / 2);
}
//创建放样时用到得参数pathAttachmentParam
double param = cv.GetEndParameter(0);
//轮廓线
CurveArray curveArray = new CurveArray();
XYZ xYZ = cv.StartPoint();
XYZ xYZ2 = xYZ.OffsetPoint(vec, Width);
XYZ xYZ3 = xYZ2.OffsetPoint(XYZ.BasisZ, MaxHeight);
XYZ xYZ4 = xYZ.OffsetPoint(XYZ.BasisZ, MinHeight);
curveArray.Append(Line.CreateBound(xYZ, xYZ2));
curveArray.Append(Line.CreateBound(xYZ2, xYZ3));
curveArray.Append(Line.CreateBound(xYZ3, xYZ4));
curveArray.Append(Line.CreateBound(xYZ4, xYZ));
List<CurveLoop> profileloops = new List<CurveLoop>();
profileloops.Add(curveArray.ToCurveLoop());
Transaction tran = wrapper.NewTransaction;
tran.Start();
try
{
Solid solid = GeometryCreationUtilities.CreateSweptGeometry(cl, 0, param, profileloops/*, option*/);
DirectShape ds = DirectShape.CreateElement(doc, new ElementId(BuiltInCategory.OST_GenericModel));
if (ds != null)
{
ds.AppendShape(new List<GeometryObject>() { solid });
}
tran.Commit();
}
catch (Autodesk.Revit.Exceptions.ArgumentException ex)
{
string msg = ex.Message;
tran.RollBack();
}
catch (Exception ex)
{
string msg = ex.Message;
tran.RollBack();
}
}
revit二次开发 内建模型之放样
猜你喜欢
转载自blog.csdn.net/zouzouol/article/details/84197270
今日推荐
周排行