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:

JKLINE

Verified Members
  • Posts

    166
  • Joined

  • Last visited

Everything posted by JKLINE

  1. And I'm officially stuck The first portion works in Mastercam, but the second portion throws an alarm. "Method not found: 'Boolean Mastercam.IO.Interop.SelectionManager.AlterContourFinish(Int32, Double, Double, Double)'." Maybe I put something in the wrong place? Or am calling it incorrectly? static System::Collections::Generic::List<int>^ GetOperations(int opCode) { auto list = gcnew System::Collections::Generic::List<int>(); for (auto index = 0; index < TpMainOpMgr.GetMainOpList().GetSize(); ++index) { auto op = TpMainOpMgr.GetMainOpList()[index]; if (op && (opCode == TP_NULL || op->opcode == opCode)) { list->Add(op->op_idn); } } return list; }; static bool SelectionManager::AlterContourFinish(long opID, double maxStepdown, double minDepth, double maxDepth) { //Get prm_srf_common opCommon; prm_srf_depths opDepth; tp_entity thisToolPath; thisToolPath.op_idn = opID; //Set opCommon.prm_srf_common::max_stepdown = maxStepdown; opDepth.prm_srf_depths::min_depth = minDepth; opDepth.prm_srf_depths::max_depth = maxDepth; return true; }; static bool SelectionManager::AlterPencilFinish(long opID, bool status, double limitOne, double limitTwo) { //Get prm_srf_limits opData; tp_entity thisToolPath; thisToolPath.op_idn = opID; //Set opData.prm_srf_limits::on = status; opData.prm_srf_limits::z1 = limitOne; opData.prm_srf_limits::z2 = limitTwo; return true; }; OperationsManager.UnSelectAllOperations(); var surfaceFinishContourOpID = Mastercam.IO.Interop.SelectionManager.GetOperations(15); var surfaceFinishPencilOpID = Mastercam.IO.Interop.SelectionManager.GetOperations(39); foreach (var op in surfaceFinishContourOpID) { var thisOp = SearchManager.GetOperation(op); thisOp.SetSelectedState(true); Mastercam.IO.Interop.SelectionManager.AlterContourFinish(op, 0.2, -0.2, -0.2); } OperationsManager.RefreshOperationsManager(true); foreach (var op in surfaceFinishPencilOpID) { var thisOp = SearchManager.GetOperation(op); thisOp.SetSelectedState(true); } OperationsManager.RefreshOperationsManager(true); return MCamReturn.NoErrors; https://github.com/UberGamz/SurfaceInterop (CLI) https://github.com/UberGamz/Rotary-PD---Copy (Nethook)
  2. Even closer! One problem though C++ has 'rules' "C++ a nonstatic member reference must be relative to a specific object" static bool AlterContourFinish(long opID, double maxStepdown, double minDepth, double maxDepth) { //Get auto thisOp = TpOpList::OpByID(opID); //Set thisOp.prm_srf_common::max_stepdown = maxStepdown; thisOp.prm_srf_depths::min_depth = minDepth; thisOp.prm_srf_depths::max_depth = maxDepth; return ; } static bool AlterPencilFinish(long opID, bool status, double limitOne, double limitTwo) { //Get auto thisOp = TpOpList::OpByID(opID); //Set thisOp.prm_srf_limits::on = status; thisOp.prm_srf_limits::z1 = limitOne; thisOp.prm_srf_limits::z2 = limitTwo; return ; }
  3. It's a Christmas Miracle! Got it to select the pencil and finish contour toolpaths. Thank you so much! Put this into my NetHook portion :: OperationsManager.UnSelectAllOperations(); var surfaceFinishContourOpID = Mastercam.IO.Interop.SelectionManager.GetOperations(15); var surfaceFinishPencilOpID = Mastercam.IO.Interop.SelectionManager.GetOperations(39); foreach (var op in surfaceFinishContourOpID) { var thisOp = SearchManager.GetOperation(op); thisOp.SetSelectedState(true); } OperationsManager.RefreshOperationsManager(true); foreach (var op in surfaceFinishPencilOpID) { var thisOp = SearchManager.GetOperation(op); thisOp.SetSelectedState(true); } OperationsManager.RefreshOperationsManager(true); return MCamReturn.NoErrors; I pasted this into the SelectionMangerExample.h static System::Collections::Generic::List<int>^ GetOperations(int opCode) { auto list = gcnew System::Collections::Generic::List<int>(); for (auto index = 0; index < TpMainOpMgr.GetMainOpList().GetSize(); ++index) { auto op = TpMainOpMgr.GetMainOpList()[index]; if (op && (opCode == TP_NULL || op->opcode == opCode)) { list->Add(op->op_idn); } } return list; } Taking this to the finish line, I've found all the codes I'll need I believe. Just need practice calling them in C++. I feel like i'm sooooo close but soooo far away static bool AlterContourFinish(int opCode) { bool succ = false; /// <summary> operation parameters - surface finish contour. </summary> struct prm_srf_fin_contour { prm_srf_common common; //!< common parameters for all surface operations prm_srf_depths depth; //!< surface operation's depth settings } /// <summary> operation parameters - surface operation's depth settings. </summary> struct prm_srf_depths { double min_depth; //!< abs: highest cut double max_depth; //!< abs: lowest cut }; /// <summary> operation parameters - common parameters for all surface operations. </summary> struct prm_srf_common { double max_stepdown; //!< maximum stepdown }; if (succ) return succ; } static bool AlterPencilFinish(int opCode) { bool succ = false; /// <summary> operation parameters - surface finish pencil. </summary> struct prm_srf_fin_pencil { prm_srf_limits limit; //!< surface operation's limit settings }; /// <summary> operation parameters - surface operation's limit settings. </summary> struct prm_srf_limits { bool on; //!< T-use cut depth limits double z1; //!< depth limit 1 double z2; //!< depth limit 2 }; if (succ) return succ; }
  4. Referencing the ChainDataInterOP source, this would go into the Main.CPP ? This would be a header file? And this would go into my NetHook file? I'm not sure why this is so difficult for me? https://github.com/UberGamz/SurfaceToolpathInterop
  5. I'm struggling to change the start entity of a chain. (closed chain). Wanting it to be the farthest entity that is to the left (most negative X), I use the logic as follows foreach (var chain in selectedChains){ var chainData = chainDetails.GetData(chain); var chainStartGeo = Geometry.RetrieveEntity(chain.FirstEntityId); if (chainStartGeo is ArcGeometry arcGeo){ var chainStartGeoEP1 = arcGeo.EndPoint1; var chainStartGeoEP2 = arcGeo.EndPoint2; var chainStartGeoMidpoint = new Point3D(((chainStartGeoEP1.x + chainStartGeoEP2.x) / 2),((chainStartGeoEP1.y + chainStartGeoEP2.y) / 2),0.0); var chainEntity = ChainManager.GetGeometryInChain(chain); foreach (var entity in chainEntity){ if (entity is ArcGeometry tempArc){ var entityGeoEP1 = tempArc.EndPoint1; var entityGeoEP2 = tempArc.EndPoint2; var entityGeoMidpoint = new Point3D(((entityGeoEP1.x + entityGeoEP2.x) / 2), ((entityGeoEP1.y + entityGeoEP2.y) / 2), 0.0); if (chainStartGeoMidpoint.x > entityGeoMidpoint.x){ chainData.FirstEntity = entity; } } I am using "ChainManager.RelinkChains(ref selectedChains);" after it goes through the checks, but it's not changing. Link :: https://github.com/UberGamz/CustomNethook Why am I trying to do this? When I select rightToLeft, it selects the colors of the chains correctly but when I select leftToRight, it colors 3 of the 4 chains correctly. I've narrowed it down to it being the start point of the chains inside the 'ColorCrossovers()'
  6. You would post this as a DLL, load it into the resources, and then call on it with opCode?
  7. You make that sound super easy I think I'm missing a large piece. I just find the parts in the C++ files that I need and copy them to where they go? Do you have a VS Project I can reference? Solution : ChainDataInterop Namespace : Mastercam Class : NETHookApiReflection Public Methods Class : Object Namespace : Mastercam.Database.Interop Class : ChainData Class : ChainDetails Public Methods Class : Object
  8. //Surface Finish Contour var maximumStepdown = 0.01; var contourMinimumDepth = 0; var contourMaximumDepth = 0; //Surface Finish Pencil var depthLimits = true; var pencilMinimumDepth = 0; var pencilMaximumDepth = 0; var selectedOps = SearchManager.GetOperations(true); foreach (var op in selectedOps) { op.Retrieve(); op.Linking. op.Commit(); } GraphicsManager.Repaint(true); return MCamReturn.NoErrors; I've started this code, but I'm not finding a LinkingParams to suit my needs. Looking to alter the circled boxes DepthCutsParams also didn't work.
  9. The intent is to compete with other software. Instead of importing customer geometry into other software, we'd like to import it directly into Mastercam. Two rotary dies that never touch. https://www.ardensoftware.com/products/impact-die-making-cad-cam-software/ Sheer cut instead of crush cut, making the metal last significantly longer.
  10. I greatly appreciate the assist. Only a form left to create and it'll be ready to demo and debug
  11. I'm so glad when I write new code, I don't do this anymore Works like a champ now. How did you find that so fast?
  12. This has become a large issue for me. I've taken all the 'repaint(true)' out of the program that I can. Some of the areas require it to be there, or they do not work. That being said, if I run two of my NetHooks, no matter the order, geometry gets moved I've tried added this code before and after each VOID but it's not helping. void deSelect() { var selectedGeo = SearchManager.GetGeometry(); foreach (var entity in selectedGeo) { entity.Retrieve(); entity.Selected = false; entity.Commit(); } } https://github.com/UberGamz/RP-GEN-CREASES https://github.com/UberGamz/RP-GEN-CUT They work fine SOLO, but when ran together during one Mastercam session, they mix up geometry.
  13. Solution :: var depth = -0.100; var roughAngle = 15.0; var finishAngle = 20.0; var selectedCutChain = ChainManager.GetMultipleChains("Select Geometry"); if (selectedCutChain == null) { return; } var depthDialog = DialogManager.AskForNumber("Enter Depth", ref depth); if (depthDialog == 0) { return; } var roughAngleDialog = DialogManager.AskForAngle("Enter Rough Angle", ref roughAngle); if (roughAngleDialog == 0) { return; } var finishAngleDialog = DialogManager.AskForAngle("Enter Finish Angle", ref finishAngle); if (finishAngleDialog == 0) { return; }
  14. var depth = -0.100; var roughAngle = 15.0; var finishAngle = 20.0; var selectedCutChain = ChainManager.GetMultipleChains("Select Geometry"); if (selectedCutChain == null) { return; } DialogManager.AskForNumber("Enter Depth", ref depth); if (depth == null) { return; } DialogManager.AskForAngle("Enter Rough Angle", ref roughAngle); if (roughAngle == null) { return; } DialogManager.AskForAngle("Enter Finish Angle", ref finishAngle); if (finishAngle == null) { return; } Agreed. Except depth, roughAngle, and finishAngle will never be null
  15. That looks like the exact thing I'm looking for Thank you. -- It doesn't work while waiting on user Input though. "oh no, I've clicked the wrong geometry, I'd like to exit instead of having to go through the rest of the motions." Thinking "if response == null, return"?
  16. While (escape key is not pressed){ --commit CHook-- } return This was my initial thought, but I can't get it to recognize when the escape key is pressed. I don't want it to exit at a specific time, I want it to exit when the user presses escape.
  17. I've looked around for a way to exit the script when the user hits the 'escape' key but failed to find a solution. Can't use 'console.readKey' because Mastercam doesn't have a console. I also found Mcamreturn (escape pressed) and looked into the UIevents I found this but it looks like it's pressing the keys, not waiting for keys to be pressed. //so, I press escape key 3 times or more.... for(int i=0;i<3;i++) { keybd_event(VK_ESCAPE, 0, 0, 0); keybd_event(VK_ESCAPE, 0, KEYEVENTF_KEYUP, 0); }
  18. if (Geometry.RetrieveEntity(surface10) is Geometry roughDraftSurface10) { roughDraftSurface10.Level = roughSurf; roughDraftSurface10.Commit(); } Changing from 'DraftSurface' to 'Geometry' fixed the level issue. It works great! Thank you Roger
  19. angle = Mastercam.Math.VectorManager.RadiansToDegrees(15) Fixed the angle issue This also fixed the 'not following arcs' issue.
  20. Using the code below, I'm getting a result, but some things seem strange. 1. It doesn't send the surface to a different level. 2. The angle I type in doesn't seem to matter. 15.0 results in -0.2618 degrees. 3. It follows the chains, but not the arcs. Did I code it wrong? void offsetCutchain(){ SelectionManager.UnselectAllGeometry(); LevelsManager.RefreshLevelsManager(); GraphicsManager.Repaint(true); var selectedCutChain = ChainManager.GetMultipleChains("Select Geometry"); int mainGeo = 10; int roughSurf = 138; SurfaceDraftParams roughSurfaceDraftParams = new SurfaceDraftParams { draftMethod=SurfaceDraftParams.DraftMethod.Length, geometryType=SurfaceDraftParams.GeometryType.Surface, length=-0.100, angle=15.0, draftDirection=SurfaceDraftParams.DraftDirection.Defined } ; foreach (var chain in selectedCutChain){ var mainGeoSide1 = chain.OffsetChain2D(OffsetSideType.Right, .002, OffsetRollCornerType.All, .5, false, .005, false); var mainGeoResult = SearchManager.GetResultGeometry(); foreach (var entity in mainGeoResult){ entity.Color = mainGeo; entity.Level = mainGeo; entity.Selected = true; entity.Commit(); } var thisChain10 = ChainManager.ChainAllSelected(); foreach (var draftChain10 in thisChain10) { var draftSurface10 = SurfaceDraftInterop.CreateDrafts(draftChain10, roughSurfaceDraftParams, false, 1); foreach (var surface10 in draftSurface10){ if (Geometry.RetrieveEntity(surface10) is DraftSurface roughDraftSurface10) { roughDraftSurface10.Level = roughSurf; roughDraftSurface10.Commit(); } } } GraphicsManager.ClearColors(new GroupSelectionMask(true)); } } offsetCutchain(); GraphicsManager.Repaint(true);
  21. Yes. Take customer geometry ChainOffsetContour(you've already helped me with this) DraftSurface(from the Result of ChainOffsetContour) at a negative depth (user specified) and angle (user specified). All ChainOffsetContour results are closed chains, and climb (Clockwise I think) direction is a positive angle. White line is customer supplied geometry. Green is the offsetContour in both directions. Surface is a draft surface at a negative value.
  22. Mastercam::CHookAPI::Database:: This was the key to finding the options/tools/methods ect ect. I'm still not seeing any 'surface' commands though. Enlighten me?

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