Exemple #1
0
 public void SetRelativePoint(V2GState printer)
 {
     this.p = printer.Position + this.p;
     if (this.p.Z <= 0.0)
     {
         this.p.Z = 0.05;
     }
 }
Exemple #2
0
 /// <summary>
 /// Set the position of the printer's extruder head.
 /// </summary>
 /// <param name="p">A PrintPoint.</param>
 public void SetPosition(V2GPrintPosition p, StringBuilder s = null)
 {
     if (s != null && Math.Abs(this.Position.Z - p.Z + this.settings.ZOffset) > 0.01)
     {
         if (this.settings.IsVerbose)
         {
             s.Append("\n(Z Changed)");
             s.Append(" (from " + this.Position.Z + " to " + p.Z + ")");
         }
         this.ResetHead(s);
     }
     this.Position = new V2GPrintPosition(p.X, p.Y, p.Z + this.settings.ZOffset);
 }
        public override void GenerateGCode(StringBuilder s, V2GState printer)
        {
            V2GPrintPosition prevP = printer.Position;

            printer.F = this.speed;
            printer.SetPosition(this.p);
            double length          = printer.Position.DistanceTo(prevP);
            double extrusionHeight = this.Height();

            if (printer.Position.Z < 0)
            {
                printer.Position.Z = 0;                         // todo: this safes inside the PrintState class
            }
            if (printer.Position.Z < 0.7 && this.AllowsGroundOverride)
            {
                if (this.thickness < 700)
                {
                    this.speed = 400;
                }
                extrusionHeight = 0.25;
            }

            // Locate Z in its place
            s.Append("\nG1");
            s.Append(" Z" + Math.Round((printer.Position.Z + extrusionHeight), 4));

            printer.EPerMM = this.EUnitIncrease();

            // Calculate E increase
            double EUnitIncrease = printer.EPerMM;
            double EIncrease     = EUnitIncrease * length;

            printer.E += EIncrease;

            // Extrude
            // - todo: check if coordinates are equal than previous ones
            s.Append("\nG1");
            s.Append(" X" + Math.Round(printer.Position.X, 4));
            s.Append(" Y" + Math.Round(printer.Position.Y, 4));
            s.Append(" Z" + Math.Round((printer.Position.Z + extrusionHeight), 4));
            s.Append(" E" + Math.Round(printer.E, 4));
            s.Append(" F" + Math.Round(printer.F, 4));
            if (printer.settings.IsVerbose)
            {
                s.Append(" (EUnitIncrease " + EUnitIncrease + ", thickness " + this.thickness + ", height " + extrusionHeight + ")");
            }
            if (printer.settings.IsVerbose)
            {
                s.Append(" (PrintSegment)");
            }
        }
Exemple #4
0
        // TODO: Implement with V2GMovement
        public void AppendAsRelativeMovement(V2GPrintPosition p)
        {
            V2GPath path = new V2GPath();

            V2GInstruction seg;

            seg = new PrintMovementOld();
            (seg as PrintMovementOld).p          = p;
            (seg as PrintMovementOld).IsRelative = true;
            (seg as PrintMovementOld).speed      = 2400;
            path.Segments.Add(seg);

            Paths.Add(path);
        }
Exemple #5
0
        public void AppendAsRelativeMovement(V2GPrintPosition p, double Retraction, double Speed = 2400)
        {
            V2GPath path = new V2GPath();

            V2GInstruction seg;

            seg = new PrintMovementOld();
            (seg as PrintMovementOld).p          = p;
            (seg as PrintMovementOld).IsRelative = true;
            (seg as PrintMovementOld).ForceFilamentOperations = true;
            (seg as PrintMovementOld).FilamentRetract         = Retraction; // mm
            (seg as PrintMovementOld).speed = Speed;
            path.Segments.Add(seg);

            Paths.Add(path);
        }
        /// <summary>
        /// Generate G-code instructions for the segment.
        /// </summary>
        /// <param name="s">StringBuilder to store the G-code.</param>
        /// <param name="printer">Printer state.</param>
        public override void GenerateGCode(StringBuilder s, V2GState printer)
        {
            V2GPrintPosition prevPrinterPosition = printer.Position;
            bool             speedChanged        = false;

            if (printer.F != this.PrintPosition.Speed)
            {
                printer.F    = this.PrintPosition.Speed;
                speedChanged = true;
            }
            printer.SetPosition(this.PrintPosition, s);
            double length = printer.Position.DistanceTo(prevPrinterPosition);

            // Switch Extruder Head if Needed
            printer.SetHead(s, this.PrintPosition.Head);

            // Move to Start Point
            //s.Append("\nG1");
            //s.Append(" Z" + Math.Round(printer.Position.Z, 4));

            // Move and Extrude
            s.Append("\nG1");
            if (prevPrinterPosition.X != printer.Position.X)
            {
                s.Append(" X" + Math.Round(printer.Position.X, 4));
            }
            if (prevPrinterPosition.Y != printer.Position.Y)
            {
                s.Append(" Y" + Math.Round(printer.Position.Y, 4));
            }
            if (Math.Abs(prevPrinterPosition.Z - printer.Position.Z) > 0.0001)
            {
                s.Append(" Z" + Math.Round(printer.Position.Z, 4));
            }
            printer.IncreaseE(s, this.PrintPosition.MaterialAmount, length, this.PrintPosition.MixPercentage);
            if (speedChanged)
            {
                s.Append(" F" + Math.Round(printer.F, 4));
            }
        }
Exemple #7
0
 /// <summary>
 /// Transform a PrintPoint from absolute coordinates to printer space coordinates.
 /// </summary>
 /// <param name="p">A PrintPoint.</param>
 /// <returns></returns>
 public V2GPrintPosition PrintPointOnBase(V2GPrintPosition p)
 {
     return(new V2GPrintPosition(p.X, p.Y, p.Z + this.settings.ZOffset));
 }
Exemple #8
0
 public V2GMovement(V2GPrintPosition printPosition, double speed)
 {
     this.PrintPosition       = printPosition;
     this.PrintPosition.Speed = speed;
 }
 public V2GPrintSegment(V2GPrintPosition printPosition)
 {
     this.PrintPosition = printPosition;
 }
Exemple #10
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)
        {
            List <V2GPrintPosition> PrintPoints    = new List <V2GPrintPosition>();
            List <Point3d>          InputPoints    = new List <Point3d>();
            List <double>           MaterialAmount = new List <double>();
            List <double>           Speed          = new List <double>();
            List <int>    Toolhead      = new List <int>();
            List <double> MixPercentage = new List <double>();

            if (!DA.GetDataList(0, InputPoints))
            {
                return;
            }
            if (!DA.GetDataList(1, MaterialAmount))
            {
                return;
            }
            if (!DA.GetDataList(2, Speed))
            {
                return;
            }
            if (!DA.GetDataList(3, Toolhead))
            {
                return;
            }
            if (!DA.GetDataList(4, MixPercentage))
            {
                return;
            }

            int    idx             = 0;
            double _Speed          = Speed[0];
            double _MaterialAmount = MaterialAmount[0];
            int    _Head           = Toolhead[0];
            double _MixPercentage  = MixPercentage[0];

            foreach (Point3d p in InputPoints)
            {
                if (Speed.Count - 1 >= idx)
                {
                    _Speed = Speed[idx];
                }
                if (MaterialAmount.Count - 1 >= idx)
                {
                    _MaterialAmount = MaterialAmount[idx];
                }
                if (Toolhead.Count - 1 >= idx)
                {
                    _Head = Toolhead[idx];
                }
                if (MixPercentage.Count - 1 >= idx)
                {
                    _MixPercentage = MixPercentage[idx];
                }

                V2GPrintPosition position = new V2GPrintPosition(V2GH.V2GPoint(p), _Speed, _MaterialAmount, _Head, _MixPercentage);
                PrintPoints.Add(new V2GPrintPosition(p.X, p.Y, p.Z));
                idx++;
            }

            DA.SetDataList(0, PrintPoints);
        }