Example #1
0
 /// <summary>
 /// Moves the model by the specified vector.
 /// </summary>
 /// <param name="moveVector">The vector of how to move the model in X, Y, Z.</param>
 public void Move(Vector moveVector)
 {
     PowerMill.DoCommand("TRANSFORM TYPE MOVE TRANSFORM MOVEX \"" + moveVector.I + "\"",
                         "TRANSFORM TYPE MOVE TRANSFORM MOVEY \"" + moveVector.J + "\"",
                         "TRANSFORM TYPE MOVE TRANSFORM MOVEZ \"" + moveVector.K + "\"",
                         "TRANSFORM MODEL \"" + Name + "\"");
 }
Example #2
0
        /// <summary>
        /// Checks if there are any collisions.
        /// If it returns true the three status indicators can then be inspected to determine the cause
        /// </summary>
        public bool DetectHolderCollisions()
        {
            // See if collisions have already been detected
            if (GetParameterBooleanValue("Verification.CollisionChecked") == false)
            {
                // Not yet detected so determine if there are any
                PowerMill.DoCommand("ACTIVATE TOOLPATH '" + Name + "'",
                                    "EDIT COLLISION TYPE Collision",
                                    "EDIT COLLISION SCOPE ALL",
                                    "EDIT COLLISION SPLIT_TOOLPATH N",
                                    "EDIT COLLISION STOCKMODEL_CHECK N",
                                    "EDIT COLLISION DEPTH N",
                                    "EDIT COLLISION USE_TOOL \" \"",
                                    "EDIT COLLISION APPLY");
            }

            // Now check the tool safety parameters
            var cuttingStatus = GetParameter("Safety.Holder.Cutting.Status");

            _holderCuttingMovesSafety = SafetyFromString(cuttingStatus);
            var linksStatus = GetParameter("Safety.Holder.Links.Status");

            _holderLinksSafety = SafetyFromString(linksStatus);
            var leadsStatus = GetParameter("Safety.Holder.Leads.Status");

            _holderLeadsSafety = SafetyFromString(leadsStatus);
            if (_holderCuttingMovesSafety == ToolpathSafety.Collides ||
                _holderLinksSafety == ToolpathSafety.Collides || _holderLeadsSafety == ToolpathSafety.Collides)
            {
                return(true);
            }

            // No collisions detected
            return(false);
        }
Example #3
0
        /// <summary>
        /// Detects if there are any gouges.
        /// If it returns true the three status indicators can then be inspected to determine the cause.
        /// </summary>
        public bool DetectToolGouges()
        {
            // See if gouges have already been detected
            if (GetParameterBooleanValue("Verification.GougeChecked") == false)
            {
                // Not yet detected so determine if there are any
                PowerMill.DoCommand("ACTIVATE TOOLPATH '" + Name + "'",
                                    "EDIT COLLISION TYPE Gouge",
                                    "EDIT COLLISION SCOPE ALL",
                                    "EDIT COLLISION SPLIT_TOOLPATH N",
                                    "EDIT COLLISION STOCKMODEL_CHECK N",
                                    "EDIT COLLISION APPLY");
            }

            // Now check the tool safety parameters
            var cuttingStatus = GetParameter("Safety.Tool.Cutting.Status");

            _toolCuttingMovesSafety = SafetyFromString(cuttingStatus);
            var linksStatus = GetParameter("Safety.Tool.Links.Status");

            _toolLinksSafety = SafetyFromString(linksStatus);
            var leadsStatus = GetParameter("Safety.Tool.Leads.Status");

            _toolLeadsSafety = SafetyFromString(leadsStatus);
            if (_toolCuttingMovesSafety == ToolpathSafety.Collides || _toolLinksSafety == ToolpathSafety.Collides ||
                _toolLeadsSafety == ToolpathSafety.Collides)
            {
                return(true);
            }

            // No gouges detected
            return(false);
        }
Example #4
0
 /// <summary>
 /// Selects the model, optionally removing everything else from the selection first.
 /// </summary>
 /// <param name="clearSelectionFirst">If true unselects everything else before selecting this model.</param>
 public void AddToSelection(bool clearSelectionFirst = false)
 {
     if (clearSelectionFirst)
     {
         PowerMill.DoCommand("EDIT MODEL ALL DESELECT ALL");
     }
     PowerMill.DoCommand("EDIT MODEL \"" + Name + "\" SELECT ALL");
 }
Example #5
0
        /// <summary>
        /// Inserts the specified Boundary into this Boundary.
        /// </summary>
        /// <param name="boundary">The boundary to insert into this Boundary.</param>
        public void InsertBoundary(PMBoundary boundary)
        {
            if (boundary == null || !boundary.Exists)
            {
                throw new ArgumentNullException("boundary", "Boundary not found");
            }

            PowerMill.DoCommand("EDIT BOUNDARY '" + Name + "' INSERT BOUNDARY '" + boundary.Name + "'");
        }
Example #6
0
        /// <summary>
        /// Reimports a file into PowerMill.
        /// </summary>
        /// <param name="file">The file to import.</param>
        public void Reimport(FileSystem.File file)
        {
            var arrayToCheck = new[] { "dmt", "dgk", "ddx", "ddz", "psmodel", "doc", "det", "pic" };

            if (!arrayToCheck.Contains(file.Extension))
            {
                throw new Exception("File extension must be dgk, ddx, ddz, psmodel, doc, det or pic");
            }
            PowerMill.DoCommand(string.Format("EDIT MODEL '{0}' REIMPORT '{1}'", Name, file.Path));
        }
 /// <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 + "'");
 }
Example #8
0
        /// <summary>
        /// Inserts the specified Boundary into this Boundary.
        /// </summary>
        /// <param name="boundaryName">The name of the boundary to insert into this Boundary.</param>
        public void InsertBoundaryByName(string boundaryName)
        {
            PMBoundary boundary = PowerMill.ActiveProject.Boundaries.GetByName(boundaryName);

            if (boundary == null || !boundary.Exists)
            {
                throw new ArgumentNullException("boundary", "Boundary not found");
            }

            PowerMill.DoCommand("EDIT BOUNDARY '" + Name + "' INSERT BOUNDARY '" + boundary.Name + "'");
        }
Example #9
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;
            }
        }
Example #11
0
 /// <summary>
 /// Splits the selected sections of the Pattern.
 /// </summary>
 public void SplitSelected()
 {
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' SPLIT");
 }
Example #12
0
 /// <summary>
 /// Invalidates the toolpath.
 /// </summary>
 public void MakeInvalid()
 {
     PowerMill.DoCommand("INVALIDATE TOOLPATH \"" + Name + "\"");
 }
Example #13
0
 /// <summary>
 /// Calculates the toolpath.
 /// </summary>
 public void Calculate()
 {
     // Activate it then calculate it
     IsActive = true;
     PowerMill.DoCommand("EDIT TOOLPATH \"" + Name + "\" CALCULATE");
 }
Example #14
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);
 }
Example #15
0
 /// <summary>
 /// Reverses the selected sections of the Pattern in PowerMill.
 /// </summary>
 public void ReverseSelected()
 {
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' REVERSE");
 }
Example #16
0
 /// <summary>
 /// Merges the selected sections of the Pattern.
 /// </summary>
 public void MergeSelected()
 {
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' MERGE");
 }
Example #17
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));
 }
Example #18
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 + "\"");
 }
Example #19
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);
 }
Example #20
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);
 }
Example #21
0
 /// <summary>
 /// Reverses all the sections of the Pattern.
 /// </summary>
 public void ReverseAll()
 {
     MergeAll();
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' REVERSE");
 }
Example #22
0
 /// <summary>
 /// Selects all sections of the Pattern.
 /// </summary>
 public void SelectAll()
 {
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' SELECT ALL");
 }
Example #23
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");
 }
Example #24
0
 /// <summary>
 /// Merges all the sections of the Pattern.
 /// </summary>
 public void MergeAll()
 {
     SelectAll();
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' MERGE");
 }
Example #25
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);
 }
Example #26
0
 /// <summary>
 /// Closes the selected sections of the Pattern.
 /// </summary>
 public void CloseSelected()
 {
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' CLOSE");
 }
Example #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 + "\"");
 }
Example #28
0
 /// <summary>
 /// Splits all the sections of the Pattern.
 /// </summary>
 public void SplitAll()
 {
     MergeAll();
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' SPLIT");
 }
Example #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 + "\"");
 }
Example #30
0
 /// <summary>
 /// Closes all the sections of the Pattern.
 /// </summary>
 public void CloseAll()
 {
     MergeAll();
     PowerMill.DoCommand("EDIT PATTERN '" + Name + "' CLOSE");
 }