Tool height Setting Macro

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

Re: Tool height Setting Macro

Postby ThreeDJ16 » Sat Sep 07, 2019 5:40 pm

ger21 wrote:I use Message Boxes to display values when things aren't working right. I do the same thing when writing plugins or programming in Visual Studio.
Haven't had a chance to look at your macro, been very busy lately.

This what I've been thinking about doing. And much appreciate it Gerri. I think with the amount of people using fixed tool heights, your next release of screenset would be awesome if it had a macro like this.
ThreeDJ16
 
Posts: 164
Joined: Tue Oct 31, 2017 5:57 pm

Re: Tool height Setting Macro

Postby ThreeDJ16 » Sat Sep 07, 2019 5:54 pm

GaryLa wrote:Per the documentation from MS, I don't understand why you're using Dispose in this manner: topform.Dispose();

"Disposes of the resources (other than memory) used by the Form." The MessageBox takes care of itself, why call Dispose for your "topform" after some MessageBox calls (but not all of them)?

Also, without placing some of this code after an "#Events" statement, my understanding is your "loop" variable will always be 1. Setting it to 0 and then returning will have no effect -- it gets reloaded again to 1.

Code: Select all
int loop = 1;

while(loop > 0) ....
loop = 0;  //unless this is global, this statement has no actual effect
return;


I only copied this example of message box code from this forum and macros created in Screenset 2017 for the message box.

Also, as stated earlier, I know the loop is screwed up. Agreed that loop=0 followed be a return serves no purpose, but somehow my loop got stuck twice and just did that in case I has missed something else. Haven't had a stuck loop since doing it, and don't know why is happened in the first place. So just left them in until I had a better method of doing the loop. But yeah, basically was just stating loop while AnyVariable is true, which I've seen used before. It's just a way to keep it looping until a step out path leads it to a return.

LOL...never claimed to be a programmer, but trying to learn C#. My first experience in programming was with a Vic20 in 1980. In Tech school, they were only teaching basic, pascal, fortran and some other ancient languages, not C at the time. So programming over the years has just been out of necessity whenever required. Haven't had any formal training on it and just trying to get some experience with C# since it's now a necessity for me. I admitted from the beginning this macro was simply a hacked up version of other people's code, but also hitting up some videos and C# wiki trying to learn how to do it correctly.

Your feedback is appreciated and I will try to get a better understanding of the windows form thing to see how I should properly format it. I know it's not working correctly as some windows are still hiding behind others on occasion and it will allow you to restart the macro with an instance running. So yeah, a lot of work to be done from an error handling standpoint and making the while loop correct as far as layout and context.

Thanks to everyone for feedback and information. Don't give up on me yet, I'll get there one day...LOL.
ThreeDJ16
 
Posts: 164
Joined: Tue Oct 31, 2017 5:57 pm

Re: Tool height Setting Macro

Postby ThreeDJ16 » Sat Sep 07, 2019 7:48 pm

Quick question. Everything I've read states UCCNC macros use C#, but does that mean it can use all C# functions? Maybe I'm using the wrong terminology here, but like "link" commands too? Most of the videos I am watching show functions such as " if (var?.tolower().firstordefault()=='y'); " and I was just wondering if everything is available or is it just something like base C# without advanced functions. I've read through the UCCNC Macro PDF and it doesn't show these functions, but then again, I'm seeing functions currently in some macros that aren't in this PDF. So overall my question is where are the limitations of C# functions with respect to UCCNC? As I'm trying to establish a baseline of what I need to learn. Why learn these advanced functions if they are of no use currently in UCCNC. My brain is already overloaded enough trying to comprehend all the different functions I can use along with the syntax involved with this language, don't want my head to explode attempting to go beyond the capacity of UCCNC functionality (which is already likely...LOL).
ThreeDJ16
 
Posts: 164
Joined: Tue Oct 31, 2017 5:57 pm

Re: Tool height Setting Macro

Postby cncdrive » Sat Sep 07, 2019 9:38 pm

Yes, Windows Vista was a total crap, I call it an "unfinished" Windows, because it was basically never finished, but they pushed out Windows 7 and offered the free upgrade instead of finishing Vista.
Windows 8 also remained half-backed, but they later released Windows 8.1 which was about OK.
Later Windows 10 replaced Windows 8 with again the free upgrade.

I think that Windows 7 is still the most reliable of all.
XP is also same reliable as 7, but XP has no more Microsoft support, so it is dying out.

I don't know how many people are still using XP, but there is sure a number of them, because when we discussed moving to the Rosyln compiler from Codedom and that then XP will be no more supported then we got complaints, so we finally did not do it.
cncdrive
Site Admin
 
Posts: 3499
Joined: Tue Aug 12, 2014 11:17 pm

Re: Tool height Setting Macro

Postby cncdrive » Sat Sep 07, 2019 9:43 pm

All the -NET compiler is available in the macros, but not all libraries are linked, only the important ones.
I mean there are so many libraries in .NET that if we link all in then it would probably cause memory usage issues on computers with low RAM memory.

The following libraries are linked into the macros:

using System;
using System.Windows.Forms;
using System.Drawing;
using System.Threading;
using System.Collections.Generic;
cncdrive
Site Admin
 
Posts: 3499
Joined: Tue Aug 12, 2014 11:17 pm

Re: Tool height Setting Macro

Postby cncdrive » Sat Sep 07, 2019 9:45 pm

And by the way you can use Visual Basic not only C#.
If you define the #VB directive in the first row of the macro code then the macro compiler will use the Visual Basic compiler on the macro code instead of C#.
So, it is up to you which programming language you will learn and use.
cncdrive
Site Admin
 
Posts: 3499
Joined: Tue Aug 12, 2014 11:17 pm

Re: Tool height Setting Macro

Postby ThreeDJ16 » Sun Sep 08, 2019 1:08 am

cncdrive wrote:Windows 7 is still the most reliable of all.
XP is also same reliable as 7, but XP has no more Microsoft support, so it is dying out.


I would mostly agree with you, but now all my computers are running Win10 and I have zero issues. In the beginning, there were a lot of driver conflicts, but now everything is very stable. LOL..I still run Classic Shell though, as I prefer the old style start menu and layouts.
ThreeDJ16
 
Posts: 164
Joined: Tue Oct 31, 2017 5:57 pm

Re: Tool height Setting Macro

Postby ThreeDJ16 » Sun Sep 08, 2019 1:09 am

cncdrive wrote:All the -NET compiler is available in the macros, but not all libraries are linked, only the important ones.
I mean there are so many libraries in .NET that if we link all in then it would probably cause memory usage issues on computers with low RAM memory.

The following libraries are linked into the macros:

using System;
using System.Windows.Forms;
using System.Drawing;
using System.Threading;
using System.Collections.Generic;


Thank you. That gives me an area to concentrate on instead of such a vast library set of functions. Just have to figure out how to narrow down my tutorial information to just these areas.
ThreeDJ16
 
Posts: 164
Joined: Tue Oct 31, 2017 5:57 pm

Re: Tool height Setting Macro

Postby ThreeDJ16 » Sun Sep 08, 2019 1:15 am

cncdrive wrote:And by the way you can use Visual Basic not only C#.
If you define the #VB directive in the first row of the macro code then the macro compiler will use the Visual Basic compiler on the macro code instead of C#.
So, it is up to you which programming language you will learn and use.


I saw this mentioned in the UCCNC Macro pdf and might consider this as I do have some experience in VB. Just not sure since all the macros I'm trying to learn from, mainly Gerri and I think it was Terry who made the tool height thing, are all in C#. So might be shooting myself in the foot starting from scratch in VB versus just modding existing. Guess we will see.

LOL...didn't get much time in today for learning C# as I did something much easier, changing out brakes, rotors and wheel bearings on my truck in 95 degree heat. But at least that is more straightforward than trying to teach an old dog new tricks. Youth is truly wasted on the young, I could have soaked up this stuff like a sponge 30 years ago....LOL. Now I'm having trouble trying to hammer it in my head and then remembering what I did from day to day. :roll:
ThreeDJ16
 
Posts: 164
Joined: Tue Oct 31, 2017 5:57 pm

Re: Tool height Setting Macro

Postby ger21 » Sun Sep 08, 2019 11:55 am

It's VB.NET, so the functions are the same, but the syntax is different.
If you've programmed in VB, but not VB.NET, you may struggle with the syntax.

Here are two examples that do the same thing.
VB
Code: Select all
#VB
MessageBox.Show("VB")
dim xval as double

xval = AS3.Getfield(226)

MessageBox.Show(xval)

If xval =0 then
MessageBox.Show ( "X axis is already at zero.")
Else
AS3.SetField(0, 226)
AS3.Validatefield(226)
MessageBox.Show ( "X axis reset to zero.")
End If




C#
Code: Select all
MessageBox.Show("C#");
double xval;

xval = AS3.Getfielddouble(226);

MessageBox.Show(Convert.ToString(xval));

if (xval == 0)
{
MessageBox.Show("X axis is already at zero.");
}
else
{
AS3.Setfield(0, 226);
AS3.Validatefield(226);
MessageBox.Show("X axis reset to zero.");
}
Gerry
UCCNC 2017 Screenset - http://www.thecncwoodworker.com/2017.html
ger21
 
Posts: 1873
Joined: Sat Sep 03, 2016 2:17 am

PreviousNext

Return to Macros

Who is online

Users browsing this forum: No registered users and 1 guest