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:

Active report output a pop up message


Recommended Posts

Hello forum,
   I am thinking of making the ACTIVE REPORT pop up a message as if I wanted to.  Is that doable and what is the hard codes of which where I can start?

 

Like... If TOOL OVER ALL LENGTH < DEPTH then
             txtPopUpMessageA.visible  = true
           End if


ps: I am using VIRTUAL BASIC language (VB.net) to write the statement.

Thank you for the help.

Link to comment
Share on other sites
26 minutes ago, peter ~ said:

Its a reference to System.Windows.Forms are you able to add a reference to that assembly with your script compiler?

then add   using System.Windows.Forms at the top

This is what I have, I just want to make sure that I understand your instructions.

 

Thank you.

CODES.PNG.227eaaa4229f67104338049d9d9671dd.PNG

Link to comment
Share on other sites
30 minutes ago, PcRobotic said:

This is what I have, I just want to make sure that I understand your instructions.

 

Thank you.

CODES.PNG.227eaaa4229f67104338049d9d9671dd.PNG

Okay I will investigate further I am not very familiar with active reports, It is possible the Scripting language in use  doesn't observe the same "rules" as vb.net for applications. I will get back to you when I know more.

Link to comment
Share on other sites
1 hour ago, PcRobotic said:

 

Thank you for pointing it out but I think I still having issue with the "define".  Do you have any recommendations?

CODES.PNG.3bfc20b595bf30dcb15458d2b9d3ce0a.PNG

Hi pcrobotic,

You need to add the reference to winforms in order to use the function MessageBox:

I don't normally use VB but I double checked the code you need to add above your function in order for it to work is

Imports System.Windows.Forms
'//then
Sub ActiveReport_ReportStart
MessageBox.Show("Message")
End Sub

I tested it the assembly for winforms is there so this will work, let me know if you have any more issues.

Link to comment
Share on other sites
23 hours ago, peter ~ said:

Hi pcrobotic,

You need to add the reference to winforms in order to use the function MessageBox:

I don't normally use VB but I double checked the code you need to add above your function in order for it to work is


Imports System.Windows.Forms
'//then
Sub ActiveReport_ReportStart
MessageBox.Show("Message")
End Sub

I tested it the assembly for winforms is there so this will work, let me know if you have any more issues.

Hello Peter,
   I got it, very nice.  I have another question.  Can I write a statement in this MESSAGE BOX? 

 

Like... 

 

if OVER ALL LENGTH < DEPTH (Z-DEPTH) then show message "STICK OUT LONGER"  

show value of Z-DEPTH in the message as well
show value of OVER ALL LENGTH in the message as well

Is that possible?  Like the one in the image of which I just made it up by hand

 

Untitled.png.e36d9944ef99565897c5deb57ab93a65.png

Link to comment
Share on other sites
3 hours ago, PcRobotic said:

Hello Peter,
   I got it, very nice.  I have another question.  Can I write a statement in this MESSAGE BOX? 

 

Like... 

 

if OVER ALL LENGTH < DEPTH (Z-DEPTH) then show message "STICK OUT LONGER"  

show value of Z-DEPTH in the message as well
show value of OVER ALL LENGTH in the message as well

Is that possible?  Like the one in the image of which I just made it up by hand

 

Untitled.png.e36d9944ef99565897c5deb57ab93a65.png

Yes it is possible, we would need the variable names for your overall length and z-depth. Then write your function something like the following example :

  Dim overall_length As Double
        overall_length = -0.5
        Dim zdepth As Double
        zdepth = -1.0
        If zdepth < overall_length Then
            MessageBox.Show("Tool Overall Length : " & overall_length & "  Z-Depth : " & zdepth)
        End If

 

Link to comment
Share on other sites
On 11/7/2019 at 10:06 AM, peter ~ said:

for vb.net use the messagebox function. example :


MessageBox.Show("message")

 

 

Hello Peter,
   I partially succeed output a message box.  However, I would like it to make multiple text line in one message box with some conditions.  Would you please tell me what I've done wrong?  

 

 

Thank you for your valuable help,
   S.Luong

=====================================
This is my hard codes but not succeeded.
1945613889_HardCodes.PNG.292bd4ad6b8371816ec53a0602c7b9ce.PNG

 

Cut Numbers.....

915860209_CUTNUMBER.PNG.12f6b8b3b5f2dd38ebcf2ab17b9bb538.PNG



This is what I want...

COMBINED.thumb.png.4a4d2152ba8d2f083ea386fa08c06e5b.png

Link to comment
Share on other sites

Well by sending multiple messagebox.show commands you are telling the API to output 3 Message boxes. What you are looking for is the newline command for vb.

Dim x As String = "first line" & Environment.NewLine & "second line"

MessageBox.show(x)

Link to comment
Share on other sites

If your textDEPTH.text value is a string you will need to convert it to a double type variable before using in an equation. I will post an example of that when I get back to my computer(im on my phone rn).

Link to comment
Share on other sites

I tested out the following code which will give you the ability to convert string values(text) to double values(decimal numbers) : 

Imports System.Windows.Forms


Private Shared Function ConvertDoubletoString(ByVal text As String) As Double
	Dim number = 0.0

	Try
		number = Convert.ToDouble(text, System.Globalization.CultureInfo.InvariantCulture)
	Catch __unusedFormatException1__ As FormatException
		MessageBox.Show("could not convert " & text & " to double")
		Return 0
	End Try

	Return number
End Function

Sub ActiveReport_ReportStart
	Dim textboxvalue = ".4"
	Dim decimalvalue As Double = 0.0

	If textboxvalue IsNot Nothing AndAlso textboxvalue <> "" Then
		decimalvalue = ConvertDoubletoString(textboxvalue)
		MessageBox.Show(decimalvalue.ToString() & Environment.NewLine & "second line")
	End If
End Sub

 

Link to comment
Share on other sites
  • 3 weeks later...
On 11/15/2019 at 1:54 PM, peter ~ said:

I tested out the following code which will give you the ability to convert string values(text) to double values(decimal numbers) : 


Imports System.Windows.Forms


Private Shared Function ConvertDoubletoString(ByVal text As String) As Double
	Dim number = 0.0

	Try
		number = Convert.ToDouble(text, System.Globalization.CultureInfo.InvariantCulture)
	Catch __unusedFormatException1__ As FormatException
		MessageBox.Show("could not convert " & text & " to double")
		Return 0
	End Try

	Return number
End Function

Sub ActiveReport_ReportStart
	Dim textboxvalue = ".4"
	Dim decimalvalue As Double = 0.0

	If textboxvalue IsNot Nothing AndAlso textboxvalue <> "" Then
		decimalvalue = ConvertDoubletoString(textboxvalue)
		MessageBox.Show(decimalvalue.ToString() & Environment.NewLine & "second line")
	End If
End Sub

 

 

Hello Peter,
   I have tried and I got many errors, it's my fault not yours.  I am attaching the file of which I am struggling with, would you please add couple lines to make it work and I can follow you?  

 

 

Thank you for your help,
   S.Luong

-ToolDetailedHorizontal.rpx

Link to comment
Share on other sites
1 hour ago, PcRobotic said:

 

Hello Peter,
   I have tried and I got many errors, it's my fault not yours.  I am attaching the file of which I am struggling with, would you please add couple lines to make it work and I can follow you?  

 

 

Thank you for your help,
   S.Luong

-ToolDetailedHorizontal.rpx

No problem, I will take a look.

Link to comment
Share on other sites

Not to throw a wrench in the works, but I am wondering in your examples are you taking neck down tools into consideration for the process? The example shows a tool cutting 2 in deep, but only have 1 in of flute length. What about a neck down tool where you may have 3.5 of reach, but only .625 length of cut. Are you having the process no only look at the length of cut, but also the amount of cut and the reach of the tool? What about a Lollipop, Keyseat cutter, Slitting saw or other tools that have reduced necks?

Many different aspect to approaching error checking. When I was part of software development conversation when I was a Product manager at a software company we extrapolated a algorithm to give us the possible errors someone could make and what effort it would take to log all of those possible errors with their own unique output. We came up with well over 100K errors with just one module of the software. We figured it would take roughly 400k of hours to create all the different needed error messages. Seeing how there is roughly 2000 hours in a year they would need to hire 200 additional coders to cover all possible errors someone could make in one module of the software. There are 5 modules and if you went on the low side and said only 1k errors then you would still need a lot of people to just create all the logic and outputs needed to cover possible errors. When you think you have covered all of those then guess what someone will find a different way to do something else that they consider an error want that addressed. Personal Preference is the biggest issues facing any software developer and the hardest to get correct.  The process of creating error checking is a never ending process. By not creating a process to check error, but by teaching the correct and proper way to go about something you lessen the need for creating error checking. Lay out our tools in the same way, Setup holders, define your levels, and many other things that many find time consuming they feel taking away from programming are not once you develop the correct habits and methods. By getting the proper training or creating a set method and process you get less errors.

This is  what Deming was teaching in his method. What Kaizen teaches, 6S all of it revolves around standardization of the process to reduce the errors. That is the point I have been trying to make all along here. I applaud what your trying to do, but when someone understands the correct way to do something they tend to do it that way. When someone keeps leaning on a crutch to catch their mistakes they get lazy and don't learn or progress. I am always learning and make my share of mistakes daily, but I learn what not to do and thus I don't keep making the same mistakes. Make a journal or a log sheet of mistakes and go back from time to time and read them. See what were your 10 most common mistakes in a week or a month. Then focus on methods and habits to not make them. As you discipline and teach yourself to not make those mistakes you put the thought process into your brain to problem solve not only in methodical process, but also in a abstract one as well. We are all different in how we learn and what we learn, but everyone is capable of learning anything if they put their mind to it.

Your a smart person and have great ideas and I will share this thought that hopefully comes across the correct way. Feed a man a fish and feed him for a day. Teach the man to fish and feed him for life. Your error checks are just feeding the fish. The teaching of the method and process is what you teach them and yourself how to be the fisherman. People forget when they hear that saying that even the best fisherman doesn't catch fish everyday, but he was smart enough to store up his good catches for the days he didn't catch a fish either. 

Hopefully between you and Peter you come up with a real time saving method and process. Have a good day and look forward to what your next method is to make things better. 

  • Like 1
Link to comment
Share on other sites
1 hour ago, 5th Axis CGI said:

Not to throw a wrench in the works, but I am wondering in your examples are you taking neck down tools into consideration for the process? The example shows a tool cutting 2 in deep, but only have 1 in of flute length. What about a neck down tool where you may have 3.5 of reach, but only .625 length of cut. Are you having the process no only look at the length of cut, but also the amount of cut and the reach of the tool? What about a Lollipop, Keyseat cutter, Slitting saw or other tools that have reduced necks?

Many different aspect to approaching error checking. When I was part of software development conversation when I was a Product manager at a software company we extrapolated a algorithm to give us the possible errors someone could make and what effort it would take to log all of those possible errors with their own unique output. We came up with well over 100K errors with just one module of the software. We figured it would take roughly 400k of hours to create all the different needed error messages. Seeing how there is roughly 2000 hours in a year they would need to hire 200 additional coders to cover all possible errors someone could make in one module of the software. There are 5 modules and if you went on the low side and said only 1k errors then you would still need a lot of people to just create all the logic and outputs needed to cover possible errors. When you think you have covered all of those then guess what someone will find a different way to do something else that they consider an error want that addressed. Personal Preference is the biggest issues facing any software developer and the hardest to get correct.  The process of creating error checking is a never ending process. By not creating a process to check error, but by teaching the correct and proper way to go about something you lessen the need for creating error checking. Lay out our tools in the same way, Setup holders, define your levels, and many other things that many find time consuming they feel taking away from programming are not once you develop the correct habits and methods. By getting the proper training or creating a set method and process you get less errors.

This is  what Deming was teaching in his method. What Kaizen teaches, 6S all of it revolves around standardization of the process to reduce the errors. That is the point I have been trying to make all along here. I applaud what your trying to do, but when someone understands the correct way to do something they tend to do it that way. When someone keeps leaning on a crutch to catch their mistakes they get lazy and don't learn or progress. I am always learning and make my share of mistakes daily, but I learn what not to do and thus I don't keep making the same mistakes. Make a journal or a log sheet of mistakes and go back from time to time and read them. See what were your 10 most common mistakes in a week or a month. Then focus on methods and habits to not make them. As you discipline and teach yourself to not make those mistakes you put the thought process into your brain to problem solve not only in methodical process, but also in a abstract one as well. We are all different in how we learn and what we learn, but everyone is capable of learning anything if they put their mind to it.

Your a smart person and have great ideas and I will share this thought that hopefully comes across the correct way. Feed a man a fish and feed him for a day. Teach the man to fish and feed him for life. Your error checks are just feeding the fish. The teaching of the method and process is what you teach them and yourself how to be the fisherman. People forget when they hear that saying that even the best fisherman doesn't catch fish everyday, but he was smart enough to store up his good catches for the days he didn't catch a fish either. 

Hopefully between you and Peter you come up with a real time saving method and process. Have a good day and look forward to what your next method is to make things better. 

Hello 5th Axis,
   I know that most of the times I have silly ideas.  I think I successfully do a OVERALL length tool check with the FINAL Z-depth.  I did write statesment in the post like this:

 

if TOTAL TOOL Z-DEPTH > OVERALL TOOL LENGTH), show error message.

 

ps: TOTAL TOOL Z-DEPTH is being calculated by the BUFFER, it will look for the deepest depth.

 

I am not sure how to imply it into the ACTIVE REPORT.  If you know, that would be a great Christmas gift from you.

 

 

Thank you for your comment,
   S.Luong

Link to comment
Share on other sites
On 12/5/2019 at 2:19 PM, PcRobotic said:

Hello 5th Axis,
   I know that most of the times I have silly ideas.  I think I successfully do a OVERALL length tool check with the FINAL Z-depth.  I did write statesment in the post like this:

 

if TOTAL TOOL Z-DEPTH > OVERALL TOOL LENGTH), show error message.

 

ps: TOTAL TOOL Z-DEPTH is being calculated by the BUFFER, it will look for the deepest depth.

 

I am not sure how to imply it into the ACTIVE REPORT.  If you know, that would be a great Christmas gift from you.

 

 

Thank you for your comment,
   S.Luong

This  c++ example for mastercam 2018 successfully handles operations with "common parameters" (CONTOUR,DRILLING,2D DYNAMIC MILL,AREA MILL,POCKET) 

#pragma once
//api_tools_exp.h
#include "Header.h"
//functions 1:
  ///mastercam stuff :D
void Get_Tool_From_Op(tp_tool &tl, operation &op)
{
	op_group * machine = OMgetActiveMachineGroup();
	tl_list *nu_t_tlist, *cur_t_tlist;
	DB_LIST_ENT_PTR t_ptr, o_ptr;
	bool t_succf, o_init_ret;
	nu_t_tlist;
	char szLibName[255] = "";
	void * list_ptr = NULL;
	list_manager(TL_ID, szLibName, LSTMGR_GET, &list_ptr);
	nu_t_tlist = (tl_list*)list_ptr;
	if (nu_t_tlist != NULL)
	{
		cur_t_tlist = nu_t_tlist;
		while (cur_t_tlist != NULL)
		{
			if (op.tl.slot == cur_t_tlist->tl.op.slot)
			{
				tl = cur_t_tlist->tl;
				break;
			}
			cur_t_tlist = cur_t_tlist->next_ptr;
		}
		operation_manager(&op, OPMGR_REWRITE, &o_ptr, &o_init_ret);//rewrite operation

	}
}
//class to export:
class ExportFunctions
{
public:
	int LoopThroughOperations(double a, double b, int c, int d)
	{
		op_group * machine = OMgetActiveMachineGroup();
		op_list *nu_o_oplist, *cur_o_oplist;
		DB_LIST_ENT_PTR t_ptr, o_ptr;
		bool t_succf = true, o_init_ret;
		char szLibName[255] = "";
		void * list_ptr = NULL;
		list_manager(OP_ID, szLibName, LSTMGR_GET, &list_ptr);
		nu_o_oplist = (op_list*)list_ptr;
		if (nu_o_oplist != NULL)
		{
			cur_o_oplist = nu_o_oplist;
			while (cur_o_oplist != NULL)
			{
				tp_tool tl;
				DB_LIST_ENT_PTR* tlptr;
				Get_Tool_From_Op(tl, cur_o_oplist->op);
				char message[2000];

				sprintf_s(message, " # : %lf : %lf", cur_o_oplist->op.cmn.depth, tl.oa_length);

				MessageBox(NULL, t_succf ? message : "Operation Failed", "SharkBait", MB_OK);
				if (cur_o_oplist->op.cmn.depth < 0.0 - tl.oa_length) {MessageBox(0, "Error Z-Depth Is Greater Than Overall Tool Length", "ERROR",MB_OK); }
				if (tl.oa_length + cur_o_oplist->op.cmn.depth > .5) { MessageBox(0, "Error Overall Tool Length Is Greater Than 0.5", "ERROR", MB_OK); }
			if (cur_o_oplist->op.db.select_flag == FALSE)

			{

				bool succf = FALSE;

				DB_LIST_ENT_PTR eptr;



				cur_o_oplist->op.db.select_flag = TRUE;

				operation_manager(&cur_o_oplist->op, OPMGR_REWRITE, &eptr, &succf);

			}



			/* next operation */

			cur_o_oplist = cur_o_oplist->next_ptr;
		}
	}
		return 1;
	}
};

 

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