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. SlaveCam, Do you happen to be located in the Atlanta area? Asking because I just received a similar query from that area via their MC Dealer.
  2. Going to need a bit more information in order to make a guess. Is your add-in a C-Hook or a NET-Hook? (You mention .NET and C-Hook, these are not the same.) > name after merging two Mastercam files together in my Chook When/where/how are you doing this “merging”? Are you merging .NCI files? Or .NC files? > I have tried renaming the NCI name but that doesn't change it. When/where/how are you doing this “renaming”? If your add-in is manipulating these files, I would think it should be able to be able to name the output to whatever you wish. It’s doing the “merging”, so how is it specifying the final destination of this merge?
  3. I think it is possible with a NET-Hook. The NET-Hook API does support the "get_event" functionality you see on the C-Hook SDK. See: https://nethookdocs.mastercam.com/content/html/ecb874d4-9d4e-f0de-31bf-9703b4e9a7ad.htm In order for us to investigate further, I'll need to create a support ticket, to do that, we'll need you to email us with your company contact info to: SDK[at]mastercam[dot].com
  4. Which version of Mastercam? With a C-Hook add-in, or a NET-Hook Add-in? If you create a C-Hook add-in using the CHookWizard that the SDK installs into Visual Studio. On the 2nd page, select the Modeless Dialog code option. That sample shows "tracking" the mouse position.
  5. With X5 (which is a sunsetted = no longer a supported version), what I can do here is very limited. A quick look at the code that is run when you click the OK button, shows issues... 1> No geometry is created for the rectangle because the corner points you calculate are both X0,Y,Z0. Dim ss As Double 'If mcUnit = mcUnit Then ss = 1 'Uncomment this line and the rectangle will now be created. '*As long as you've entered valid values for the (3) items on your Form!* 'Else ' ss = ss / 25.4 'End If Dim i, j, k As Integer ' ss = 0 here, so the resulting i,j,k values become 0 ! ' CreateRectangle fails to create anything because both corner pointsare 0,0,0 i = (Int(TX.Text) / 2) * ss : j = (Int(TY.Text) / 2) * ss : k = (Int(TZ.Text)) * ss Dim topRectangle = GeometryCreationManager.CreateRectangle(New Point3D(i, j, 0), New Point3D(-i, -j, 0)) 2> So after you've fixed this issue of no geometry. Now that you do have geometry to be chained, you're chaining "selected" geometry. But the problem is, you have no "selected" geometry! Dim chains = ChainManager.ChainAllSelected(True) 'Yyou need to set the geometry entities you're creating as "selected". With element .Color = 12 .Level = 2 .Selected = true ' Added so this entity is makred as "selected". .Commit() End With
  6. If you wish I can investigate further. To "get" the dimensions/notes would require a C-Hook add-in. A NET-Hook add-in could use the C-Hook as a "worker" to retrieve the data in the part file, then all of the processing of that data could be done in your NET-Hook. Send us (with your company contact information) a sample file to -> sdk[at]mastercam[dot]com Let me know what data you want to retrieve (the dimension "text"?) and I can see what could be done. Also, we need to know what version of Mastercam is this for!
  7. AnMastercam, We're past the point for doing API support for this via the forum. If you ZIP up your NET-Hook project and include your sample part file. Send this ZIP with your Company contact information to SDK<at>mastercam<dot>com, we can investigate further.
  8. As Mick stated, the NET-Hook API doesn't "know about" Notes/Dimensions. Exactly what are you wanting to do with the "dimensions"?
  9. Not quite sure what you are trying to do here. I assume that you want to set the active graphics view to Isometric? Mastercam.IO.ViewManager.GraphicsView = SearchManager.GetSystemView(SystemPlaneType.Iso) Mastercam.IO.GraphicsManager.FitScreen() 'optional
  10. If you (customer) has a log-in to mastercam.com you have access to -> SDK Downloads If you can supply details on what "expand their functionality of MasterCam" entails, we may be able to make suggestions on how that could be done.
  11. It depends on “what” geometries you want to pass to the RectangularBoundingBox method. Look at the “Get Geometry” methods in Mastercam.Support.SearchManager -> https://nethookdocs.mastercam.com/content/html/6128065d-1d7f-4616-4327-15bbf305dc94.htm
  12. This question is basic .NET which we really don't do. We're here to help you using Mastercam functionality in a Mastercam Add-In. I created a simple VB.NET Windows Form Application, then I inserted your MainView.Designer.vb code. The result worked for me. I get a somewhat large Form with (2) buttons. Click on the 'Open' button and the File Open Dialog opens. Click on the 'OK' button and the Form closes. If you are just setting up the user interface for a NET-Hook add-in and you are not really using any Mastercam “specific” functionality yet. You can save time by building your project as a std. “Window Form Application”. Then you don’t need to startup Mastercam, just to run your project to test your UI. Once you get your UI setup like you want, just switch the Application Type over to “Class Library”, and add a Reference to the NETHook3_0.DLL and have a class with the “Run” function in your project -> Imports Mastercam.App Imports Mastercam.App.Types Public Class NethookMain Inherits NetHook3App Public Overrides Function Run(ByVal param As Integer) As MCamReturn Using view = New MainView() view.ShowDialog() End Using Return MCamReturn.NoErrors End Function End Class Now you have a NET-Hook add-in (DLL) and can continue on to implementing the items that rely on Mastercam functionality. WindowsAppVB.zip
  13. I did some more looking at the situation with the ToolPreview (user-control) class. What makes it different, that the WinForms Designer cannot handle it properly? I noticed that it’s the only user-control class that directly references the NETHook3 API. The NETHook3_0.DLL is a 64-bit Assembly, and we know that WinForms Designer does not handle 64-bit well. If you remove any use (references) to the NETHook API in the user-controls, the MainForm of the project will now load in the WinForms Designer.
  14. When I attempt to load the main form into the Winformes Designer I get 2 errors. 1> Could not load file or assembly NETHook3_0 .... 2> The variable "ToolPreview1" is either undeclared or was never assigned. #1 - Doesn't make much sense, as I know that the NETHook3_0 reference in both projects is set correctly. #2 - Hmmm... I commented out all references to "ToolPreview1" in MainView.vb and MainView.Designer.vb files. And now the MainView.vb [Design] will load into the WinForms Designer. Even though this obviously doesn't fix everything, it at least leads us to where a problem appears to be.
  15. If you want to use Designer in Visual Studio you need to build with AnyCPU. The Designer is not "smart" enough to handle a 64-bit built assembly. (Visual Studio is a 32-bit Application!) The "Processor Mismatch" is just that - a warning. You can build AnyCPU during development and then switch over to 64-bit for your production build.
  16. Translating geometry, see below. As for "here is a part file, tell me how to do this..." You'll need to email us with our data and your company ID -> [email protected] Public Class MyHook : Inherits NetHook3App Public Overrides Function Run(ByVal param As Integer) As MCamReturn Dim result = TranslatePoint() Dim arc = TranslateArc() ViewManager.GraphicsView = SearchManager.GetSystemView(SystemPlaneType.Iso) GraphicsManager.FitScreen() Return MCamReturn.NoErrors End Function Private Function TranslatePoint() As Boolean Dim myPoint As New PointGeometry(1, 2, 0) Dim fromPoint As New Point3D(0, 0, 0) Dim toPoint As New Point3D(15, 25, 30) Dim fromView = ViewManager.CPlane Dim toView = SearchManager.GetSystemView(SystemPlaneType.Front) ' Translates (moves) the Geometry object Dim result = myPoint.Translate(fromPoint, toPoint, fromView, toView) Return result End Function Private Function TranslateArc() As ArcGeometry ' Create an arc at the origin in the current Construction Plane Dim myArc As New ArcGeometry(ViewManager.CPlane, New Point3D(0, 0, 0), 5, 0, 180) myArc.Commit() Dim fromPoint As New Point3D(0, 0, 0) Dim toPoint As New Point3D(15, 25, 30) Dim fromView = ViewManager.CPlane Dim toView = SearchManager.GetSystemView(SystemPlaneType.Front) ' A copy the original eobject (myArc), then translate it. ' The new translated object is returned Dim newArc = myArc.CopyAndTranslate(fromPoint, toPoint, fromView, toView) Return newArc End Function End Class
  17. Please post your code, not "pictures" of your code. Also, which version of Mastercam are you using? This creates a mirrored line with endpoints of -10,0,0 and -10,10,0 Public Overrides Function Run(ByVal param As Integer) As MCamReturn Dim result = MirrorLine() MessageBox.Show(String.Format("Line has been mirrored -> {0}", result)) Return MCamReturn.NoErrors End Function Private Function MirrorLine() As Boolean Dim originalLine = New LineGeometry(New Point3D(10, 0, 0), New Point3D(10, 10, 0)) Dim axisLine = New Line3D(New Point3D(0, 0, 0), New Point3D(0, 25, 0)) Dim view = ViewManager.CPlane Return originalLine.Mirror(axisLine, view) End Function
  18. If you are just wanting to replicate the DrillPoints from one operation into another. There is built in functionality to do this. Below is a somewhat contrived example. It copies all the points in the 1st operation into the 2nd operation, replacing the points in the target operation. “CopyDrillPointsFromOp” is a member function of a DrillBasedOperation (since it only works with “point” type operations), so we need to do the casting of the Operation(s) to the DrillBasedOperation type. bool result = false; var drillOPs = Mastercam.Support.SearchManager.GetOperations(OperationType.Drill); if (drillOPs.Length > 1) { bool replacePoints = true; result = ((DrillBasedOperation)drillOPs[1]).CopyDrillPointsFromOp((DrillBasedOperation)drillOPs[0], replacePoints); } if (result) { result = drillOPs[1].Regenerate(); }
  19. "Declaration expected" ? What is the exact pop-up message? The code below works for me. It creates the Spline and displays a message box -> "spline has 3 points" (Visual Studio 2015 or 2017 and .NET Framework 4 or higher.) Public Class MyHook : Inherits NetHook3App Public Overrides Function Run(ByVal param As Integer) As MCamReturn Dim spline = CreateSpline() MessageBox.Show(String.Format("spline has {0} points", spline.NodePoints.Length)) Return MCamReturn.NoErrors End Function Private Function CreateSpline As SplineGeometry Dim pt1 As New Point3D(10, 0, 0) Dim pt2 As New Point3D(10, 10, 10) Dim pt3 As New Point3D(25, 30, 35) Dim points() As Point3D = {pt1, pt2, pt3} ' The "New Spline" in the parameter here is not needed. ' You can do it this way, it's just an unnecessary additional construction. 'Dim spline As New SplineGeometry(New Spline(points)) ' You can pass the points directly to the SplineGeometry constructor. Dim spline As New SplineGeometry(points) Dim result = spline.Commit() Return spline End Function End Class
  20. That SplineGeometry constructor wants an array of Point3D objects. See the online NET-Hook API docs here -> https://nethookdocs.mastercam.com Dim pt1 As New Point3D(10, 0, 0) Dim pt2 As New Point3D(10, 10, 10) Dim pt3 As New Point3D(25, 30, 35) ' Need an Array of Point3D objects Dim points() As Point3D points = New Point3D() {pt1, pt2, pt3} Dim spline As New SplineGeometry(points) spline.Commit()
  21. Your NET-Hook works for me. It created the two points. Be sure the you are running the proper DLL (masternethook.dll) that this project created? In your “The breakpoint will not currently be hit” screen shot, Visual Studio is referring to -> OPERATIONSMANAGEREXMAPLE.DLL That’s not the name of the DLL that the “masternethook“ project you sent creates. I loaded your “masternethook“ project in Visual Studio. Start Debugging (F5) and Mastercam 2018 starts up. Selected the “Run Add-In” command and navigated to the bin\Debug folder of the “masternethook“ project and selected the just built masternethook.dll. The result is two points added to the Mastercam database and shown on-screen.
  22. On our website are sample NET-Hook projects: https://www.mastercam.com/en-us/Communities/3rd-Party-Developers/NET-Hook-Downloads You appear to be missing the main "Run" function that Mastercam calls when you run your Add-In. From within the "Run", you call your methods. Public Overrides Function Run(ByVal param As Integer) As MCamReturn Me.Point1() Return Mastercam.App.Types.MCamReturn.NoErrors End Function
  23. Karl, The source code for this C-Hook is not available. The offer is to supply a pre-built C-Hook DLL for either 2017 and/or 2018. As mentioned, a story has been entered into our system to add this to the NET-Hook API in the future -> We have created a Story for this -> S-53715 : API - NET-Hook - Add support for "Break Many Pieces"

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