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:

Roger Martin from CNC Software

CNC Software
  • Posts

    2,870
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Roger Martin from CNC Software

  1. If appears from your code sample, that you are doing a NET-Hook, not a C-Hook (C++). In 2017 I do not see an option for the Groups. The ImportOperation functionality was re-worked in Mastercam 2018 and I do see that it has an option for the operation groups -> OperationsManager.ImportOptions.ImportOperationGroups Property Gets or sets a value indicating whether any associated operation (toolpath) groups will also be imported with the operation. See the on-line NET-Hook docs here -> https://nethookdocs.mastercam.com/
  2. It appears that you want to search for a tool in the local (loaded) part file, correct? But you are attempting to open the local (mcam) file "as a tool library" => Don't do that. You use OpenLibrary for .tooldb files. If a pass in Tool Number of "4" to this GetProfile method (with your sample file loaded), It returns me profile data with 7 segments. /// <summary> Gets the stored profile of a tool. </summary> /// /// <param name="toolNumber"> The tool number to match in the local part file tool list. </param> /// /// <returns> The profile is here is one, else null. </returns> private TlProfile GetProfile(int toolNumber) { var ts = TlToolFunctions.GetToolSystem(); // Get the Tool Assemblies in the local part file. var assemblies = ts.GetAssemblies(); foreach (var assembly in assemblies) { if (assembly.HasMainTool()) { var tlToolMill = assembly.GetMillTool(); if (tlToolMill != null && tlToolMill.ToolNumber == toolNumber) { try { TlProfile profile; if (tlToolMill.HasStoredProfile()) { profile = tlToolMill.StoredProfile; // Or getting the profile this way. //var result = tlToolMill.GetProfile(); //if (result.resultCode == TlProfileResultCode.NoError) //{ // profile = result.profile; //} DisplaySegmentData(profile, toolNumber, "Profile Segments"); return profile; } } catch (Exception e) { MessageBox.Show(e.Message); } } } } return null; } /// <summary> Display the segment data in a profile. </summary> /// /// <param name="profile"> The profile. </param> /// <param name="toolNumber"> The tool number. </param> /// <param name="title"> The title for the messagebox. </param> private void DisplaySegmentData(TlProfile profile, int toolNumber, string title) { if (profile != null) { var segments = profile.GetProfileSegmentsTopDown(); var sb = new StringBuilder("Tool Number = " + toolNumber); for (var i = 0; i < segments.Count; ++i) { var h = segments[i].GetHeight(); var l = segments[i].GetLength(); sb.AppendFormat("\nSeg#:{0} Height={1} Length={2}", i + 1, h, l); } MessageBox.Show(sb.ToString(), title); } }
  3. In your NET-Hook project you need to add a Reference to the ToolNetAPI.DLL, just like you do for the NETHook3_0.DLL (The NET-Hook API). Now you have access to the functionality under the Cnc.Tool.Interop namespace. using Cnc.Tool.Interop; /// <summary> Gets the tool profile. </summary> /// /// <param name="toolAssembly"> The tool assembly. </param> /// <param name="profile"> [out] The profile. </param> /// /// <returns> True if it succeeds, false if it fails. </returns> private bool GetToolProfile(TlAssembly toolAssembly, ref TlProfile profile) { if (toolAssembly.HasMainTool()) { TlProfileResult result = toolAssembly.GetMillTool().GetProfile(); if (result.resultCode == TlProfileResultCode.NoError) { profile = result.profile; // Profile data back to caller return true; } MessageBox.Show(result.errorMessage, toolAssembly.GetMillTool().Name, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } return false; }
  4. This is not possible with a NET-Hook. You'd have to do this with a C-Hook Add-In.
  5. The PNG files would not be in any Mastercam folder, as those images are embedded into your Add-In DLL. If your PNG images are in Resources of your DLL and the "names" given to them in the Resources of your NET-Hook project match what you are telling Mastercam in your FT file, and you are seeing these default "X" icons, this line in the FT file may be the problem -> In the dnRES_NAME line in the FT you must tell Mastercam where in your DLL these Resources exist. dnRES_NAME "HelloWorld_NETHook.Resources" Usually (can be different!) the path to these Resources in the Add-In Assembly will be -> [Root Namespace]\Resources You can find what the [Root Namespace] be look at the Application page in the Project properties of your Add-In.
  6. What you are asking for is possible . X5 was when the ability to get data “directly” back from an add-in (C-Hook or NET-Hook) that was run from within a PST became available. Is not the Date and Time data already available in the MP Post language? Here is from the std. MPFAN.PST from X7, showing different output styles -> sopen_prn, "DATE=DD-MM-YY - ", date$, " TIME=HH:MM - ", time$, sclose_prn, e$ #Date and time output Ex. 12-02-05 15:52 #sopen_prn, "DATE - ", month$, "-", day$, "-", year$, sclose_prn, e$ #Date output as month,day,year - Ex. 02-12-05 #sopen_prn, "DATE - ", *smonth, " ", day$, " ", *year2, sclose_prn, e$ #Date output as month,day,year - Ex. Feb. 12 2005 #sopen_prn, "TIME - ", time$, sclose_prn, e$ #24 hour time output - Ex. 15:52 #sopen_prn, "TIME - ", ptime sclose_prn, e$ #12 hour time output 3:52 PM
  7. There is a function here -> [SDK-Here]\interfaces\Core\ProjFun_CH.h Could you supply me an example file that demonstrates what you're starting with? (Surface & Point to be project normal to that surface?) And the output values you'd be looking for. mail to : SDK [at] mastercam [dot] com
  8. Do not know right now, but I'll investigate. What version of Mastercam ?
  9. Terry. The "remember the dialog position" memory doesn't really have anything to do with the version of Windows. In X9, the color picker dialog remembers its previous position. But... if you right-click to display the color picker dialog, you're in the "change color of existing entities" mode. In this mode, it is not remembering its position. Maybe not the desired behavior. This is now moot, as this code path no longer exists in Mastercam since the introduction of the Ribbon UI.
  10. You are looking for a quicker way to “select” all Operations that use a specific Tool# ? You used the term “sort” here, so that’s why I’m asking for clarification -> Also, what version of Mastercam are you running? Appears to be X9?
  11. Certainly is! Especially since X5 has been sunsetted and is no longer supported, and X6 will be in the same "no longer supported" state as soon as Mastercam 2018 is released, which will be soon.
  12. This code tested in Mastercam X9 (using the NETHook3_0 API). It is possible that it may not work in older versions. Imports System.IO Imports Mastercam.Support Namespace ChangeToolpathName Public Class ChangeNCI ''' <summary> Change the NCI/NC output name in the selected operations. </summary> ''' ''' <param name="onlySelectedOps"> (Optional) True to only process 'selected' operations, false to do all of the ops. </param> ''' ''' <returns> The number of operations that were altered. </returns> Public Function ChangeName(Optional onlySelectedOps As Boolean = False) As Integer Dim count = 0 Dim ops = SearchManager.GetOperations(onlySelectedOps) For Each op As var In ops ' Find the Group this Operation is in and then get the Name of that Group. Dim groupNumber = op.GroupNumber Dim group As Mastercam.Support.Group = GroupManager.FindGroupByID(groupNumber) ' Get the output folder path. Dim nciPath = Path.GetDirectoryName(op.NCIName) + "\" ' *** NOTE *** ' A Group Name could contain characters that are invalid for a path\name! ' We are NOT doing any checking for that situation here! ' Build up the new toolpath output file name. Dim newPath = nciPath + group.Name + ".NCI" op.NCIName = newPath ' Older Mastercam may not have this true/false parameter on .Commit() If op.Commit(False) Then count += 1 End If Next Return count End Function End Class End Namespace
  13. Could we get a bit more information here? Any errors? What are the specific types of the toolpath operation you are trying to .Commit?
  14. You have changed the something in the .NET "Operation" object. You have to tell it if you wish to "commit" the change(s) made to the Operation into Mastercam's database. For Each op As Mastercam.Database.Operation In SearchManager.GetOperations(True) intCount = intCount + 1 op.NCIName = Microsoft.VisualBasic.ChrW(op.OperationTool.Number) op.Commit(False) ' commit the change Next Note that the NET-Hook API does not recognize every type of tool operation in Mastercam. Do not attempt to .Commit "unknown" Operation types.
  15. Doing a Solid Pattern from a Add-In is not supported at this time. I'll enter a request with the CAD Team to see if they could make this available sometime in the future. For their reference, could you supply details of exactly what you're wishing to pattern? Send to -> SDK <at> mastercam <dot> com
  16. sld_extrude_from_chain is in the MCGeomSld.lib Have you included this library file in your project's Linker settings? Place this in a CMD (BATch) file and use it to "find" the .LIB file a function resides in. REM This will create a text file for each .LIB file (in the current folder) REM containing a list of the exported functions in that .LIB REM It must be run from a Visual Studio Developer Command Prompt window, REM so that the 'DumpBin' will be found. REM Then you can use 'Find in Files' from within Visual Studio to search REM for the function name in question within the resulting text files. @ECHO OFF FOR %%f IN (*.lib) DO ( ECHO Dumping exports from "%%f" DumpBin /exports %%f > %%~f_Exports.txt )
  17. That code works fine for me. You must have the path wrong or the name wrong in the Linker settings. Or that files does not exist (which it certainly should from the Mastercam 2017 C-Hook SDK install). Linker Tools Error LNK1104 -> https://msdn.microsoft.com/en-us/library/ts7eyw4s.aspx
  18. In your project, is there a proper path to where that .LIB file is located on your system? Check here: Project properties - Linker - General- Additional Library Directories
  19. Which version of Mastercam? "Linker error" without the actual message doesn't give much information to go on. The sld_extrude_from_chain function is in the MCGeomSld.lib Do you have that library included in your project? -> Project properties - Linker - Input - Additional Dependencies If you do have the correct libraries in the project and you're getting a Linker Error, that's usually an incorrect function signature. Double check the parameters you are passing to that function.
  20. You are not going to be able to turn these Drafting Entities into high-level “NET-Hook style” Geometry objects, as this API does not deal with those types. GeometryCaster will complain, as you’ve discovered. If you have the items that you wish to move to another level. This method does not care about the type of the entity. It just moves anything that is currently "selected" -> int GeometryManipulationManager.MoveSelectedGeometryToLevel (int destinationLevel, bool clearSelectBit); Since you are manipulating the placement of items on levels “behind Mastercam’s back”, you may want to make this call after you do this the move to level call. Mastercam.IO.LevelsManager.RefreshLevelsManager(); Mastercam's Level Manager display will ultimately update to reflect the changes, but by doing this you can tell it to do it now.
  21. You could isolate them in VBScript, but what could you do with them? The NET-Hook API does not "know" (as you've discovered) Drafting entities, as they are not "normal" Geometry entity items. What exactly are you wishing to do with these Drafting entities?
  22. Mastercam.Support.ExternalAppsManager.PostFTCommand (string) This allows for "firing" many Mastercam commands via a Command (string) just as if the user had selected them via the UI. email us -> SDK<at>mastercam<dot>com and I can get you "docs".
  23. Everyone would love to have this capability! Load a CAD drawing, push a button and out comes the NC toolpath program. Doing automatic toolpathing like this is very difficult to do, and then only when you are working with a limited "known set" of inputs. Look at Mastercam's ATP to see an example of what is involved. *It works for Mill/Router only, doing what is known as "flat panel" work. It sounds as if you came up with an idea for a project with no idea of what it would take to accomplish it. If you are not familiar with C++ coding, and do not have a lot of time to invest in this, the chances of being successful are probably not good.
  24. ??? Not sure what you mean here. ^^^ What version of Mastercam? That determines which version of Visual Studio that you must have. If you email us (SDK<at>mastercam<dot>com) with your customer info and details of what you are trying to do. An example of the desired "end result" is also very useful. We may be able to assist.
  25. The "MakeOperationFromName" function in VBScript which lets you import an operation and apply currently selected Chains or Points only works with Mill/Router type toolpaths. Creating (importing an operation and applying the geometry) for Lathe type toolpaths is only possible with a C-Hook style add-in.

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