-
Posts
30 -
Joined
-
Last visited
samuelhanson's Achievements
Newbie (1/14)
1
Reputation
-
Sorry for delay, I was focused on other projects. This could still be useful. Can we pass a Mastercam.Database.Operation entity for sourceOperation? And an integer for tagetIndex. Perhaps: InsertAt(operation, targetIndex) InsertBefore(operation, targetOperation) InsertAfter(operation, targetOperation) If that isn't possible, then perhaps move all ops with selected flag set: insertSelectedAt(targetIndex) If SearchManager.GetOperations always returns in same order as the toolpath manager list, that would be good in itself. Otherwise a way to get a list of operations in that order would be useful.
-
Tools in external file
samuelhanson replied to samuelhanson's topic in Mastercam C-Hook, NET-Hook and VBScript Development
That is what I meant. Thanks. -
When importing tools from an external file is there a way to distinguish tools in a drilling block from "library" tools? var toolData = new Mastercam.Database.Tool[0]; bool res = Mastercam.Support.SearchManager.GetToolsInExternalFile(file, ref toolData); if (res) { foreach (var ft in toolData) { System.Windows.Forms.MessageBox.Show(@"Importing tool " + ft.Number.ToString() + " named " + ft.Name + " type " + ft.ToolTypeID); } } The tools in the drill block defined in the Machine Def are imported along with the tool library tools. First tool imported is of BlockDrill type, then the next (9 in my case) tools are of Drill type and are from the drilling block. How can I know that these (9) are part of the block drilling unit? In this specific case I want to read only tools in the tool library and ignore those in the drilling block.
-
Edit Posting Details
samuelhanson replied to Synturion's topic in Mastercam C-Hook, NET-Hook and VBScript Development
Quite similar to Mick's, this is the function I wrote and use in my current project. Also, I have multi-threading disabled in Mastercam for toolpath generation. This is to ensure all regeneration is complete before posting. (See here for more info) public static bool regenAndPost(string fileName, bool onlySelected){ string pathNCI = System.IO.Path.ChangeExtension(fileName,".nci"); Mastercam.Database.Operation[] allOps = Mastercam.Support.SearchManager.GetOperations(onlySelected); foreach (var op in allOps) { op.NCIName = pathNCI; op.Commit(false); if (op.Dirty) { op.Regenerate(); } } foreach (var op in allOps) { op.Retrieve(); if (op.Dirty) { System.Windows.Forms.MessageBox.Show("Error - dirty operation. Try again."); return false; } } Mastercam.Operations.OperationsManager.PostAllOperations(System.IO.Path.GetDirectoryName(pathNCI), true); Mastercam.Operations.OperationsManager.RefreshOperationsManager(); return true; } -
Related, The NC file is opening for editing even when I specify not to. Any ideas what might cause this? public static bool regenAndPost(string fileName, bool onlySelected){ //Regenerate toolpaths //... //Post Mastercam.Operations.OperationsManager.PostAllOperations(System.IO.Path.GetDirectoryName(fileName),false); return true; }
-
I am trying to regenerate and post a number of operations from a C# NET-Hook. I iterate through each operation, regenerate if necessary, then start the post processor. If multi-threading is enabled sometimes the regeneration is not completed before the post processor is initiated. When that happens it doesn't post properly. Turn multi-threading off and everything works perfect but slower. How can I make the post processor wait until operations are finished regenerating? string pathNC = Mastercam.IO.SettingsManager.UserDirectory+@"Router\NC\new"; Mastercam.Database.Operation[] selectedOps = Mastercam.Support.SearchManager.GetOperations(false); foreach (var op in selectedOps) { op.NCIName = Mastercam.IO.SettingsManager.UserDirectory + @"Router\NCI\cake.nci"; op.Commit(false); if (op.Dirty) { op.Regenerate(); } } // System.Threading.Thread.Sleep(10000); //Wait... but apparently that locks up the regeneration too. foreach (var op in selectedOps) { op.Retrieve(); if (op.Dirty) { System.Windows.Forms.MessageBox.Show("Error - dirty operation"); return; } } Mastercam.Operations.OperationsManager.PostOperations(selectedOps, pathNC, true, false); Mastercam X9 Router, C# NET-Hook
-
I ran into a few problems related to level visibility. All have been worked around, but I'd like to bring them up for the sake of understanding. Mastercam X9, Router, C# NET-Hook 1. If a level visibility is toggled to hidden using LevelsManager.SetLevelVisible(Level, false); then the level entities will not show when it is first toggled back to visible through the level manager unless I use Screen>Regenerate Display List. Toggling twice (on-off-on) in the level manager will also cause it to show. Is there a way to turn a level visibility off in the nethook such that the mastercam user will be able to toggle it back on with one click in the level manager? Calling LevelsManager.SetLevelVisible(Level, false); GraphicsManager.Repaint(true);//repaint with full regenerate still seemed to have the same symptoms. 2. If entities are created on an invisible level like so lineTopC = new LineGeometry(new Point3D(bx2, by2, bz), new Point3D(bx2, by1, bz)); lineTopC.Color = baseColor; lineTopC.Level = doorLevel; lineTopC.Commit(); Then chaining using that geometry reference will fail Geometry[] geo = {lineTopC}; var op = (Mastercam.Operations.ContourOperation)Services.UtilityService.CreateContourOp(); Chain[] geoChain = ChainManager.ChainGeometry(geo); //^^^ this fails when lineTopC.Level is set and Commit()ed to an invisible level. op.SetChainArray(geoChain); op.Name = @"Bottom"; op.Commit(); Is there a way to create geometry on an invisible level then chain it using the references?I worked around by checking and setting visibility to true before creating and chaining geometry, but still run into #1 if I try to restore the prior (hidden) level visibility after function is complete. Edit on #2: May have found a case where it works... I'll look into that more and update
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.