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(); } }
public override void Draw() { t_in = Inputs[0] as dynDouble; curve_in = Inputs[1] as dynCurve; if (curve_in != null && t_in != null) { this.point = curve_in.Curve.Evaluate(t_in.D, true); //compute the derivatives and set the axes of the point Transform t = curve_in.Curve.ComputeDerivatives(t_in.D, true); XYZ xaxis = t.BasisX.Normalize(); XYZ yaxis = t.BasisY.Normalize(); if (xaxis.Y == 1.0) { yaxis = new XYZ(1.0, 0.0, 0.0); } else if (xaxis.Y == -1.0) { yaxis = new XYZ(-1.0, 0.0, 0.0); } else if (xaxis.X == -1) { yaxis = new XYZ(0.0, 1.0, 0.0); } else if (xaxis.X == 1) { yaxis = new XYZ(0.0, -1.0, 0.0); } this.xAxis = xaxis; this.yAxis = yaxis; this.up = xAxis.CrossProduct(yaxis); base.Draw(); } }
public override void Draw() { if (Inputs.Count == 3) { x = Inputs[0] as dynDouble; y = Inputs[1] as dynDouble; z = Inputs[2] as dynDouble; if (x != null && y != null && z != null) { this.point = new XYZ(x.D, y.D, z.D); base.Draw(); } } }
public override void Draw() { angle1_in = Inputs[1] as dynDouble; angle2_in = Inputs[2] as dynDouble; radius_in = Inputs[3] as dynDouble; plane_in = Inputs[0] as dynPlane; if (plane_in != null && plane_in.P != null && angle1_in != null && angle2_in != null && radius_in != null) { if (angle2_in.D - angle1_in.D > 1 && radius_in.D > 0) { //convert these to radians double a1 = angle1_in.D * Math.PI / 180; double a2 = angle2_in.D * Math.PI / 180; curve = Settings.Revit.Application.Create.NewArc(plane_in.P, radius_in.D, angle1_in.D, angle2_in.D); base.Draw(); } } }