public override void Draw() { face_in = Inputs[0] as dynFaceBySelection; u_in = Inputs[1] as dynDouble; v_in = Inputs[2] as dynDouble; offset_in = Inputs[3] as dynDouble; if (face_in != null && u_in != null && v_in != null && offset_in!=null) { //Use 0 for u coordinate and 1 for v coordinate. BoundingBoxUV bbuv = face_in.Face.GetBoundingBox(); double uPer = bbuv.Max.U; double vPer = bbuv.Max.V; //convert the doubles to ints int uDiv = Convert.ToInt16(u_in.D); int vDiv = Convert.ToInt16(v_in.D); double perDivU = uPer / uDiv; double perDivV = vPer / vDiv; for (int i = 0; i <= uDiv-1; i++) { for (int j = 0; j <= vDiv; j++) { UV uv1 = new UV(i * perDivU, j * perDivV); UV uv2 = new UV((i+1) * perDivU, j * perDivV); XYZ normal1 = face_in.Face.ComputeNormal(uv1).Normalize(); XYZ normal2 = face_in.Face.ComputeNormal(uv2).Normalize(); XYZ pt1 = face_in.Face.Evaluate(uv1) + normal1 * offset_in.D; XYZ pt2 = face_in.Face.Evaluate(uv2) + normal2 * offset_in.D; //SketchPlane sp = dynUtils.CreateSketchPlaneForModelCurve(Settings.Revit, Settings.Doc, // pt1, pt2); XYZ xAxis = (pt2 - pt1).Normalize(); XYZ planeNorm = xAxis.CrossProduct(normal1); SketchPlane sp = Settings.Doc.Document.Create.NewSketchPlane(new Plane(planeNorm, pt1)); Curve c = Settings.Revit.Application.Create.NewLineBound(pt1, pt2); //ModelCurve mc = Settings.Doc.Document.Create.NewModelCurve(c, sp); dynCurveSimple cv = new dynCurveSimple(Settings); cv.Curve = c; cv.Sketch = sp; //if (mc != null) //{ // this.Elements.Add(mc); //} if (cv != null) { this.Elements.Add(cv); } } } for (int i = 0; i <= uDiv; i++) { for (int j = 0; j <= vDiv - 1; j++) { UV uv1 = new UV(i * perDivU, j * perDivV); UV uv2 = new UV(i*perDivU, (j+1) * perDivV); XYZ normal1 = face_in.Face.ComputeNormal(uv1).Normalize(); XYZ normal2 = face_in.Face.ComputeNormal(uv2).Normalize(); XYZ pt1 = face_in.Face.Evaluate(uv1) + normal1 * offset_in.D; XYZ pt2 = face_in.Face.Evaluate(uv2) + normal2 * offset_in.D; //SketchPlane sp = dynUtils.CreateSketchPlaneForModelCurve(Settings.Revit, Settings.Doc, // pt1, pt2); XYZ xAxis = (pt2 - pt1).Normalize(); XYZ planeNorm = xAxis.CrossProduct(normal1); SketchPlane sp = Settings.Doc.Document.Create.NewSketchPlane(new Plane(planeNorm, pt1)); Curve c = Settings.Revit.Application.Create.NewLineBound(pt1, pt2); //ModelCurve mc = Settings.Doc.Document.Create.NewModelCurve(c, sp); dynCurveSimple cv = new dynCurveSimple(Settings); cv.Curve = c; cv.Sketch = sp; //if (mc != null) //{ // this.Elements.Add(mc); //} if (cv != null) { this.Elements.Add(cv); } } } base.Draw(); } }
public override void Draw() { face_in = Inputs[0] as dynFaceBySelection; u_in = Inputs[1] as dynDouble; v_in = Inputs[2] as dynDouble; offset_in = Inputs[3] as dynDouble; if (face_in != null && u_in != null && v_in != null && offset_in!=null) { //Use 0 for u coordinate and 1 for v coordinate. BoundingBoxUV bbuv = face_in.Face.GetBoundingBox(); double uPer = bbuv.Max.U; double vPer = bbuv.Max.V; //convert the doubles to ints int uDiv = Convert.ToInt16(u_in.D); int vDiv = Convert.ToInt16(v_in.D); double perDivU = uPer / uDiv; double perDivV = vPer / vDiv; for (int i = 0; i <=uDiv; i++) { for (int j = 0; j <= vDiv; j++) { UV uv1 = new UV(i * perDivU, j * perDivV); Transform t = face_in.Face.ComputeDerivatives(uv1); XYZ pt1 = face_in.Face.Evaluate(uv1) + t.BasisZ.Normalize() * offset_in.D; dynPointSimple pt = new dynPointSimple(Settings); pt.point = pt1; pt.xAxis = t.BasisX.Normalize(); pt.yAxis = t.BasisY.Normalize(); pt.up = t.BasisZ.Normalize(); if (pt != null) { this.Elements.Add(pt); } } } base.Draw(); } }