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:

Zaffin_D

Verified Members
  • Posts

    374
  • Joined

  • Days Won

    1

Zaffin_D last won the day on May 8 2021

Zaffin_D had the most liked content!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Zaffin_D's Achievements

Apprentice

Apprentice (3/14)

  • Dedicated Rare
  • Very Popular Rare
  • First Post Rare
  • Collaborator Rare
  • Week One Done

Recent Badges

237

Reputation

  1. Can you provide an example? The below works for me. std::wstring filename (geo_filename);
  2. To normalize/unitize is to make the Vector have a length of 1unit.
  3. If you want to know how alike two 3D vectors are, normalize them, then dot them. If the dot product is 0 (or very close to it, remember not to trust floating point numbers) then the vectors are orthogonal. If the dot product is -1 then they are 180 degree apart.
  4. Maybe the update I just pushed will correct this behavior.
  5. I just tested 2021 and it worked with the most basic example... pheader$ sparameter$ = opinfo(1051, 0) ">>>" sparameter$, e$ I'd send a zip2go over to [email protected], perhaps they can sort it out.
  6. Here is a link to a full refactor on GitHub. I'm not sure if it's doing what you want, but it does something!
  7. I looked at the NCI and each operation (even contour ramp) contains a 1051 after the 999. I've also had no trouble doing the following... #// Postblock op_index : 0 operation_id : 0 s_machine_name : "" p_write_machine_names op_index = 0 while s_machine_name <> "-99999", [ operation_id = opinfo(1, op_index) s_machine_name = opinfo(1051, op_index) *operation_id, s_machine_name, e$ op_index = op_index + 1 s_machine_name = opinfo(1051, op_index) ] #// Call pheader$ #Call before start of file p_write_machine_names // Sample output operation_id 1. Mill Default operation_id 2. Mill Default % O0000(T) (DATE=DD-MM-YY - 19-11-22 TIME=HH:MM - 11:07) (MCAM FILE - T) My operations. Can you share a bit more about what you are trying to do?
  8. I haven't done a full refactor of your code, but you are repeating yourself a lot. I refactored one of your methods, offsetCutchain. First, I created two service classes: SelectionUtilities... // File: SelectionUtilities.cs using Mastercam.Database.Types; using Mastercam.GeometryUtility; using Mastercam.IO; using Mastercam.Support; namespace eMastercamRateMyCode { internal class SelectionUtilities { public void UnselectAll() => SelectionManager.UnselectAllGeometry(); public void TurnOffVisibleLevels(bool refreshLevelsList = true) { var shown = LevelsManager.GetVisibleLevelNumbers(); foreach (var level in shown) { LevelsManager.SetLevelVisible(level, false); } if (refreshLevelsList) LevelsManager.RefreshLevelsManager(); } public void SetMainLevel(int levelNumber, bool makeVisible = true, bool refreshLevelsList = true) { LevelsManager.SetMainLevel(levelNumber); LevelsManager.SetLevelVisible(levelNumber, makeVisible); if (refreshLevelsList) LevelsManager.RefreshLevelsManager(); GraphicsManager.Repaint(true); } public bool CreateLevel(int levelNumber, string levelName, bool setAsMain = true, bool makeVisible = true) { var result = LevelsManager.SetLevelName(levelNumber, levelName); if (setAsMain) LevelsManager.SetMainLevel(levelNumber); LevelsManager.SetLevelVisible(levelNumber, makeVisible); LevelsManager.RefreshLevelsManager(); return result; } public int MoveSelectedToLevel(int levelNumber, bool clearSelection = true, bool clearColors = true) { var numberOfEntsCopied = GeometryManipulationManager.MoveSelectedGeometryToLevel(levelNumber, clearSelection); if (clearColors) GraphicsManager.ClearColors(new GroupSelectionMask(true)); return numberOfEntsCopied; } public int ColorAndSelectResultGeometry(int colorID, bool isSelected = true) { var numberOfEntsCommitted = 0; var resultGeometry = SearchManager.GetResultGeometry(); foreach (var geometryEntity in resultGeometry) { geometryEntity.Color = colorID; geometryEntity.Selected = isSelected; if (geometryEntity.Commit()) numberOfEntsCommitted++; } return numberOfEntsCommitted; } } } ...and GeometryUtilities... // File: GeometryUtilities.cs using Mastercam.Curves; using Mastercam.Database; using Mastercam.Database.Types; using Mastercam.Math; using System.Collections.Generic; using System.Linq; namespace eMastercamRateMyCode { internal class GeometryUtilities { public bool CreateLine(Crease crease) { var lowerPoint = new Point3D(crease.LowerPoint.X, crease.UpperPoint.Y, 0.0); var upperPoint = new Point3D(crease.UpperPoint.X, crease.UpperPoint.Y, 0.0); var line = new LineGeometry(lowerPoint, upperPoint); line.Selected = true; return line.Commit(); } public List<Chain> ChainAllByLevel(int levelToChain) => ChainManager.ChainAll(levelToChain).ToList(); public Chain OffsetChainLeft(Chain chainToOffset, double radius) { return OffsetChain(chainToOffset, OffsetSideType.Left, radius); } public Chain OffsetChainRight(Chain chainToOffset, double radius) { return OffsetChain(chainToOffset, OffsetSideType.Right, radius); } private Chain OffsetChain(Chain chainToOffset, OffsetSideType offsetSide, double radius) { return chainToOffset.OffsetChain2D(offsetSide, radius, OffsetRollCornerType.None, .5, false, .005, false); } } } The I created the UtilitiesFacade facade... // File: UtilitiesFacade.cs namespace eMastercamRateMyCode { internal class UtilitiesFacade { public SelectionUtilities Selection; public GeometryUtilities Geometry; public UtilitiesFacade() { } } } I also created two small structs to hold common chain data. public struct LevelData { public int Number { get; set; } public string Name { get; set; } } public struct ChainData { public LevelData Level { get; set; } public int ColorID { get; set; } public double SmallOffsetRadius { get; set; } public double LargeOffsetRadius { get; set; } } With that done, the refactored method offsetCutchain looks like this... void OffsetCutChain(int cutChainlevel, ChainData lower, ChainData upper) { var utilities = new UtilitiesFacade(); utilities.Selection.UnselectAll(); utilities.Selection.TurnOffVisibleLevels(); utilities.Selection.SetMainLevel(cutChainlevel); utilities.Selection.CreateLevel(lower.Level.Number, lower.Level.Name); utilities.Selection.CreateLevel(upper.Level.Number, upper.Level.Name); foreach (var chain in utilities.Geometry.ChainAllByLevel(cutChainlevel)) { utilities.Geometry.OffsetChainRight(chain, lower.SmallOffsetRadius); utilities.Geometry.OffsetChainLeft(chain, lower.LargeOffsetRadius); utilities.Selection.ColorAndSelectResultGeometry(11); utilities.Selection.MoveSelectedToLevel(lower.Level.Number); utilities.Geometry.OffsetChainLeft(chain, upper.SmallOffsetRadius); utilities.Geometry.OffsetChainRight(chain, upper.LargeOffsetRadius); utilities.Selection.ColorAndSelectResultGeometry(upper.ColorID); utilities.Selection.MoveSelectedToLevel(upper.Level.Number); } } This still is not ideal (could use more abstraction, less dependencies, etc.), but it's far less repetitive. Hope that helped, Zaffin
  9. Try right clicking on the tool parameters tab, the option is there.
  10. What have your tried? The abstract; at tool change, read the operation comment into a variable using opinfo. Once you have the comment, use the regex function to parse it.
  11. No, chamfer drill cannot produce a canned cycle.
  12. I’m riffing this (I don’t have access to a PC till next week), so I expect it to be about 80% correct. Get the next tool number using opinfo, if you want the next operation, use a 1 for the number of ops to look ahead. Compare that to the current tool number, if they are equal (or the next tool number is -99999) do nothing. If the next tool number is different than the current tool number (and not -99999), get the next tool’s description and output it. You always want to look ahead to the next operation, and there is no easy license plate setting to get the next operations parameter if the tool changed.
  13. The tt_ variables are only numeric if I recall correctly. The opinfo function is the way to go here.
  14. You don’t need a buffer. Search the documentation for opinfo, you can query the next operations tool description easily.

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...