public override string ToString() { string letterRepresentation = ""; letterRepresentation += ("Letter : " + letter + " letterDirection " + letterDirection + "\nLetter divisor : " + sharedDirection.Divisor + "\nSmaller : " + smaller + "Letter direction length : " + sharedDirection.DirectionLength + "\nOn Plane : " + OnPlane.ToString()); return(letterRepresentation); }
///<summary> This gets called when when the user runs this command.</summary> public override IRhinoCommand.result RunCommand(IRhinoCommandContext context) { OnLine line = new OnLine(); OnPlane plane = new OnPlane(); MRhinoGetPoint gp = new MRhinoGetPoint(); gp.SetCommandPrompt("Start of line"); gp.GetPoint(); if (gp.CommandResult() != IRhinoCommand.result.success) { return(gp.CommandResult()); } line.from = gp.Point(); plane = new OnPlane(RhUtil.RhinoActiveCPlane()); plane.SetOrigin(line.from); gp.SetCommandPrompt("End of line"); gp.Constrain(plane); gp.SetBasePoint(line.from); gp.DrawLineFromPoint(line.from, true); gp.GetPoint(); if (gp.CommandResult() != IRhinoCommand.result.success) { return(gp.CommandResult()); } line.to = plane.ClosestPointTo(gp.Point()); if (!line.IsValid()) { return(IRhinoCommand.result.nothing); } SampleCsDrawArrowheadConduit conduit = new SampleCsDrawArrowheadConduit(plane, line, 1.0); conduit.Enable(); context.m_doc.Redraw(); MRhinoGetString gs = new MRhinoGetString(); gs.SetCommandPrompt("Press <Enter> to continue"); gs.AcceptNothing(); gs.GetString(); conduit.Disable(); context.m_doc.Redraw(); return(IRhinoCommand.result.success); }
///<summary> This gets called when when the user runs this command.</summary> public override IRhinoCommand.result RunCommand(IRhinoCommandContext context) { MRhinoGetObject go = new MRhinoGetObject(); go.SetCommandPrompt("Select rectangular light"); go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.light_object); go.GetObjects(1, 1); if (go.CommandResult() != IRhinoCommand.result.success) { return(go.CommandResult()); } IOnLight light = go.Object(0).Light(); if (null == light) { return(IRhinoCommand.result.failure); } if (!light.IsRectangularLight()) { RhUtil.RhinoApp().Print("Not a rectangular light.\n"); return(IRhinoCommand.result.nothing); } On3dPoint origin = light.Location(); On3dVector xaxis = light.Length(); On3dVector yaxis = light.Width(); OnPlane plane = new OnPlane(origin, xaxis, yaxis); OnInterval x_interval = new OnInterval(0.0, xaxis.Length()); OnInterval y_interval = new OnInterval(0.0, yaxis.Length()); OnMesh mesh = RhUtil.RhinoMeshPlane(plane, x_interval, y_interval, 2, 2); if (null != mesh) { mesh.ConvertQuadsToTriangles(); context.m_doc.AddMeshObject(mesh); context.m_doc.Redraw(); } return(IRhinoCommand.result.cancel); }
private static double GetCurveArea(IOnCurve crv, double tol) { double area = 0.0; if (null != crv && crv.IsClosed()) { OnPlane plane = new OnPlane(); if (crv.IsPlanar(plane, tol)) { OnBoundingBox bbox = crv.BoundingBox(); On3dPoint point = plane.ClosestPointTo(bbox.Center()); OnMassProperties mp = new OnMassProperties(); if (crv.AreaMassProperties(point, plane.Normal(), ref mp)) { area = Math.Abs(mp.Area()); } } } return(area); }
///<summary> This gets called when when the user runs this command.</summary> public override IRhinoCommand.result RunCommand(IRhinoCommandContext context) { OnLine line = new OnLine(); OnPlane plane = new OnPlane(); MRhinoGetPoint gp = new MRhinoGetPoint(); gp.SetCommandPrompt("Start of line"); gp.GetPoint(); if (gp.CommandResult() != IRhinoCommand.result.success) return gp.CommandResult(); line.from = gp.Point(); plane = new OnPlane(RhUtil.RhinoActiveCPlane()); plane.SetOrigin(line.from); gp.SetCommandPrompt("End of line"); gp.Constrain(plane); gp.SetBasePoint(line.from); gp.DrawLineFromPoint(line.from, true); gp.GetPoint(); if (gp.CommandResult() != IRhinoCommand.result.success) return gp.CommandResult(); line.to = plane.ClosestPointTo(gp.Point()); if (!line.IsValid()) return IRhinoCommand.result.nothing; SampleCsDrawArrowheadConduit conduit = new SampleCsDrawArrowheadConduit(plane, line, 1.0); conduit.Enable(); context.m_doc.Redraw(); MRhinoGetString gs = new MRhinoGetString(); gs.SetCommandPrompt("Press <Enter> to continue"); gs.AcceptNothing(); gs.GetString(); conduit.Disable(); context.m_doc.Redraw(); return IRhinoCommand.result.success; }
/// <summary> /// Public constructor /// </summary> public SampleCsDrawArrowheadConduit(OnPlane plane, OnLine line, double scale) : base(new MSupportChannels(MSupportChannels.SC_CALCBOUNDINGBOX | MSupportChannels.SC_DRAWOVERLAY), false) { m_bDraw = false; m_plane = plane; m_line = line; m_arrowhead = new On3dPointArray(); double x = 0, y = 0; m_plane.ClosestPointTo(line.from, ref x, ref y); On2dPoint from = new On2dPoint(x, y); m_plane.ClosestPointTo(line.to, ref x, ref y); On2dPoint to = new On2dPoint(x, y); On2dVector dir = new On2dVector(from - to); dir.Unitize(); m_bDraw = GetArrowHead(dir, from, scale, ref m_arrowhead); }
///<summary> This gets called when when the user runs this command.</summary> public override IRhinoCommand.result RunCommand(IRhinoCommandContext context) { MRhinoGetObject go = new MRhinoGetObject(); go.SetCommandPrompt("Select rectangular light"); go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.light_object); go.GetObjects(1, 1); if (go.CommandResult() != IRhinoCommand.result.success) return go.CommandResult(); IOnLight light = go.Object(0).Light(); if (null == light) return IRhinoCommand.result.failure; if (!light.IsRectangularLight()) { RhUtil.RhinoApp().Print("Not a rectangular light.\n"); return IRhinoCommand.result.nothing; } On3dPoint origin = light.Location(); On3dVector xaxis = light.Length(); On3dVector yaxis = light.Width(); OnPlane plane = new OnPlane(origin, xaxis, yaxis); OnInterval x_interval = new OnInterval(0.0, xaxis.Length()); OnInterval y_interval = new OnInterval(0.0, yaxis.Length()); OnMesh mesh = RhUtil.RhinoMeshPlane(plane, x_interval, y_interval, 2, 2); if (null != mesh) { mesh.ConvertQuadsToTriangles(); context.m_doc.AddMeshObject(mesh); context.m_doc.Redraw(); } return IRhinoCommand.result.cancel; }
private static double GetCurveArea(IOnCurve crv, double tol) { double area = 0.0; if (null != crv && crv.IsClosed()) { OnPlane plane = new OnPlane(); if (crv.IsPlanar(plane, tol)) { OnBoundingBox bbox = crv.BoundingBox(); On3dPoint point = plane.ClosestPointTo(bbox.Center()); OnMassProperties mp = new OnMassProperties(); if (crv.AreaMassProperties(point, plane.Normal(), ref mp)) area = Math.Abs(mp.Area()); } } return area; }
///<summary> This gets called when when the user runs this command.</summary> public override IRhinoCommand.result RunCommand(IRhinoCommandContext context) { // Define geometry for rail and shape curves On3dPoint start_point = new On3dPoint(0, 0, 0); On3dPoint end_point = new On3dPoint(10, 0, 0); OnPlane plane = new OnPlane(OnUtil.On_yz_plane); plane.SetOrigin(start_point); OnCircle circle0 = new OnCircle(plane, 5); plane.SetOrigin(end_point); OnCircle circle1 = new OnCircle(plane, 2); // Build rail and shape curves OnLineCurve line_curve = new OnLineCurve(start_point, end_point); OnArcCurve arc_curve0 = new OnArcCurve(circle0); OnArcCurve arc_curve1 = new OnArcCurve(circle1); // Build poly edge curve MRhinoPolyEdge rail_curve = new MRhinoPolyEdge(); rail_curve.Create(line_curve); // Create sweep arguments MArgsRhinoSweep1 args = new MArgsRhinoSweep1(); // Add rail curve and related settings args.m_rail_curve = rail_curve; args.m_bHaveRailPickPoint = false; args.m_bClosed = false; args.m_bUsePivotPoint = false; // Add shape curves List<OnCurve> shape_curves = new List<OnCurve>(); shape_curves.Add(arc_curve0); shape_curves.Add(arc_curve1); args.m_shape_curves = shape_curves.ToArray(); // Specify parameters on rail closest to shapes args.m_rail_params.Append(rail_curve.Domain()[0]); args.m_rail_params.Append(rail_curve.Domain()[1]); // No starting sweep point args.set_m_bUsePoints(0, 0); // No ending sweep point args.set_m_bUsePoints(1, 0); // 0 = Freeform args.m_style = 0; // 0 = Do Not Simplify args.m_simplify = 0; // Sample point count for rebuilding shapes args.m_rebuild_count = -1; // 0 = don't miter args.m_miter_type = 0; // Standard tolerances args.m_refit_tolerance = context.m_doc.AbsoluteTolerance(); args.m_sweep_tolerance = context.m_doc.AbsoluteTolerance(); args.m_angle_tolerance = context.m_doc.AngleToleranceRadians(); OnBrep[] breps = null; if (RhUtil.RhinoSweep1(ref args, out breps)) { for (int i = 0; i < breps.Length; i++) context.m_doc.AddBrepObject(breps[i]); context.m_doc.Redraw(); } return IRhinoCommand.result.success; }
///<summary> This gets called when when the user runs this command.</summary> public override IRhinoCommand.result RunCommand(IRhinoCommandContext context) { // Define geometry for rail and shape curves On3dPoint start_point = new On3dPoint(0, 0, 0); On3dPoint end_point = new On3dPoint(10, 0, 0); OnPlane plane = new OnPlane(OnUtil.On_yz_plane); plane.SetOrigin(start_point); OnCircle circle0 = new OnCircle(plane, 5); plane.SetOrigin(end_point); OnCircle circle1 = new OnCircle(plane, 2); // Build rail and shape curves OnLineCurve line_curve = new OnLineCurve(start_point, end_point); OnArcCurve arc_curve0 = new OnArcCurve(circle0); OnArcCurve arc_curve1 = new OnArcCurve(circle1); // Build poly edge curve MRhinoPolyEdge rail_curve = new MRhinoPolyEdge(); rail_curve.Create(line_curve); // Create sweep arguments MArgsRhinoSweep1 args = new MArgsRhinoSweep1(); // Add rail curve and related settings args.m_rail_curve = rail_curve; args.m_bHaveRailPickPoint = false; args.m_bClosed = false; args.m_bUsePivotPoint = false; // Add shape curves List <OnCurve> shape_curves = new List <OnCurve>(); shape_curves.Add(arc_curve0); shape_curves.Add(arc_curve1); args.m_shape_curves = shape_curves.ToArray(); // Specify parameters on rail closest to shapes args.m_rail_params.Append(rail_curve.Domain()[0]); args.m_rail_params.Append(rail_curve.Domain()[1]); // No starting sweep point args.set_m_bUsePoints(0, 0); // No ending sweep point args.set_m_bUsePoints(1, 0); // 0 = Freeform args.m_style = 0; // 0 = Do Not Simplify args.m_simplify = 0; // Sample point count for rebuilding shapes args.m_rebuild_count = -1; // 0 = don't miter args.m_miter_type = 0; // Standard tolerances args.m_refit_tolerance = context.m_doc.AbsoluteTolerance(); args.m_sweep_tolerance = context.m_doc.AbsoluteTolerance(); args.m_angle_tolerance = context.m_doc.AngleToleranceRadians(); OnBrep[] breps = null; if (RhUtil.RhinoSweep1(ref args, out breps)) { for (int i = 0; i < breps.Length; i++) { context.m_doc.AddBrepObject(breps[i]); } context.m_doc.Redraw(); } return(IRhinoCommand.result.success); }
///<summary> This gets called when when the user runs this command.</summary> public override IRhinoCommand.result RunCommand(IRhinoCommandContext context) { // Select a curve object MRhinoGetObject go = new MRhinoGetObject(); go.SetCommandPrompt("Select curve"); go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.curve_object); go.GetObjects(1, 1); if (go.CommandResult() != IRhinoCommand.result.success) { return(go.CommandResult()); } // Validate the selection IRhinoObject obj = go.Object(0).Object(); if (null == obj) { return(IRhinoCommand.result.failure); } // Get the active view MRhinoView view = RhUtil.RhinoApp().ActiveView(); if (null == view) { return(IRhinoCommand.result.failure); } // Get the construction plane from the active view OnPlane plane = new OnPlane(view.ActiveViewport().ConstructionPlane().m_plane); // Create a construction plane aligned bounding box OnBoundingBox bbox = new OnBoundingBox(); IRhinoObject[] objs = new IRhinoObject[1] { obj }; bool rc = RhUtil.RhinoGetTightBoundingBox(objs, ref bbox, false, plane); if (rc == false) { return(IRhinoCommand.result.failure); } // Validate bounding box if (0 != bbox.IsDegenerate()) { RhUtil.RhinoApp().Print("Curve's tight bounding box is degenerate.\n"); return(IRhinoCommand.result.nothing); } // ON_BrepBox wants 8 points defining the box corners // arranged in this order: // // v7______________v6 // |\ |\ // | \ | \ // | \ _____________\ // | v4 | v5 // | | | | // | | | | // v3---|---------v2 | // \ | \ | // \ | \ | // \ | \ | // \v0____________\v1 // On3dPoint[] box_corners = new On3dPoint[8]; box_corners[0] = bbox.Corner(0, 0, 0); box_corners[1] = bbox.Corner(1, 0, 0); box_corners[2] = bbox.Corner(1, 1, 0); box_corners[3] = bbox.Corner(0, 1, 0); box_corners[4] = bbox.Corner(0, 0, 1); box_corners[5] = bbox.Corner(1, 0, 1); box_corners[6] = bbox.Corner(1, 1, 1); box_corners[7] = bbox.Corner(0, 1, 1); // Transform points to the world-xy plane OnXform p2w = new OnXform(); p2w.ChangeBasis(plane, OnUtil.On_xy_plane); for (int i = 0; i < 8; i++) { box_corners[i].Transform(p2w); } // Make a brep box OnBrep brep = OnUtil.ON_BrepBox(box_corners); if (null != brep) { context.m_doc.AddBrepObject(brep); context.m_doc.Redraw(); } return(IRhinoCommand.result.success); }
///<summary> This gets called when when the user runs this command.</summary> public override IRhinoCommand.result RunCommand(IRhinoCommandContext context) { // Select a curve object MRhinoGetObject go = new MRhinoGetObject(); go.SetCommandPrompt("Select curve"); go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.curve_object); go.GetObjects(1, 1); if (go.CommandResult() != IRhinoCommand.result.success) return go.CommandResult(); // Validate the selection IRhinoObject obj = go.Object(0).Object(); if (null == obj) return IRhinoCommand.result.failure; // Get the active view MRhinoView view = RhUtil.RhinoApp().ActiveView(); if (null == view) return IRhinoCommand.result.failure; // Get the construction plane from the active view OnPlane plane = new OnPlane(view.ActiveViewport().ConstructionPlane().m_plane); // Create a construction plane aligned bounding box OnBoundingBox bbox = new OnBoundingBox(); IRhinoObject[] objs = new IRhinoObject[1] { obj }; bool rc = RhUtil.RhinoGetTightBoundingBox(objs, ref bbox, false, plane); if (rc == false) return IRhinoCommand.result.failure; // Validate bounding box if (0 != bbox.IsDegenerate()) { RhUtil.RhinoApp().Print("Curve's tight bounding box is degenerate.\n"); return IRhinoCommand.result.nothing; } // ON_BrepBox wants 8 points defining the box corners // arranged in this order: // // v7______________v6 // |\ |\ // | \ | \ // | \ _____________\ // | v4 | v5 // | | | | // | | | | // v3---|---------v2 | // \ | \ | // \ | \ | // \ | \ | // \v0____________\v1 // On3dPoint[] box_corners = new On3dPoint[8]; box_corners[0] = bbox.Corner(0, 0, 0); box_corners[1] = bbox.Corner(1, 0, 0); box_corners[2] = bbox.Corner(1, 1, 0); box_corners[3] = bbox.Corner(0, 1, 0); box_corners[4] = bbox.Corner(0, 0, 1); box_corners[5] = bbox.Corner(1, 0, 1); box_corners[6] = bbox.Corner(1, 1, 1); box_corners[7] = bbox.Corner(0, 1, 1); // Transform points to the world-xy plane OnXform p2w = new OnXform(); p2w.ChangeBasis(plane, OnUtil.On_xy_plane); for (int i = 0; i < 8; i++) box_corners[i].Transform(p2w); // Make a brep box OnBrep brep = OnUtil.ON_BrepBox(box_corners); if (null != brep) { context.m_doc.AddBrepObject(brep); context.m_doc.Redraw(); } return IRhinoCommand.result.success; }