Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to automate two CAM nesting and cut applications by adding API funcionality and interact programmatically with them.

One of them (named as software A and programmed in VB.NET) expose methods and properties through COM interface, and I've made a windows form application consisting of an external and independent executable programmed in C# .NET that accomplish this task by interacting with software A. For example, it can make nesting of parts putting them in precise locations on sheet determined by the program. Of course software A and .NET exe
run in different processes and simultaneously and the last interact with the first, executing whatever instructions we implement in the executable and available in methods and props. of software A COM referenced DLL's.

The other CAM package however (named as software B), is programmed in C++ and does not expose methods and props through COM, making the goal more difficult.

I know that DLL's of software B export all functions and names and prototypes of these functions are all of them known. Software does not include API/SDK nor DLL load or plugin mechanism. That means AFAIK that the more appropiated method of interacting with software B would be by means of an external executable programmed in C#.NET or C++ that although run independently it would be able to import the classes ,objects and functions of software B DLL's in the same process and execute instructions programmatically to drive software B.

I have only a small knowledge on C++ and I don't really know if this is possible (perhaps someone knows page link on internet explaining details) Anyway it seems to me a matter of interest.

What I have tried:

I've made a windows form application consisting of an external and independent executable programmed in C# .NET that accomplish this task by interacting with software A. For example, it can make nesting of parts putting them in precise locations on sheet determined by the program
Posted
Updated 28-Nov-20 0:43am
v2
Comments
RickZeeland 25-Nov-20 15:02pm    
Have you tried adding the DLL's of software B to a C# solution?
Visual Studio normally does a good job of automatically generating interop dll's.
Member 3615972 25-Nov-20 15:19pm    
Yes, but it doesn't work
DLL that are not valid COM component can not be referenced in C# project
Dll in C# project can be imported with [DllImport(.....dll)]
and declaring functions static extern void function1(argument1,argument2,...) they can be used
but doesn't interact with software package because it must be running in the same process.
RickZeeland 25-Nov-20 15:40pm    
You are right, it will only work for COM dll's, the only thing that springs to mind now is to use a disassembler or hacking tool, but that's probably not what you want.
Member 3615972 25-Nov-20 16:44pm    
May be a pointer or handle to the running instance of the main host application of software B can be obtained Using C/C++ WINDOWS api functions like LoadLibrary,LoadLibraryEx or GetProcAddress
I will investigate further

 
Share this answer
 
I've finally giving up with C++ option.
Below is parcial example on how I've made automatic nesting by pressing a button in a form of a C#.NET executable. Thus a CAM application with COM DLLs can be automated through an external executable.I think that applications that doesn't have COM DLLS or API/SDK implemented is a terrible nightmare or imposible task to automate them this way.

private void tb_NestParts_Click(object sender, EventArgs e)
{
try
{

CAM_Nest.Application NestingApp = new CAM_Nest.Application(); //CAM_DI.IApplication;

CAM_Nest.Document NestingDoc = (CAM_Nest.Document)NestingApp.ActiveDocument; //CAM_NI.IOrder


CAM_NI.INesting CurrNest = NestingDoc.CurrentNesting;
CAM_NI.Part NestingPart = (CAM_NI.Part)NestingDoc.Parts[lbPartsToNest.SelectedIndex];
CAM_DI.point BondBoxMin = NestingPart.BoundingBoxMin;
CAM_DI.point BondBoxMid = NestingPart.BoundingBoxMiddle;
CAM_DI.point BondBoxMax = NestingPart.BoundingBoxMax;
string FileName = NestingPart.FileName;
int FreeCount = NestingPart.FreeCount;
double PartWidth = NestingPart.Width;
double Nr1 = 0, Nr2 = 0;
cbox_PackPrefer.Update();

//Number of torches in Col1 upper rows

for (int i = 1; i <= NumberOfColumns; i++)
{
NestingDoc.CurrentFlameNumber = NumberOfTorches_Col1_1;
CurrNest.NestPart(NestingPart, BorderGap + (i - 1) * ColumnDistance, PlateWidth - BorderGap - (NumberOfTorches_Col1_1 - 1) * TorchDistance - PartWidth);
if (NumberOfTorches_Col1_2 > 0)
{
NestingDoc.CurrentFlameNumber = NumberOfTorches_Col1_2;
//for (int i = 1; i <= NumberOfColumns; i++)
//{
CurrNest.NestPart(NestingPart, BorderGap + (i - 1) * ColumnDistance, PlateWidth - BorderGap - (NumberOfTorches_Col1 - 1) * TorchDistance - PartWidth);
if ((2 * BorderGap + (i - 1) * ColumnDistance + PartWidth / 2) > PlateLength)
{
NumberOfColumns = i;
break;

}
//}
}


NestingDoc.UpdateGraphic();
//NestingDoc.CloseNesting();
//NestingDoc.FileSave
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "EXCEPTION", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);

}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900