Scripting


Page 1 of 2 12 LastLast
Results 1 to 20 of 30

Thread: Scripting

  1. #1
    Registered Klox's Avatar
    Join Date
    Mar 2003
    Location
    NZ
    Posts
    507
    Downloads
    0
    Uploads
    0

    Question Scripting

    Hu,
    I have grasp the idea of scripting....eventually (i feel like an idiot confessing this). As i understand scripting is done in Basic. From the posts i've read you wrote about (mostly at the BobCAD support forum) scripting i know you must be a Pro.

    Could you give me pointers on books about Basic?

    Thanx
    Klox



    Similar Threads:
    *** KloX ***
    I'm lazy, I'm only "sparking" when the EDM is running....


  2. #2
    Member HuFlungDung's Avatar
    Join Date
    Mar 2003
    Location
    Canada
    Posts
    4826
    Downloads
    0
    Uploads
    0

    Default

    (chuckling at the funny little image in your post)

    Klox, I'd hate to give you references that wouldn't help you much because Bobcad's scripting language is ......homemade
    I guess the general rules of logic apply, but when unknown traps are lurking under the surface of what should be straight-forward, it can be frustrating.

    I've picked up so many bits of info from all over, that I really couldn't point to any book and say: "This is what I used". Studying scripts that other people wrote (ie., scripts that came with Bobcad, plus other cool people that took the time to help me out, like James Bond0h) is where I learned to do it.

    The basic principles of what they call Boolean logic, I think, is sort of the starting point: how to work with IF THEN statements, how to make loops, use AND and OR, and ELSE and ELSEIF. Then you have the different types of variables, and how to set them up and call them, how to use a debug tool to test your logic.

    I poured over the vb scripting manual that came with Bobcad a lot, trying to understand the rules of syntax (the exact way of writing a command). A bit of study conducted on the internet on unknown terms revealed a lot of material to help clue me on on what I wasn't familiar with.

    But, by far, learning by studying other scripts is by far the best tool to learn with. I usually pursued specific ideas that I wanted to encapsulate in a script, and in doing that, went down lots of dead ends of course, but even those teach you something. What do they say: "If you've made a lot of mistakes in a given field, you gain experience, but if you make all the mistakes, then you are an expert" I'm getting close

    Last edited by HuFlungDung; 05-17-2003 at 12:32 AM.
    First you get good, then you get fast. Then grouchiness sets in.

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


  3. #3
    Registered hardmill's Avatar
    Join Date
    Mar 2003
    Location
    United States
    Posts
    499
    Downloads
    0
    Uploads
    0

    Default

    Originally posted by HuFlungDung
    (chuckling at the funny little image in your post)


    But, by far, learning by studying other scripts is by far the best tool to learn with. I usually pursed specific ideas that I wanted to encapsulate in a script, and in doing that, went down lots of dead ends of course, but even those teach you something. What do they say: "If you've made a lot of mistakes in a given field, you gain experience, but if you make all the mistakes, then you are an expert" I'm getting close
    Well said Hu !!



  4. #4
    Registered Klox's Avatar
    Join Date
    Mar 2003
    Location
    NZ
    Posts
    507
    Downloads
    0
    Uploads
    0

    Default

    Thanx for your quick replies. The one thing life taught me is that humor takes the bumpiness out of every road we might take.
    I try doing some scripts on my own, i'll either swim or drown!!!

    Enjoy your weekend!

    Klox

    *** KloX ***
    I'm lazy, I'm only "sparking" when the EDM is running....


  5. #5
    Registered sorincnc's Avatar
    Join Date
    Mar 2003
    Location
    U.S.A.
    Posts
    107
    Downloads
    0
    Uploads
    0

    Default

    Originally posted by Klox
    .I try doing some scripts on my own, i'll either swim or drown!!!

    Enjoy your weekend!

    Klox
    Klox,
    What do you have to loose???? Remember, nothing is lost as long you learn something. What I tell all the guys thatt I train is to print as much scripts as possible and the take them one at the time and read them over and over until things seem to make sense when they try to run them. If you go to the "Special\scripts" comand you will be able to select a script and then "execute" it. On the bottom of the script selection window there is a box that you can check called "STEP". This will take through the script step by step (kind like single block on a CNC machine). This is especially good when running a script for the first time because you will find out where the mistake is (most of the time).
    Hope this helps,
    Sorin



  6. #6
    Registered Kookaburra's Avatar
    Join Date
    Apr 2003
    Location
    Australia
    Posts
    372
    Downloads
    0
    Uploads
    0

    Default

    Everyone,

    I must add that experience is the best way. I also must add on BobCAD's behalf that their manual shows in great detail how to get from drawing to g-code, well done BobCAD!!! Scripting is a very advanced option and I must admit a very nice option indeed, I use it all the time to create my own drawing and g-code programming facilities and I have found that if you know the fundamentals of basic programming and how scripting works, then most of the information you need to have success is in the BobCAD Manual. I must ask this question, when you buy a car you are given a manual that explains where all of the buttons are and what they do but author of the manual will expect that you at least know how to drive the car.

    "A Helicopter Hovers Above The Ground, Kind Of Like A Brick Doesn't"
    Greetings From Down Under
    Dave Drain
    Akela Australia Pty. Ltd.

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


  7. #7
    Registered Klox's Avatar
    Join Date
    Mar 2003
    Location
    NZ
    Posts
    507
    Downloads
    0
    Uploads
    0

    Default

    Kookaburra,
    Nice to hear from you!
    I'm actually a BobWIRE user and i haven't had the need for scripting in BobWIRE yet. The guys i am competing against in my neighbourhood either uses PEPS, MasterCAM, HCAM or even Cameo (can you believe it!).

    I got myself BobCAD V18 a while ago and being inquisitive by nature i am checking out scripting. I must admit that i am using V18 a lot as a vehicle to import DXF and IGES files from other packages as it is more powerfull as V16.

    I do not have much time to play around with scripting, i have done one experimental script and i see that it would take time to get the hang of it. I must say that it is very interesting!

    See you,

    Klox

    *** KloX ***
    I'm lazy, I'm only "sparking" when the EDM is running....


  8. #8
    Registered Kookaburra's Avatar
    Join Date
    Apr 2003
    Location
    Australia
    Posts
    372
    Downloads
    0
    Uploads
    0

    Default

    Klox,

    when you get into scripting and get good at it, it veryyyyy hard to
    stop thinking about all the possibilities, the fact that you can manipulate both the nc code and the geometry is beautiful. To get a handle on it first have a look at the sample scripts issued with BCC V18 and work out how the dialogue and variables work then do some script recording eg: set record on and draw a line, then open the script and edit the actual values to be variables, set your code to bring up a pop up window to ask you the values that will be assigned to the variables you have stipulated and see how you go. Once you have the basics it it not a hard climb from there. If you wish you can contact me and I will be happy to help you get started.

    "A Helicopter Hovers Above The Ground, Kind Of Like A Brick Doesn't"
    Greetings From Down Under
    Dave Drain
    Akela Australia Pty. Ltd.

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


  9. #9
    Registered Klox's Avatar
    Join Date
    Mar 2003
    Location
    NZ
    Posts
    507
    Downloads
    0
    Uploads
    0

    Default

    Kookaburra,
    Thanks for the generous offer. First question: Scripting does it "happen" in Basic or Virtual Basic?

    Please type a teeny weeny bit slower the next time as i am a slow reader! LOL

    Just pulling your leg!!!

    Klox

    *** KloX ***
    I'm lazy, I'm only "sparking" when the EDM is running....


  10. #10
    Registered Kookaburra's Avatar
    Join Date
    Apr 2003
    Location
    Australia
    Posts
    372
    Downloads
    0
    Uploads
    0

    Default

    Klox,

    I would suggest you would call it virtual basic because you are dealing with a piece of software that houses its own library of required statements for calling on functions within the software itself and there are some minor differences in how you arrange the whole program to best work. But if a basic programmer had to learn the scripting environment within BobCAD it would not take much time to get a grasp of what is going on.

    For example, in a script you can automatically create a layer, select a line, divide a line, create an arc, etc. These are special cad functions that have to align with a piece of software that can interperet them and perform an on-screen outcome. So I guess BobCAD to a certain extent had to change the "so called normal" to make things work.

    Typed slower this time by holding a coffee in one hand and typing with the other.

    Clear as Mud ?

    "A Helicopter Hovers Above The Ground, Kind Of Like A Brick Doesn't"
    Greetings From Down Under
    Dave Drain
    Akela Australia Pty. Ltd.

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


  11. #11
    Registered Jennifer's Avatar
    Join Date
    Jun 2003
    Location
    San Diego, CA
    Posts
    129
    Downloads
    0
    Uploads
    0

    Default

    Hey Guys!

    Every time I try to get into this scripting thing my computer freezes up. I've got the "Intro to BOBCAD Basic..." and following along, doing nothing more than the first exercise (rectangle w/circle) to record a script...I try to play it back...computer rigor mortise. Doesn't make it seem too friendly.

    Any thoughts?

    Jen

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


  12. #12
    Registered Kookaburra's Avatar
    Join Date
    Apr 2003
    Location
    Australia
    Posts
    372
    Downloads
    0
    Uploads
    0

    Default

    Jen,

    Did you edit the script to define all of the variables, popup window, etc. If so, can you give me a better description of what the PC is doing. Are there any error messages or does it just sit there in crash land. Usually this comes from a slight glitch in the scripting code. I will be happy to look at it for you. Feel free to e-mail me the *.bas file for some trouble shooting. A small problem it will be.

    "A Helicopter Hovers Above The Ground, Kind Of Like A Brick Doesn't"
    Greetings From Down Under
    Dave Drain
    Akela Australia Pty. Ltd.

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


  13. #13
    Member HuFlungDung's Avatar
    Join Date
    Mar 2003
    Location
    Canada
    Posts
    4826
    Downloads
    0
    Uploads
    0

    Default

    Hi Jennifer,

    Bobcad is object-action, so this requires that you have whatever objects you want to operate on, selected before the script runs.

    Keep in mind that there are some things you can do while recording a script that you cannot play back. Generally, anything that you do with the mouse is recorded by the script recorder, but will not work when played back. This means you have to figure out the "menu method" of doing whatever it is you are going to do. This is the way to make a "good recording".

    Generally, mouse actions that are recorded are preceded by the prefix "X", such as XSelect, or XCadlayer, etc. The last patch ( the one that was pulled), if you are running that, happened to screw around with this command structure a little bit, so that "Select Layers" would no longer work, but "XSelect Layers" would.

    The menu commands are generally valid commands to run when you try to run a script. You can learn what they are by means of the script recorder, that is the real reason to run it in record mode in the first place.



    First you get good, then you get fast. Then grouchiness sets in.

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


  14. #14
    Registered Jennifer's Avatar
    Join Date
    Jun 2003
    Location
    San Diego, CA
    Posts
    129
    Downloads
    0
    Uploads
    0

    Default

    K -
    It just sits there in "crash land" until I "end task" the ol' fella.

    H-
    "Generally, anything that you do with the mouse is recorded by the script recorder, but will not work when played back. "

    So, everything has to be done from the last command? This must be why the auto preselect has to be on...

    I'll have to mess with this a bit more and get back to you guys.
    Thanks for the prompt replies.

    Jen

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


  15. #15
    Member HuFlungDung's Avatar
    Join Date
    Mar 2003
    Location
    Canada
    Posts
    4826
    Downloads
    0
    Uploads
    0

    Default

    Ah, yes, I knew there was something about "auto-preselect". It may need to be on for scripts (I'm not positive what happens when it is off) but auto-preselect needs to be off for trim2 to work correctly.

    Actually, with the script recorder, you could also record the commands in the environment settings change required to turn auto preselect on and off. Then you could incorporate these commands at the beginning and end of a script. I never thought of doing that before, but it is feasible.

    Good luck!

    First you get good, then you get fast. Then grouchiness sets in.

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


  16. #16
    Registered Jennifer's Avatar
    Join Date
    Jun 2003
    Location
    San Diego, CA
    Posts
    129
    Downloads
    0
    Uploads
    0

    Default

    Here's what I'm trying to do...

    I draw a line...put end pts on it...another parallel to it......3 pt arc using the end pts and the parallel line...When I play it back I get no arc...Is this because I have to deselect between commands? How would I do this otherwise?

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


  17. #17
    Member HuFlungDung's Avatar
    Join Date
    Mar 2003
    Location
    Canada
    Posts
    4826
    Downloads
    0
    Uploads
    0

    Default

    Post your sample script here so it can be discussed.

    Hint: you cannot actually use the "LineParallel" command in your script because it requires mouse interaction to work, unless you had some way of knowing which side you wanted the offset line on.

    You would be best to create the two lines from coordinates, or you could copy and move a line that you create from coordinates.

    Part of the trick of scripting is figuring out a way to do something without using all the mouse shortcuts that you are accustomed to using. This sometimes involves writing quite a bit of code just to do a simple thing, but if that is what it takes for the script to execute, you are pretty much committed to doing things the long way.

    First you get good, then you get fast. Then grouchiness sets in.

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


  18. #18
    Registered Kookaburra's Avatar
    Join Date
    Apr 2003
    Location
    Australia
    Posts
    372
    Downloads
    0
    Uploads
    0

    Default

    HF & Jen,

    I have found that offset works much better that lineparallel. Lineparallel is a workable function given the right circumstances but I never usually worry about when is right and when is not I just use the offset function.

    Jen, I will have a go at what you are trying to do and get back to you.

    "A Helicopter Hovers Above The Ground, Kind Of Like A Brick Doesn't"
    Greetings From Down Under
    Dave Drain
    Akela Australia Pty. Ltd.

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


  19. #19
    Registered Kookaburra's Avatar
    Join Date
    Apr 2003
    Location
    Australia
    Posts
    372
    Downloads
    0
    Uploads
    0

    Default

    Jen,

    I hast completeth thy task. I will work out how to get it over to you. Maybe I should post it up as a technical article, or both, let me know. I have set it out as a step by step description of what code is doing what and where. The script would normally be very short but I have filled it full of remmed comments to make it easier to follow. I used script recording just to get some basics into it then did a final edit. I could have done it in a quicker way but I chucked a few extra steps in there to give you a better understanding of how scripting works. Hope it is OK.

    Last edited by Kookaburra; 07-16-2003 at 12:00 AM.
    "A Helicopter Hovers Above The Ground, Kind Of Like A Brick Doesn't"
    Greetings From Down Under
    Dave Drain
    Akela Australia Pty. Ltd.

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


  20. #20
    Registered Jennifer's Avatar
    Join Date
    Jun 2003
    Location
    San Diego, CA
    Posts
    129
    Downloads
    0
    Uploads
    0

    Default

    Kookaburra - (would that be "Kook" for short? )

    That sounds great! I think you should post it both here and in the technical articles - I'm sure lots of others would appreciate it.

    Thanks a bunch!

    Jen

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Scripting

Scripting