Exemple #1
0
 /// <summary>
 /// Exports the model to the specified file.
 /// </summary>
 /// <param name="file">The file to which the model will be exported.</param>
 public void ExportModel(FileSystem.File file,
                         bool exportInActiveWorkplane = true)
 {
     // Delete the file if it already exists
     file.Delete();
     if (exportInActiveWorkplane == false)
     {
         PowerMill.DoCommand("DEACTIVATE WORKPLANE");
     }
     PowerMill.DoCommand("EXPORT MODEL '" + Name + "' '" + file.Path + "'");
 }
Exemple #2
0
        public MM SegmentLength(int segmentNumber)
        {
            var numberOfSegments = NumberOfSegments;

            if (segmentNumber < numberOfSegments)
            {
                return
                    (double.Parse(
                         PowerMill.DoCommandEx("print par terse ${segment_get_length(entity('toolpath', '" + Name + "'), " +
                                               segmentNumber + ")}").ToString()));
            }
            throw new IndexOutOfRangeException(
                      $"{segmentNumber} is greater than the {numberOfSegments} segments in this toolpath.");
        }
Exemple #3
0
        /// <summary>
        /// Mirrors the model in the plane.
        /// </summary>
        /// <param name="plane">The plane used to mirror the model.</param>
        public void MirrorInPlane(Planes plane)
        {
            switch (plane)
            {
            case Planes.XY:
                PowerMill.DoCommand("TRANSFORM TYPE SCALEZ TRANSFORM SCALEVALUE -1 TRANSFORM MODEL '" + Name + "'");
                break;

            case Planes.ZX:
                PowerMill.DoCommand("TRANSFORM TYPE SCALEY TRANSFORM SCALEVALUE -1 TRANSFORM MODEL '" + Name + "'");
                break;

            case Planes.YZ:
                PowerMill.DoCommand("TRANSFORM TYPE SCALEX TRANSFORM SCALEVALUE -1 TRANSFORM MODEL '" + Name + "'");
                break;
            }
        }
        /// <summary>
        /// Rotate the model by the specified axis and angle.
        /// </summary>
        /// <param name="rotateAxis">The rotation axis</param>
        /// <param name="rotateAngle">The rotation angle</param>
        public void Rotate(Axes rotateAxis, double rotateAngle)
        {
            switch (rotateAxis)
            {
            case Axes.X:
                PowerMill.DoCommand("TRANSFORM ANGLE \"" + rotateAngle + "\" TRANSFORM TYPE ROTATEX TRANSFORM MODEL \"" + Name + "\"");
                break;

            case Axes.Y:
                PowerMill.DoCommand("TRANSFORM ANGLE \"" + rotateAngle + "\" TRANSFORM TYPE ROTATEY TRANSFORM MODEL \"" + Name + "\"");
                break;

            case Axes.Z:
                PowerMill.DoCommand("TRANSFORM ANGLE \"" + rotateAngle + "\" TRANSFORM TYPE ROTATEZ TRANSFORM MODEL \"" + Name + "\"");
                break;
            }
        }
Exemple #5
0
        /// <summary>
        /// Gets and sets the length of the requested holder component.
        /// </summary>
        public MM HolderElementLength(int index)
        {
            if (PowerMill.Version < new Version("15.0"))
            {
                throw new Exception(
                          "Holder elementes are not available for this version of PowerMILL.  PowerMILL 15 or greater is required");
            }
            string result =
                PowerMill.DoCommandEx("PRINT par terse \"entity('tool','" + Name + "').holdersetvalues[" + index +
                                      "].length\"").ToString();

            if (result.Contains("#ERROR"))
            {
                throw new IndexOutOfRangeException(
                          "The specified index is greater than the number of elements in the holder");
            }
            return(Convert.ToDouble(result));
        }
Exemple #6
0
        /// <summary>
        /// Gets the position of the specified point in the specified segment
        /// </summary>
        /// <param name="segmentNumber">The segment number of the toolpath (indexed from zero)</param>
        /// <param name="pointNumber">The point number in the specified segment (indexed from zero)</param>
        /// <returns>The point position</returns>
        public Point ToolpathPointPosition(int segmentNumber, int pointNumber)
        {
            var numberOfPoints = NumberOfPointsInSegment(segmentNumber);

            if (pointNumber < numberOfPoints)
            {
                var x = double.Parse(PowerMill.DoCommandEx("print par terse ${segment_get_point(entity('toolpath', '" + Name +
                                                           "'), " +
                                                           segmentNumber + ", " + pointNumber + ").Position.X}").ToString());
                var y = double.Parse(PowerMill.DoCommandEx("print par terse ${segment_get_point(entity('toolpath', '" + Name +
                                                           "'), " +
                                                           segmentNumber + ", " + pointNumber + ").Position.Y}").ToString());
                var z = double.Parse(PowerMill.DoCommandEx("print par terse ${segment_get_point(entity('toolpath', '" + Name +
                                                           "'), " +
                                                           segmentNumber + ", " + pointNumber + ").Position.Z}").ToString());
                return(new Point(x, y, z));
            }
            throw new IndexOutOfRangeException(
                      $"{pointNumber} is greater than the {numberOfPoints} points in segment {segmentNumber} of this toolpath.");
        }
Exemple #7
0
        /// <summary>
        /// Gets the tool axis vector for the specified point in the specified segment
        /// </summary>
        /// <param name="segmentNumber">The segment number of the toolpath (indexed from zero)</param>
        /// <param name="pointNumber">The point number in the specified segment (indexed from zero)</param>
        /// <returns>The tool axis vector</returns>
        public Vector ToolpathPointToolAxis(int segmentNumber, int pointNumber)
        {
            var numberOfPoints = NumberOfPointsInSegment(segmentNumber);

            if (pointNumber < numberOfPoints)
            {
                var i = double.Parse(PowerMill.DoCommandEx("print par terse ${segment_get_point(entity('toolpath', '" + Name +
                                                           "'), " +
                                                           segmentNumber + ", " + pointNumber + ").ToolAxis[0]}").ToString());
                var j = double.Parse(PowerMill.DoCommandEx("print par terse ${segment_get_point(entity('toolpath', '" + Name +
                                                           "'), " +
                                                           segmentNumber + ", " + pointNumber + ").ToolAxis[1]}").ToString());
                var k = double.Parse(PowerMill.DoCommandEx("print par terse ${segment_get_point(entity('toolpath', '" + Name +
                                                           "'), " +
                                                           segmentNumber + ", " + pointNumber + ").ToolAxis[2]}").ToString());
                return(new Vector(i, j, k));
            }
            throw new IndexOutOfRangeException(
                      $"{pointNumber} is greater than the {numberOfPoints} points in segment {segmentNumber} of this toolpath.");
        }
Exemple #8
0
 /// <summary>
 /// Fits an Arc to all the sections of the Pattern.
 /// </summary>
 /// <param name="dblTolerance">The Arc fitting tolerance.</param>
 public void ArcFitAll(double dblTolerance)
 {
     MergeAll();
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' ARCFIT " + dblTolerance);
 }
 /// <summary>
 /// Writes the NCProgram.  Post-processor and option file must have been specified already.
 /// </summary>
 public void Write()
 {
     // Write out the NCProgram
     PowerMill.DoCommand("ACTIVATE NCPROGRAM \"" + Name + "\"", "KEEP NCPROGRAM \"" + Name + "\"");
 }
Exemple #10
0
 /// <summary>
 /// Splines the selected sections of the Pattern.
 /// </summary>
 /// <param name="dblTolerance">The spline fitting tolerance.</param>
 public void SplineSelected(double dblTolerance)
 {
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' SPLINE " + dblTolerance);
 }
Exemple #11
0
 /// <summary>
 /// Fits an arc to the selected sections of the Pattern.
 /// </summary>
 /// <param name="tolerance">The Arc fitting tolerance.</param>
 public void ArcFitSelected(double tolerance)
 {
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' ARCFIT " + tolerance);
 }
Exemple #12
0
 /// <summary>
 /// Reverses the selected sections of the Pattern in PowerMill.
 /// </summary>
 public void ReverseSelected()
 {
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' REVERSE");
 }
Exemple #13
0
 /// <summary>
 /// Merges all the sections of the Pattern.
 /// </summary>
 public void MergeAll()
 {
     SelectAll();
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' MERGE");
 }
Exemple #14
0
 /// <summary>
 /// Polygonises the selected sections of the Pattern.
 /// </summary>
 /// <param name="dblTolerance">The Polygonisation tolerance.</param>
 public void PolygoniseSelected(double dblTolerance)
 {
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' SMASH " + dblTolerance);
 }
Exemple #15
0
 /// <summary>
 /// Inserts the specified file into this Boundary.
 /// </summary>
 /// <param name="file">The file to insert into this Boundary.</param>
 public void InsertFile(File file)
 {
     PowerMill.DoCommand("EDIT BOUNDARY '" + Name + "' INSERT FILE \"" + file.Path + "\"");
 }
Exemple #16
0
 /// <summary>
 /// Polygonise a boundary to a specified tolerance.
 /// </summary>
 /// <param name="smashTolerance">The tolerance used to polygonise boundary.</param>
 public void Smash(double smashTolerance)
 {
     PowerMill.DoCommand(string.Format("EDIT BOUNDARY \"{0}\" SMASH {1}", Name, smashTolerance));
 }
Exemple #17
0
 /// <summary>
 /// Invalidates the toolpath.
 /// </summary>
 public void MakeInvalid()
 {
     PowerMill.DoCommand("INVALIDATE TOOLPATH \"" + Name + "\"");
 }
Exemple #18
0
 /// <summary>
 /// Reverses all the sections of the Pattern.
 /// </summary>
 public void ReverseAll()
 {
     MergeAll();
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' REVERSE");
 }
Exemple #19
0
 /// <summary>
 /// Selects all sections of the Pattern.
 /// </summary>
 public void SelectAll()
 {
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' SELECT ALL");
 }
Exemple #20
0
 /// <summary>
 /// Merges the selected sections of the Pattern.
 /// </summary>
 public void MergeSelected()
 {
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' MERGE");
 }
Exemple #21
0
 /// <summary>
 /// Closes the selected sections of the Pattern.
 /// </summary>
 public void CloseSelected()
 {
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' CLOSE");
 }
Exemple #22
0
 /// <summary>
 /// Splits the selected sections of the Pattern.
 /// </summary>
 public void SplitSelected()
 {
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' SPLIT");
 }
Exemple #23
0
 /// <summary>
 /// Calculates the toolpath.
 /// </summary>
 public void Calculate()
 {
     // Activate it then calculate it
     IsActive = true;
     PowerMill.DoCommand("EDIT TOOLPATH \"" + Name + "\" CALCULATE");
 }
Exemple #24
0
 /// <summary>
 /// Splines all the sections of the Pattern.
 /// </summary>
 /// <param name="dblTolerance">The Spline fitting tolerance.</param>
 public void SplineAll(double dblTolerance)
 {
     MergeAll();
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' SPLINE " + dblTolerance);
 }
Exemple #25
0
 /// <summary>
 /// Fatten the boundary onto the XY Plane at Z = 0.
 /// </summary>
 public void Flat()
 {
     PowerMill.DoCommand(string.Format("EDIT BOUNDARY \"{0}\" CURVEEDITOR START", Name));
     PowerMill.DoCommand("CURVEEDITOR FLATTEN SELECTED");
     PowerMill.DoCommand("CURVEEDITOR FINISH ACCEPT");
 }
Exemple #26
0
 /// <summary>
 /// Polygonises all the sections of the Pattern.
 /// </summary>
 /// <param name="dblTolerance">The Polygonisation tolerance.</param>
 public void PolygoniseAll(double dblTolerance)
 {
     MergeAll();
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' SMASH " + dblTolerance);
 }
Exemple #27
0
 /// <summary>
 /// Inserts the specified toolpath into this Boundary.
 /// </summary>
 /// <param name="toolpath">The toolpath to insert into this Boundary.</param>
 public void InsertToolpath(PMToolpath toolpath)
 {
     PowerMill.DoCommand("EDIT BOUNDARY '" + Name + "' INSERT TOOLPATH \"" + toolpath.Name + "\"");
 }
Exemple #28
0
 /// <summary>
 /// Splits all the sections of the Pattern.
 /// </summary>
 public void SplitAll()
 {
     MergeAll();
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' SPLIT");
 }
Exemple #29
0
 /// <summary>
 /// Write the Boundary to the specified file.  Supported file types are: dgk, ddz, ddx, dxf, pic
 /// </summary>
 /// <param name="file">The file to write to.</param>
 public void WriteToFile(File file)
 {
     PowerMill.DoCommand("KEEP BOUNDARY '" + Name + "' FILESAVE \"" + file.Path + "\"");
 }
Exemple #30
0
 /// <summary>
 /// Closes all the sections of the Pattern.
 /// </summary>
 public void CloseAll()
 {
     MergeAll();
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' CLOSE");
 }