Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Leaderboard

Popular Content

Showing content with the highest reputation on 12/05/2022 in all areas

  1. The other reason to default to Dynamic/Opti is that they generally put less stress into the part, if flatness or tolerances are tight on the finish product you'll get a lot less distortion when you unclamp than with traditional methods. You can dial in the amount of load you're putting into the material, and often trade a bit of roughing time to not have to do a second "finishing" op after releasing/skimming/reclamping the part. Sometimes it's not raw toolpath time that's the big win.
    3 points
  2. Like so? I unroilled the geometry with an angle setting of +90...that accounts for the way MCAM handles the Back plane....think like lathe, the Back plane is C0... JP_SOLID.mcam
    2 points
  3. The Mill-Turn machine environment for Mastercam supports the structured programming and was developed in Germany. I would recommend that your reseller work with the machine development team here at CNC to ensure that the solution is configured properly for your machine and that there is support in place as you learn how to run the machine and how to program it in Mastercam.
    2 points
  4. and you'll probably have to hold the operator's hand the for the first couple of programs if you are not used to dynamic roughing on a machine capable of very fast feed motion F1000 or F2000 back feed motion can be terrifying
    1 point
  5. One thing to be careful of with the Opti/Dynamic toolpaths is to make sure your microlift distance and speed is more reasonable for a linear way modern machine. There's no reason to back off .01" unless you've got a ton of Z axis backlash, .002-.003 should be fine. Max out your back feed rate to whatever the machine can theoretically traverse at. It defaults to 100IPM, which is way too slow, especially since you'll be aiming for >2000 IPM range most likely...
    1 point
  6. Thank you so much !!!!
    1 point
  7. 1> What is the goal of this add-in? I’ve read the Logic:: description. (Not that I understood it.) I see the image you posted, but that itself doesn’t help me know that me what the process is supposed to be. 2> This is just a code fragment (albeit a very large one!) It has many repeated code sections. I would suggest breaking it down. * Trying to follow logic through a 1300+ lines of code in one method is going to cause you grief. 3> Why the templist9 and templist10 that contain the geometry entity IDs? Seems it may be an unnecessary complication. *Example: Don’t repeat code if possible. Break that out to its own method. This section of code is essentially repeated 40+ times! (Copy/Paste is not your friend here.) //foreach (var v in tempList9) //{ // var w = Geometry.RetrieveEntity(v);// Gets point based on GeoID // if (w is PointGeometry point) // { // var ux = point.Data.x;// X location of point // var uy = point.Data.y;// Y location of point / Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location // var entityPointDistance = VectorManager.Distance(uPoint, nextArcStartPoint); // if (entityPointDistance <= tolerance) // { // step = 4; // } // } //} if (SearchTempList9(tempList9, nextArcStartPoint)) { step = 4; } A single method to call can replace those instances of repeated code. ///<summary> Search the list of entities for a matching point position </summary> /// ///<param name="entIdList"> The list of entity IDs to search </param> ///<param name="pt"> The point position to look for in the list </param>\ /// ///<returns> Thrue if a match was found, else false </returns> private bool SearchTempList9(List<int> entIdList, Point3D pt) { foreach (var entId in entIdList) { var geom = Geometry.RetrieveEntity(entId); if (geom is PointGeometry point) { var ux = point.Data.x; // X location of point var uy = point.Data.y; // Y location of point var uPoint = new Point3D(ux, uy, 0.0); // Saves point location var entityPointDistance = VectorManager.Distance(uPoint, pt); if (entityPointDistance <= tolerance) { return true; } } } return false; } The code below builds but is not tested. (since I do not know exactly want it is supposed to do!) Could I have introduced new bugs to this quick & dirty refactoring or the code>? Absolutely. using System; using System.Collections.Generic; using Mastercam.BasicGeometry; using Mastercam.Curves; using Mastercam.Database; using Mastercam.Database.Types; using Mastercam.Math; namespace Customer { public class Support { private double tolerance = Mastercam.IO.SettingsManager.SystemTolerance; private List<int> tempList9 = new List<int>(); private List<int> templist10 = new List<int>(); public void DoIt() { double entityStartDistance; double entityEndDistance; Point3D lineStartPoint; Point3D lineEndPoint; Point3D nextLineStartPoint; Point3D nextLineEndPoint; Point3D arcStartPoint; Point3D arcEndPoint; Point3D nextArcStartPoint; Point3D nextArcEndPoint; var firstEntity = 0; var step = 0; var chainDetails = new Mastercam.Database.Interop.ChainDetails();// Preps the ChainDetails plugin var selectedChains = ChainManager.ChainAll(75);// Chains all geometry on level 75 var chainDirection = ChainDirectionType.CounterClockwise;// Going to be used to make sure all chains go the same direction ChainManager.StartChainAtLongest(selectedChains); foreach (var chain in selectedChains) { var chainData = chainDetails.GetData(chain); var chainEntityList = chainData.ChainEntities; foreach (var t in chainEntityList) { (t.Key).Color = 9; (t.Key).Commit(); } } foreach (var chain in selectedChains) { templist10.Clear(); step = 0; chain.Direction = chainDirection; var chainEntity = ChainManager.GetGeometryInChain(chain); if (step == 0) { System.Windows.Forms.MessageBox.Show("step 0"); foreach (var entity in chainEntity) { if (entity is ArcGeometry arc && step == 0) { step = SearchTempList9Arcs(entity, step); } else if (entity is LineGeometry line && step == 0) { step = SearchTempList9Lines(entity, step); } } } if (step == 1) { System.Windows.Forms.MessageBox.Show("step 1"); foreach (var entity in chainEntity) { if (firstEntity == 1 && step == 1) { var thisEntity = Geometry.RetrieveEntity(templist10[0]); if (thisEntity is ArcGeometry arc && step == 1) { GetEndPoints(arc, out arcStartPoint, out arcEndPoint); if (entity is ArcGeometry nextArc && (entity.GetEntityID() != templist10[0]) && step == 1) { GetEndPoints(nextArc, out nextArcStartPoint, out nextArcEndPoint); entityStartDistance = VectorManager.Distance(arcEndPoint, nextArcStartPoint); entityEndDistance = VectorManager.Distance(arcEndPoint, nextArcEndPoint); if (entityStartDistance <= tolerance && step == 1) { UpdateEntityColorAndList10(entity, 10); step = 2; firstEntity = 1; if (SearchTempList9(tempList9, nextArcEndPoint)) { step = 3; } } if (entityEndDistance <= tolerance && step == 1) { UpdateEntityColorAndList10(entity, 10); step = 4; firstEntity = 1; if (SearchTempList9(tempList9, nextArcStartPoint)) { step = 3; } } } if (entity is LineGeometry nextLine && (entity.GetEntityID() != templist10[0]) && step == 1) { GetEndPoints(nextLine, out nextLineStartPoint, out nextLineEndPoint); entityStartDistance = VectorManager.Distance(arcEndPoint, nextLineStartPoint); entityEndDistance = VectorManager.Distance(arcEndPoint, nextLineEndPoint); if (entityStartDistance <= tolerance && step == 1) { UpdateEntityColorAndList10(entity, 10); step = 2; firstEntity = 2; if (SearchTempList9(tempList9, nextLineEndPoint)) { step = 3; } } if (entityEndDistance <= tolerance && step == 1) { UpdateEntityColorAndList10(entity, 10); step = 4; firstEntity = 2; if (SearchTempList9(tempList9, nextLineStartPoint)) { step = 3; } } } } } if (firstEntity == 2 && step == 1) { var thisEntity = Geometry.RetrieveEntity(templist10[0]); if (thisEntity is LineGeometry line && step == 1) { GetEndPoints(line, out lineStartPoint, out lineEndPoint); if (entity is ArcGeometry nextArc && (entity.GetEntityID() != templist10[0]) && step == 1) { GetEndPoints(entity as ArcGeometry, out nextArcStartPoint, out nextArcEndPoint); entityStartDistance = VectorManager.Distance(lineEndPoint, nextArcStartPoint); entityEndDistance = VectorManager.Distance(lineEndPoint, nextArcEndPoint); if (entityStartDistance <= tolerance && step == 1) { UpdateEntityColorAndList10(entity, 10); step = 2; firstEntity = 1; if (SearchTempList9(tempList9, nextArcEndPoint)) { step = 3; } } if (entityEndDistance <= tolerance && step == 1) { UpdateEntityColorAndList10(entity, 10); step = 4; firstEntity = 1; if (SearchTempList9(tempList9, nextArcStartPoint)) { step = 3; } } } if (entity is LineGeometry nextLine && (entity.GetEntityID() != templist10[0]) && step == 1) { GetEndPoints(nextLine, out nextLineStartPoint, out nextLineEndPoint); entityStartDistance = VectorManager.Distance(lineEndPoint, nextLineStartPoint); entityEndDistance = VectorManager.Distance(lineEndPoint, nextLineEndPoint); if (entityStartDistance <= tolerance && step == 1) { UpdateEntityColorAndList10(entity, 10); step = 2; firstEntity = 2; if (SearchTempList9(tempList9, nextLineEndPoint)) { step = 3; } } if (entityEndDistance <= tolerance && step == 1) { UpdateEntityColorAndList10(entity, 10); step = 4; firstEntity = 2; if (SearchTempList9(tempList9, nextLineStartPoint)) { step = 3; } } } } } } } if (step == 2) { System.Windows.Forms.MessageBox.Show("step 2"); foreach (var entity in chainEntity) { if (firstEntity == 1 && step == 2) { var thisEntity = Geometry.RetrieveEntity(templist10[0]); if (thisEntity is ArcGeometry arc && step == 2) { GetEndPoints(arc, out arcStartPoint, out arcEndPoint); if (entity is ArcGeometry nextArc && (entity.Color != 10) && (entity.Color != 11) && step == 2) { GetEndPoints(nextArc, out nextArcStartPoint, out nextArcEndPoint); entityStartDistance = VectorManager.Distance(arcEndPoint, nextArcStartPoint); entityEndDistance = VectorManager.Distance(arcEndPoint, nextArcEndPoint); if (entityStartDistance <= tolerance && step == 2) { UpdateEntityColorAndList10(entity, 10); step = 2; firstEntity = 1; if (SearchTempList9(tempList9, nextArcEndPoint)) { step = 3; } } if (entityEndDistance <= tolerance && step == 2) { UpdateEntityColorAndList10(entity, 10); step = 4; firstEntity = 1; if (SearchTempList9(tempList9, nextArcStartPoint)) { step = 5; } } } if (entity is LineGeometry nextLine && (entity.Color != 10) && (entity.Color != 11) && step == 2) { GetEndPoints(nextLine, out nextLineStartPoint, out nextLineEndPoint); entityStartDistance = VectorManager.Distance(arcEndPoint, nextLineStartPoint); entityEndDistance = VectorManager.Distance(arcEndPoint, nextLineEndPoint); if (entityStartDistance <= tolerance && step == 2) { UpdateEntityColorAndList10(entity, 10); step = 2; firstEntity = 2; if (SearchTempList9(tempList9, nextLineEndPoint)) { step = 3; } } if (entityEndDistance <= tolerance && step == 2) { UpdateEntityColorAndList10(entity, 10); step = 4; firstEntity = 2; if (SearchTempList9(tempList9, nextLineStartPoint)) { step = 5; } } } } } if (firstEntity == 2 && step == 2) { var thisEntity = Geometry.RetrieveEntity(templist10[0]); if (thisEntity is LineGeometry line && step == 2) { GetEndPoints(line, out lineStartPoint, out lineEndPoint); if (entity is ArcGeometry nextArc && (entity.Color != 10) && (entity.Color != 11) && step == 2) { GetEndPoints(nextArc, out nextArcStartPoint, out nextArcEndPoint); entityStartDistance = VectorManager.Distance(lineEndPoint, nextArcStartPoint); entityEndDistance = VectorManager.Distance(lineEndPoint, nextArcEndPoint); if (entityStartDistance <= tolerance && step == 2) { UpdateEntityColorAndList10(entity, 10); step = 2; firstEntity = 1; if (SearchTempList9(tempList9, nextArcEndPoint)) { step = 3; } } if (entityEndDistance <= tolerance && step == 2) { UpdateEntityColorAndList10(entity, 10); step = 4; firstEntity = 1; if (SearchTempList9(tempList9, nextArcStartPoint)) { step = 5; } } } if (entity is LineGeometry nextLine && (entity.Color != 10) && (entity.Color != 11) && step == 2) { GetEndPoints(nextLine, out nextLineStartPoint, out nextLineEndPoint); entityStartDistance = VectorManager.Distance(lineEndPoint, nextLineStartPoint); entityEndDistance = VectorManager.Distance(lineEndPoint, nextLineEndPoint); if (entityStartDistance <= tolerance && step == 2) { UpdateEntityColorAndList10(entity, 10); step = 2; firstEntity = 2; if (SearchTempList9(tempList9, nextLineEndPoint)) { step = 3; } } if (entityEndDistance <= tolerance && step == 2) { UpdateEntityColorAndList10(entity, 10); step = 4; firstEntity = 2; if (SearchTempList9(tempList9, nextLineStartPoint)) { step = 5; } } } } } } } // Gets Geo that connects first entity end point to second entity start point (offset 2) if (step == 3) { System.Windows.Forms.MessageBox.Show("step 3"); foreach (var entity in chainEntity) { if (firstEntity == 1 && step == 3) { var thisEntity = Geometry.RetrieveEntity(templist10[0]); if (thisEntity is ArcGeometry arc && step == 3) { GetEndPoints(arc, out arcStartPoint, out arcEndPoint); if (entity is ArcGeometry nextArc && (entity.Color != 10) && (entity.Color != 11) && step == 3) { GetEndPoints(nextArc, out nextArcStartPoint, out nextArcEndPoint); entityStartDistance = VectorManager.Distance(arcEndPoint, nextArcStartPoint); entityEndDistance = VectorManager.Distance(arcEndPoint, nextArcEndPoint); if (entityStartDistance <= tolerance && step == 3) { UpdateEntityColorAndList10(entity, 11); step = 3; firstEntity = 1; if (SearchTempList9(tempList9, nextArcEndPoint)) { step = 2; } } if (entityEndDistance <= tolerance && step == 3) { UpdateEntityColorAndList10(entity, 11); step = 5; firstEntity = 1; if (SearchTempList9(tempList9, nextArcStartPoint)) { step = 4; } } } if (entity is LineGeometry nextLine && (entity.Color != 10) && (entity.Color != 11) && step == 3) { GetEndPoints(nextLine, out nextLineStartPoint, out nextLineEndPoint); entityStartDistance = VectorManager.Distance(arcEndPoint, nextLineStartPoint); entityEndDistance = VectorManager.Distance(arcEndPoint, nextLineEndPoint); if (entityStartDistance <= tolerance && step == 3) { UpdateEntityColorAndList10(entity, 11); step = 3; firstEntity = 2; if (SearchTempList9(tempList9, nextLineEndPoint)) { step = 2; } } if (entityEndDistance <= tolerance && step == 3) { UpdateEntityColorAndList10(entity, 11); step = 5; firstEntity = 2; if (SearchTempList9(tempList9, nextLineStartPoint)) { step = 4; } } } } } if (firstEntity == 2 && step == 3) { var thisEntity = Geometry.RetrieveEntity(templist10[0]); if (thisEntity is LineGeometry line && step == 3) { GetEndPoints(line, out lineStartPoint, out lineEndPoint); if (entity is ArcGeometry nextArc && (entity.Color != 10) && (entity.Color != 11) && step == 3) { GetEndPoints(nextArc, out nextArcStartPoint, out nextArcEndPoint); entityStartDistance = VectorManager.Distance(lineEndPoint, nextArcStartPoint); entityEndDistance = VectorManager.Distance(lineEndPoint, nextArcEndPoint); if (entityStartDistance <= tolerance && step == 3) { UpdateEntityColorAndList10(entity, 11); step = 3; firstEntity = 1; if (SearchTempList9(tempList9, nextArcEndPoint)) { step = 2; } } if (entityEndDistance <= tolerance && step == 3) { UpdateEntityColorAndList10(entity, 11); step = 5; firstEntity = 1; if (SearchTempList9(tempList9, nextArcStartPoint)) { step = 4; } } } if (entity is LineGeometry nextLine && (entity.Color != 10) && (entity.Color != 11) && step == 3) { GetEndPoints(nextLine, out nextLineStartPoint, out nextLineEndPoint); entityStartDistance = VectorManager.Distance(lineEndPoint, nextLineStartPoint); entityEndDistance = VectorManager.Distance(lineEndPoint, nextLineEndPoint); if (entityStartDistance <= tolerance && step == 3) { UpdateEntityColorAndList10(entity, 11); step = 3; firstEntity = 2; if (SearchTempList9(tempList9, nextLineEndPoint)) { step = 2; } } if (entityEndDistance <= tolerance && step == 3) { UpdateEntityColorAndList10(entity, 11); step = 5; firstEntity = 2; if (SearchTempList9(tempList9, nextLineStartPoint)) { step = 4; } } } } } } } // Gets Geo that connects first entity end point to second entity start point (offset 1) if (step == 4) { System.Windows.Forms.MessageBox.Show("step 4"); foreach (var entity in chainEntity) { if (firstEntity == 1 && step == 2) { var thisEntity = Geometry.RetrieveEntity(templist10[0]); if (thisEntity is ArcGeometry arc && step == 2) { GetEndPoints(arc, out arcStartPoint, out arcEndPoint); if (entity is ArcGeometry nextArc && (entity.Color != 10) && (entity.Color != 11) && step == 2) { GetEndPoints(nextArc, out nextArcStartPoint, out nextArcEndPoint); entityStartDistance = VectorManager.Distance(arcEndPoint, nextArcStartPoint); entityEndDistance = VectorManager.Distance(arcEndPoint, nextArcEndPoint); if (entityStartDistance <= tolerance && step == 2) { UpdateEntityColorAndList10(entity, 10); step = 2; firstEntity = 1; if (SearchTempList9(tempList9, nextArcEndPoint)) { step = 3; } } if (entityEndDistance <= tolerance && step == 2) { UpdateEntityColorAndList10(entity, 10); step = 4; firstEntity = 1; if (SearchTempList9(tempList9, nextArcStartPoint)) { step = 5; } } } if (entity is LineGeometry nextLine && (entity.Color != 10) && (entity.Color != 11) && step == 2) { GetEndPoints(nextLine, out nextLineStartPoint, out nextLineEndPoint); entityStartDistance = VectorManager.Distance(arcEndPoint, nextLineStartPoint); entityEndDistance = VectorManager.Distance(arcEndPoint, nextLineEndPoint); if (entityStartDistance <= tolerance && step == 2) { UpdateEntityColorAndList10(entity, 10); step = 2; firstEntity = 2; if (SearchTempList9(tempList9, nextLineEndPoint)) { step = 3; } } if (entityEndDistance <= tolerance && step == 2) { UpdateEntityColorAndList10(entity, 10); step = 4; firstEntity = 2; if (SearchTempList9(tempList9, nextLineStartPoint)) { step = 5; } } } } } if (firstEntity == 2 && step == 2) { var thisEntity = Geometry.RetrieveEntity(templist10[0]); if (thisEntity is LineGeometry line && step == 2) { GetEndPoints(line, out lineStartPoint, out lineEndPoint); if (entity is ArcGeometry nextArc && (entity.Color != 10) && (entity.Color != 11) && step == 2) { GetEndPoints(nextArc, out nextArcStartPoint, out nextArcEndPoint); entityStartDistance = VectorManager.Distance(lineEndPoint, nextArcStartPoint); entityEndDistance = VectorManager.Distance(lineEndPoint, nextArcEndPoint); if (entityStartDistance <= tolerance && step == 2) { UpdateEntityColorAndList10(entity, 10); step = 2; firstEntity = 1; if (SearchTempList9(tempList9, nextArcEndPoint)) { step = 3; } } if (entityEndDistance <= tolerance && step == 2) { UpdateEntityColorAndList10(entity, 10); step = 4; firstEntity = 1; if (SearchTempList9(tempList9, nextArcStartPoint)) { step = 5; } } if (entity is LineGeometry nextLine && (entity.Color != 10) && (entity.Color != 11) && step == 2) { GetEndPoints(nextLine, out nextLineStartPoint, out nextLineEndPoint); entityStartDistance = VectorManager.Distance(lineEndPoint, nextLineStartPoint); entityEndDistance = VectorManager.Distance(lineEndPoint, nextLineEndPoint); if (entityStartDistance <= tolerance && step == 2) { UpdateEntityColorAndList10(entity, 10); step = 2; firstEntity = 2; if (SearchTempList9(tempList9, nextLineEndPoint)) { step = 3; } } if (entityEndDistance <= tolerance && step == 2) { UpdateEntityColorAndList10(entity, 10); step = 4; firstEntity = 2; if (SearchTempList9(tempList9, nextLineStartPoint)) { step = 5; } } } } } } } // Gets Geo that connects first entity start point to second entity start point (offset 2) if (step == 5) { System.Windows.Forms.MessageBox.Show("step 5"); foreach (var entity in chainEntity) { if (firstEntity == 1 && step == 3) { var thisEntity = Geometry.RetrieveEntity(templist10[0]); if (thisEntity is ArcGeometry arc && step == 3) { GetEndPoints(arc, out arcStartPoint, out arcEndPoint); if (entity is ArcGeometry nextArc && (entity.Color != 10) && (entity.Color != 11) && step == 3) { GetEndPoints(nextArc, out nextArcStartPoint, out nextArcEndPoint); entityStartDistance = VectorManager.Distance(arcEndPoint, nextArcStartPoint); entityEndDistance = VectorManager.Distance(arcEndPoint, nextArcEndPoint); if (entityStartDistance <= tolerance && step == 3) { UpdateEntityColorAndList10(entity, 11); step = 3; firstEntity = 1; if (SearchTempList9(tempList9, nextArcEndPoint)) { step = 2; } } if (entityEndDistance <= tolerance && step == 3) { UpdateEntityColorAndList10(entity, 11); step = 5; firstEntity = 1; if (SearchTempList9(tempList9, nextArcStartPoint)) { step = 4; } } } if (entity is LineGeometry nextLine && (entity.Color != 10) && (entity.Color != 11) && step == 3) { GetEndPoints(nextLine, out nextLineStartPoint, out nextLineEndPoint); entityStartDistance = VectorManager.Distance(arcEndPoint, nextLineStartPoint); entityEndDistance = VectorManager.Distance(arcEndPoint, nextLineEndPoint); if (entityStartDistance <= tolerance && step == 3) { UpdateEntityColorAndList10(entity, 11); step = 3; firstEntity = 2; if (SearchTempList9(tempList9, nextLineEndPoint)) { step = 2; } } if (entityEndDistance <= tolerance && step == 3) { UpdateEntityColorAndList10(entity, 11); step = 5; firstEntity = 2; if (SearchTempList9(tempList9, nextLineStartPoint)) { step = 4; } } } } } if (firstEntity == 2 && step == 3) { var thisEntity = Geometry.RetrieveEntity(templist10[0]); if (thisEntity is LineGeometry line && step == 3) { GetEndPoints(line, out lineStartPoint, out lineEndPoint); if (entity is ArcGeometry nextArc && (entity.Color != 10) && (entity.Color != 11) && step == 3) { GetEndPoints(nextArc, out nextArcStartPoint, out nextArcEndPoint); entityStartDistance = VectorManager.Distance(lineEndPoint, nextArcStartPoint); entityEndDistance = VectorManager.Distance(lineEndPoint, nextArcEndPoint); if (entityStartDistance <= tolerance && step == 3) { UpdateEntityColorAndList10(entity, 11); step = 3; firstEntity = 1; if (SearchTempList9(tempList9, nextArcEndPoint)) { step = 2; } } if (entityEndDistance <= tolerance && step == 3) { entity.Color = 11; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 5; firstEntity = 1; if (SearchTempList9(tempList9, nextArcStartPoint)) { step = 4; } //foreach (var v in tempList9) //{ // var w = Geometry.RetrieveEntity(v);// Gets point based on GeoID // if (w is PointGeometry point) // { // var ux = point.Data.x;// X location of point // var uy = point.Data.y;// Y location of point // Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location // var entityPointDistance = VectorManager.Distance(uPoint, nextArcStartPoint); // if (entityPointDistance <= tolerance) // { // step = 4; // } // } //} } } if (entity is LineGeometry nextLine && (entity.Color != 10) && (entity.Color != 11) && step == 3) { GetEndPoints(nextLine, out nextLineStartPoint, out nextLineEndPoint); entityStartDistance = VectorManager.Distance(lineEndPoint, nextLineStartPoint); entityEndDistance = VectorManager.Distance(lineEndPoint, nextLineEndPoint); if (entityStartDistance <= tolerance && step == 3) { UpdateEntityColorAndList10(entity, 11); step = 3; firstEntity = 2; if (SearchTempList9(tempList9, nextLineEndPoint)) { step = 2; } } if (entityEndDistance <= tolerance && step == 3) { UpdateEntityColorAndList10(entity, 11); step = 5; firstEntity = 2; if (SearchTempList9(tempList9, nextLineStartPoint)) { step = 4; } } } } } } } // Gets Geo that connects first entity start point to second entity start point (offset 1) } } } ///<summary> Search the list of entities for a matching point position </summary> /// ///<param name="entIdList"> The list of entity IDs to search </param> ///<param name="pt"> The point position to look for in the list </param> /// ///<returns> Thrue if a match was found, else false </returns> private bool SearchTempList9(List<int> entIdList, Point3D pt) { foreach (var entId in entIdList) { var geom = Geometry.RetrieveEntity(entId); if (geom is PointGeometry point) { var ux = point.Data.x; // X location of point var uy = point.Data.y; // Y location of point var uPoint = new Point3D(ux, uy, 0.0); // Saves point location var entityPointDistance = VectorManager.Distance(uPoint, pt); if (entityPointDistance <= tolerance) { return true; } } } return false; } ///<summary> Search the list of entities for a matching point position </summary> /// ///<param name="entity"> The arc ntity to match </param> ///<param name="pt"> The point position to look for in the list </param> /// ///<returns> Thrue if a match was found, else false </returns> private int SearchTempList9Arcs(Geometry entity, int step) { if (entity is ArcGeometry arc && step == 0) { var arcStartPoint = new Point3D(); // Arc start point var arcEndPoint = new Point3D(); // Arc end point GetEndPoints(arc, out arcStartPoint, out arcEndPoint); foreach (var v in tempList9) { var w = Geometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point && step == 0) { var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point var uPoint = new Point3D(ux, uy, 0.0);// Saves point location var arcStartDistance = Math.Abs(VectorManager.Distance(uPoint, arcStartPoint));// Distance between entity start point and crossover point var arcEndDistance = Math.Abs(VectorManager.Distance(uPoint, arcEndPoint));// Distance between entity end point and crossover point if (arcStartDistance <= tolerance /*&& step == 0*/) { entity.Color = 10;// Changes color of entity to 10 entity.Commit();// Saves entity into Mastercam Database templist10.Add(entity.GetEntityID()); step = 1;// Sets step to 1 } } } } return step; } ///<summary> Search the list of entities for a matching point position </summary> /// ///<param name="entity"> The line ntity to match </param> ///<param name="pt"> The point position to look for in the list </param> /// ///<returns> Thrue if a match was found, else false </returns> private int SearchTempList9Lines(Geometry entity, int step) { if (entity is LineGeometry line && step == 0) { var lineStartPoint = new Point3D(); // Line start point var lineEndPoint = new Point3D(); // Line end point GetEndPoints(line, out lineStartPoint, out lineEndPoint); foreach (var v in tempList9) { var w = Geometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point && step == 0) { var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point var uPoint = new Point3D(ux, uy, 0.0);// Saves point location var lineStartDistance = Math.Abs(VectorManager.Distance(uPoint, lineStartPoint));// Distance between entity start point and crossover point var lineEndDistance = Math.Abs(VectorManager.Distance(uPoint, lineEndPoint));// Distance between entity end point and crossover point if (lineStartDistance <= tolerance && step == 0) { entity.Color = 10;// Changes color of entity to 10 entity.Commit();// Saves entity into Mastercam Database templist10.Add(entity.GetEntityID()); step = 1;// Sets step to 1 } } } } return step; } ///<summary> Get the start and end points of a line or arc entity. </summary> // /// <remarkis> The Z coordinate of the points is forced to be '0' </remarkis> /// ///<param name="geom"> The line or arc entity </param> ///<param name="startPt"> [out] The start point </param> ///<param name="endPt"> [out] The end point </param> private void GetEndPoints(Geometry geom, out Point3D startPoint, out Point3D endPoint) { if (geom is LineGeometry line) { startPoint = new Point3D(line.EndPoint1.x, line.EndPoint1.y, 0.0); endPoint = new Point3D(line.EndPoint2.x, line.EndPoint2.y, 0.0); } else if (geom is ArcGeometry arc) { startPoint = new Point3D(arc.EndPoint1.x, arc.EndPoint1.y, 0.0); endPoint = new Point3D(arc.EndPoint2.x, arc.EndPoint2.y, 0.0); } else { // TODO: Let the user that we where given something other than a line or arc! startPoint = new Point3D(); endPoint = new Point3D(); } } private void UpdateEntityColorAndList10(Geometry entity, byte color) { entity.Color = color; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); } } }
    1 point
  8. I do. Step up comes in handy when you deal with ribs
    1 point
  9. I look at that motion and in my opinion, WAY too slow
    1 point

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...