Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: Scott on November 15, 2006, 01:27:15 PM

Title: Need help with new macro or wizard
Post by: Scott on November 15, 2006, 01:27:15 PM
I'm new to Mach and VB and having come from a situation that used plain basic, I have need for a macro or a wizard to replace one that I used with my old controller.

Basically what I need to do is this.  I make a lot of plaques in varying sizes that need to have hangslots cut with a keyhole bit for hanging the plaque on a wall.  Some of these plaques need to have a vertical and horizontal slot, some need only one slot, and some may need two vertical slots.  Most are centered one inch in from the edge and two inches long and some are one inch in from each edge and one inch or less long.  I would input the various information and how many need to be cut.  The tool needs to park clear of the fixture and wait until I get the next plaque locked in, then with the push of a momentary button on the gantry, it would do the next one and so on until the count is met.  At that time the tool will again go to the clear position and turn off the router.

A macro that can ask for all the info and then execute would be fine, but I'm not experienced enough to know the proper syntax for everything that would be needed.

A wizard may be nice, but that's beyond my limits at the moment  ;)  Any help would be appreciated!     
Title: Re: Need help with new macro or wizard
Post by: Brian Barker on November 17, 2006, 09:38:48 AM
Open up any of the wizards that I did in the past (other then the NFS set) and you can use the code in it for a base to start from :)

Hope that helps
Brian
Title: Re: Need help with new macro or wizard
Post by: Scott on November 17, 2006, 02:15:26 PM
Thanks Brian,

I didn't know that all of those had screen sets also.  I've got it figured out how to make the screen and have it show up in the list, but I'm going to need some help with parts of it if you don't mind.  ;)  I noticed that Screen4 won't show some of the objects in the layout.  Image buttons, images, and some leds aren't shown as they should be.

I'd like to make a graphic that I could choose one or more locations to be applied to the final code.  How do you make multiple selections?

I would also like to have the machine park at a specified distance away from the fixture and wait for me to push a momentary switch located on the gantry (you may recall talking about this at the Kansas camp).  The switch is currently set to limit/home A, port 1 pin 13.  How would I make it wait and monitor the condition of that switch and then step back into the loop once pressed?

Thanks
Title: Re: Need help with new macro or wizard
Post by: Brian Barker on November 17, 2006, 10:02:06 PM
Benny is the one that can help you with Screen4

And the best thing is to play with the wizards and if you see something that you think you would like to do... look at the code under the button :) That is the best way to learn...
Title: Re: Need help with new macro or wizard
Post by: Scott on November 28, 2006, 01:02:58 AM
Well, I've just about got my "Hanglsot" wizard finished.  I've got one script problem that I can't seem to get to work though.  If you look at the screen shot, you can see that I have six positional leds (two pairs and two singles).  I have all the different combinations working for "good" combinations and all but one for the bad combinations.  I can't get a "If Not - And Not - And Not - And Not - Then -  warning message" to work for when all leds are off.  It wants to always drop through.  All other "If Not" or "And" four ways work fine, but that one doesn't.  I guess it's not necessary, but I have all the other "bad combinations" working to throw up a warning so it would be nice to have the all off scenario work too.  Any ideas?

Thanks
Title: Re: Need help with new macro or wizard
Post by: Graham Waterworth on November 28, 2006, 05:39:38 AM
Give each LED a number then add them up and if number is zero show warning, you can check any combination of led's then.

E.G.

led1=1
led2=2
led3=4
led4=8
led5=16
led6=32

ledcount=0
if led1 is on ledcount=ledcount+led1
if led2 is on ledcount=ledcount+led2
etc.......

if ledcount=0 "warning"

case ledcount

when 3 "led 1 and 2 are on"
when 12 "led 3 and 4 are on"
.....
end case

Graham.
Title: Re: Need help with new macro or wizard
Post by: Scott on November 28, 2006, 01:43:16 PM
Thanks Graham!

That works great!  :)  Much better than a bunch of "If, If And, and If Not's".  I would've never come up with that solution on my own, but then again, I'm just learning all this VB script stuff.  Thanks for todays lesson.  ;)

If it would be of any use to anyone else, I'll post it here when completed.  No warranty expressed or implied!  :P 


I didn't see your "Case Select" addition there before I posted.  It works well without it, but that's another way to skin it.

Thanks
Title: Re: Need help with new macro or wizard
Post by: ART on December 01, 2006, 09:27:43 AM
Scott:

 Very Clever.. Very nice wizard, I love to see the cooperation shown on this. Its what its all about, my thx to all involved..

Art
Title: Re: Need help with new macro or wizard
Post by: Scott on December 02, 2006, 02:23:30 AM
 :o Wow, thanks Art!  Coming from the master coder, that's a treasured complement.  ;)

I've just about got it finished, but I've got so much other stuff to do that it'll have to wait just a bit more.  I've actually used it for about fifty plaques so far and it works great.

Now if I could just get my other problems worked out.....(as he slowly turns and heads off for the CV thread)..... :(
Title: Re: Need help with new macro or wizard
Post by: Scott on December 10, 2006, 03:30:58 PM
Once a wizard is finished, what's the accepted method for distribution?  Just a zip file here for anyone who wants to give it a try or something else?

Just wanted to know before I zip one up here.

Thanks,
Title: Re: Need help with new macro or wizard
Post by: Brian Barker on December 10, 2006, 06:02:52 PM
That is okay to put them here.. I think at some point I can set up a place on the FTP server
Title: Re: Need help with new macro or wizard
Post by: Scott on December 10, 2006, 11:08:54 PM
Hi all,

I finally had some time to finish my "Hangslot Wizard".  There is a readme file included.  If you think it may be of some use to you, check it out.

Thanks to Brian and Graham for helping me out with my first wizard.  It's relatively simple, but it was a good learning experience.

I'm not the best mathematician so if you find something that doesn't add up, let me know.  ;)

Regards, 
Title: Re: Need help with new macro or wizard
Post by: zarzul on December 12, 2006, 10:44:22 AM
Nice job on the wizard!

Keep up the good work,  need more wizards like this!!
Title: Re: Need help with new macro or wizard
Post by: Greolt on November 03, 2007, 09:08:43 PM
Scott

Believe it or not the little I know about this VB stuff as used in Mach I have learned from you.  So thanks for your efforts.

I had a poke around and converted it to metric.  Haven't used it yet.  Just a learning exercise.  ;D

Greg
Title: Re: Need help with new macro or wizard
Post by: Scott on November 04, 2007, 12:44:17 AM
 ;)  It was a learning exercise for me too.  Kind of fun though.  A good break from the day to day stuff.

I need to do it again.  With the control software I'm using now, I've set one up that is just dialog based and I'd like to make a "Virtual Tool" (wizard) that is has a GUI with drop down lists and fill in fields, but I haven't had the time to wade through Visual Basic to make one.

Scott