Ejemplo n.º 1
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Variables
            List <V2GPrintable> printables = new List <V2GPrintable>();
            V2GSettings         settings   = new V2GSettings();

            // Get Data
            DA.GetDataList(0, printables);
            DA.GetData(1, ref settings);
            //if (!DA.GetData(1, ref settings))
            //{
            //   settings = new V2GSettings();
            // }

            // Stuff
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            // Create Printer and adjust settings
            V2GState printer = new V2GState();

            printer.SetSettings(settings);

            // Create Model
            V2GModel model = new V2GModel();

            // Append PrintPolylines
            foreach (V2GPrintable printable in printables)
            {
                if (printable is V2GPrintPolyline)
                {
                    model.AppendAsPath(printable as Voxel2GCodeCore.Geometry.V2GPrintPolyline);
                }
                else if (printable is V2GPrintPosition)
                {
                    /// TODO: implement model.AppendAsPath(V2GPrintPosition position) { }
                }
            }

            model.AppendAsRelativeMovement(new V2GPrintPosition(0, 0, 10.0), 0, 7200);

            // Generate GCode
            model.GenerateGCode(sb, printer);

            // Set Data
            DA.SetData(0, sb.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Printables"></param>
        /// <param name="Settings"></param>
        /// <param name="IsVerbose"></param>
        /// <returns name="GCode">Printable GCode</returns>

        public static string Printer(
            List <V2GPrintPolyline> Printables,
            [DefaultArgumentAttribute("Voxel2GCodeZeroTouch.GetUnsetValue()")] object Settings,
            [DefaultArgumentAttribute("Voxel2GCodeZeroTouch.GetUnsetValue()")] bool IsVerbose)
        {
            // Stuff
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            // Create State
            V2GState printer = new V2GState();

            if (IsSet(IsVerbose))
            {
                printer.settings.IsVerbose = (bool)IsVerbose;
            }
            if (IsSet(Settings))
            {
                printer.SetSettings((V2GSettings)Settings);
            }

            // Create Model
            V2GModel model = new V2GModel();

            printer.settings.StartPoint = new V2GPrintPosition(20, 20, 0);
            printer.settings.EndPoint   = printer.settings.StartPoint;

            // Append PrintPolylines
            foreach (var printable in Printables)
            {
                if (printable is V2GPrintPolyline)
                {
                    model.AppendAsPath(printable as V2GPrintPolyline);
                }

                // if (printable is PrintPoint) { }
                // if (printable is PrintSurface) { }
            }

            model.AppendAsRelativeMovement(new V2GPrintPosition(0, 0, 10.0), 0);

            // Generate GCode
            model.GenerateGCode(sb, printer);

            return(sb.ToString());
        }