-
Posts
30 -
Joined
-
Last visited
Content Type
Profiles
Forums
Downloads
Store
eMastercam Wiki
Blogs
Gallery
Events
Everything posted by samuelhanson
-
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
-
It doesn't seem do anything for me, so that lines up When I change the OperationTool of an op, I need to also explicitly update all feeds and speeds if I want them to match? Right now my operation is created with a default tool. Then I programatically change the OperationTool, but the feeds and speeds still match the original tool. It's fine if that is just the way it is - the following snippet does what I need. But I'm curious if there's a more elegant solution that I missed. op.OperationTool = tool; op.SpindleSpeed = tool.RPM; op.FeedRate = tool.Feed; op.PlungeRate = tool.PlungeFeed; op.RetractRate = tool.RetractFeed; op.Commit(); What type of tool-specific settings are updated in the operation?
-
The Operation.UpdateToolSettings method is not working how I would expect. I assumed it would set the feeds and speed of the operation the match the tool parameters, like right clicking on a tool and choosing "Re-initialize feeds and speeds" in the operation parameters window. However I have not noticed anything change after calling that function on an operation. Can you help me understand how this function works, and if it is working? op.OperationTool = tool; op.Commit(); op.UpdateToolSettings(); vs. op.OperationTool = tool; op.SpindleSpeed = tool.RPM; op.FeedRate = tool.Feed; op.PlungeRate = tool.PlungeFeed; op.RetractRate = tool.RetractFeed; op.Commit(); Mastercam X9 (18.0.18466.0) Router C# NET-Hook
-
NETHook create operation
samuelhanson replied to samuelhanson's topic in Mastercam C-Hook, NET-Hook and VBScript Development
That would explain it - I am using a Router group. For the time being I'll import the operation from an existing file - that will be fine for now. -
NETHook create operation
samuelhanson replied to samuelhanson's topic in Mastercam C-Hook, NET-Hook and VBScript Development
Interesting. Thank you for looking into it. I'll create a test case separate from my main code and try again. -
In C#, MX9: When creating a new pocket operation, a new machining group is also being created. Even though one already exists. And the first time I commit the new operation, a third machining group is created. Is this normal? It can be worked around, but I would like to create the operation in the active machining group without creating new ones. Is there a way to do this? Mastercam.Operations.PocketOperation op = new Mastercam.Operations.PocketOperation(); op.Commit();
-
NETHook Mirror
samuelhanson replied to samuelhanson's topic in Mastercam C-Hook, NET-Hook and VBScript Development
In case anyone else runs into this, here's a C# NET-Hook function that mirrors specific geometry with GeometryManipulationManager while retaining user selections. public static void mirrorGeometry(Geometry[] geometry) { var line = new Line3D(new Point3D(0, 0, 0), new Point3D(1, 0, 0)); var view = SearchManager.GetSystemView(Mastercam.IO.Types.GraphicsViewType.Top); var selectedGeometry = SearchManager.GetSelectedGeometry(); SelectionManager.UnselectAllGeometry(); foreach (var geo in geometry) { geo.Selected = true; geo.Commit(); } Mastercam.GeometryUtility.GeometryManipulationManager.MirrorGeometry(line, view, false); SelectionManager.UnselectAllGeometry(); foreach (var geo in selectedGeometry) { geo.Retrieve(); geo.Selected = true; geo.Commit(); } GraphicsManager.ClearColors(new GroupSelectionMask(true)); GraphicsManager.Repaint(true); } -
NETHook Mirror
samuelhanson replied to samuelhanson's topic in Mastercam C-Hook, NET-Hook and VBScript Development
That is working for me - thank you. -
I have a problem when mirroring geometry in C#, MX9. The graphics change and appear mirrored, but any operation or analysis uses the original location. var allGeometry = SearchManager.GetGeometry(); foreach (var geo in allGeometry) { geo.Mirror(new Line3D(new Point3D(0, 0, 0), new Point3D(1, 0, 0)), SearchManager.GetSystemView(Mastercam.IO.Types.GraphicsViewType.Top)); geo.Commit(); } And after mirror: How does one properly mirror geometry?
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.