【Revit】族及项目下创建拉伸,融合,放样
作者:互联网
族:
public static Element GetHostInstance(Document doc, CurveArrArray curveArrs, XYZ faceNormal, double start, double end, bool IsSolid = true) { Element element = null; #if Revit2018 element = doc.FamilyCreate.NewExtrusion(IsSolid, curveArrs, SketchPlane.Create(doc, Plane.CreateByNormalAndOrigin(faceNormal, new XYZ(start * faceNormal.X, start * faceNormal.Y, start * faceNormal.Z).ConvertToInternalUnits())), Math.Abs(end - start).ConvertToInternalUnits()); #elif Revit2019 element = doc.FamilyCreate.NewExtrusion(IsSolid, curveArrs, SketchPlane.Create(doc, Plane.CreateByNormalAndOrigin(faceNormal, new XYZ(start * faceNormal.X, start * faceNormal.Y, start * faceNormal.Z).ConvertToInternalUnits())), Math.Abs(end - start).ConvertToInternalUnits()); #else element = doc.FamilyCreate.NewExtrusion(IsSolid, curveArrs, SketchPlane.Create(doc, new Plane(faceNormal, new XYZ(start * faceNormal.X, start * faceNormal.Y, start * faceNormal.Z).ConvertToInternalUnits())), Math.Abs(end - start).ConvertToInternalUnits()); #endif return element; } public static Extrusion CreateExtrusion(Document doc, CurveArrArray curveArrs, XYZ faceNormal, double start, double end, bool IsSolid = true) { return GetHostInstance(doc, curveArrs, faceNormal, start, end, IsSolid) as Extrusion; } public static Blend CreateBlend(Document doc, CurveArray topCurves, CurveArray bottomCurves, XYZ faceNormal, double start, bool IsSolid = true) { var plane = CreateSketchPlane(doc, faceNormal, start); var blend = doc.FamilyCreate.NewBlend(IsSolid, topCurves, bottomCurves, plane); return blend; } public static Sweep CreateSweep(Document doc, CurveArrArray profileArray, XYZ start, XYZ end, bool IsSolid = true) { XYZ xvec = new XYZ(end.X - start.X, end.Y - start.Y, 0).Normalize(); XYZ yvec = XYZ.BasisZ; start = start.ConvertToInternalUnits(); end = end.ConvertToInternalUnits(); var plane = SketchPlane.Create(doc, CreatePlane(xvec, yvec, start)); SweepProfile profile = doc.Application.Create.NewCurveLoopsProfile(profileArray); Curve curve = Line.CreateBound(start, end); CurveArray curves = new CurveArray(); curves.Append(curve); return doc.FamilyCreate.NewSweep(IsSolid, curves, plane, profile, 0, ProfilePlaneLocation.Start); } public static SketchPlane CreateSketchPlane(Document doc, XYZ faceNormal, XYZ origin) { SketchPlane element = null; #if Revit2018 element = SketchPlane.Create(doc, Plane.CreateByNormalAndOrigin(faceNormal, origin)); #elif Revit2019 element = SketchPlane.Create(doc, Plane.CreateByNormalAndOrigin(faceNormal, origin)); #else element = SketchPlane.Create(doc, new Plane(faceNormal, origin)); #endif return element; } public static SketchPlane CreateSketchPlane(Document doc, XYZ faceNormal, double start) { SketchPlane element = null; #if Revit2018 element = SketchPlane.Create(doc, Plane.CreateByNormalAndOrigin(faceNormal, new XYZ(start * faceNormal.X, start * faceNormal.Y, start * faceNormal.Z).ConvertToInternalUnits())); #elif Revit2019 element = SketchPlane.Create(doc, Plane.CreateByNormalAndOrigin(faceNormal, new XYZ(start * faceNormal.X, start * faceNormal.Y, start * faceNormal.Z).ConvertToInternalUnits())); #else element = SketchPlane.Create(doc, new Plane(faceNormal, new XYZ(start * faceNormal.X, start * faceNormal.Y, start * faceNormal.Z).ConvertToInternalUnits())); #endif return element; }
项目:
标签:拉伸,SketchPlane,doc,XYZ,放样,faceNormal,start,element,Revit 来源: https://www.cnblogs.com/mqxs/p/12652036.html