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:

Recommended Posts

You can call the XForm_Project function within Mastercam,

works just like if the uer had selected the command.

 

Add a Class to your C# Project

[ C# <-> VB convert ]

 

using System;
using System.Runtime.InteropServices;

namespace MyProject
{
   // Declare the P/Invoke signatures
   class Interop
   {                
       // extern "C" __declspec(dllexport) int do_xform_project (int dummy)
       [DllImport("McCore.dll", EntryPoint = "do_xform_project", CharSet = CharSet.Auto)]
       public static extern int XformProject(int dummy);
   }
}

 

 

And make the call, like this ->

 

int rv = MyProject.Interop.XformProject(0);

Link to comment
Share on other sites
  • 1 year later...

Windows 7 32bit - Tested under Mcx7/VS2010 and Mcx6/VS2010

 

When running the above code in the IDE, it runs OK, but after completion, the IDE gives a PInvoke Error (see image)

 

Below is the complete (short) VB source:

 

Imports System.Runtime.InteropServices '
Imports System
Imports Mastercam.App
Imports Mastercam.App.Types
Namespace MyExample
Public Class NetHookAppExample
 Inherits NetHook2App
 Public Overrides Function Run(ByVal param As Integer) As MCamReturn
	 Dim rv As Integer = Interop.XformProject(0)
	 Return Mastercam.App.Types.MCamReturn.NoErrors
 End Function
End Class
' Declare the P/Invoke signature
Class Interop
 ' extern "C" __declspec(dllexport) int do_xform_project (int dummy)
 <DllImport("McCore.dll", EntryPoint:="do_xform_project", CharSet:=CharSet.Auto)> _
 Public Shared Function XformProject(ByVal dummy As Integer) As Integer
 End Function
End Class
End Namespace

 

Is there something else I should be doing ?

post-39678-0-50546600-1372359439_thumb.png

Link to comment
Share on other sites

Try adding the the CallingConvention shown below...

 

' Declare the P/Invoke signatures

Class Interop

' extern "C" __declspec(dllexport) int do_xform_project (int dummy)

<DllImport("McCore.dll", EntryPoint := "do_xform_project", CharSet := CharSet.Auto, CallingConvention := CallingConvention.Cdecl)> _

Public Shared Function XformProject(dummy As Integer) As Integer

End Function

End Class

Link to comment
Share on other sites
  • 4 years later...

Hi! I'm exploring the capabilities of Invoke to solve a task in my Nethook App.

I'd like to ask why do you know that "do_xform_project" is the EntryPoint for this function in the McCore.dll. Is there a way to explore the dll to get this?

Thank you in advance!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

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