Results 1 to 5 of 5

Thread: Getting the X and Y of my First CAM location

  1. #1
    Registered
    Join Date
    Dec 2006
    Location
    USA
    Posts
    47
    Downloads
    0
    Uploads
    0

    Getting the X and Y of my First CAM location

    I've posted this in the BCC Forums. Thought someone here might help as well.

    I'm trying to make an Edit to the Way the Tool Change Macro Outputs the First X and Y position. In the Default Macro, It was Hard Coded to output an X0 and a Y0.
    I've Changed it to X???? and Y???? because these always need to be changed.
    What I liked to do is have the Macro Output the X and Y of the First Feature to be cut from the Cam side.
    If Nothing is selected on the CAM side then it would output the X???? and the Y???? so they can be manually changed.
    Example, If I'm going to Drill Holes, then I want the X and Y to be the X and Y of the First Hole location.
    Here is the Modified Script/Macro as I have it now.
    Fanuc0MDToolChange.bas
    Code:
    'Tool Parameters
    OptionsUnits Output, Unit = UN
    NCEdit Output,Line = i
    dim XPOS as double
    dim YPOS as double
    dim ZPOS as double
    dim TOOLNUM as integer
    dim DESC as string
    dim TOOLNUMSTRING as string
    dim SPINDIR as integer
    dim SPINSPEED as integer
    dim WORKOFF as integer
    SPINDIR = 3
    SPINSPEED = 500
    WORKOFF = 54
    NCEdit Line = i, Output, X = XPOS, Y = YPOS, Z = ZPOS
    Ask Header="Tool Change",Output,Cancel=canc,"Tool Number;0"=TOOLNUM, "Tool 
    Description"=DESC, "Spindle Direction;0"=SPINDIR, "Spindle Speed;0"=SPINSPEED, 
    "Work Offset;0"=WORKOFF
    If canc Then
        Exit
    End If
    If WORKOFF < 54 Then
     WORKOFF = 54
    End If
    If WORKOFF > 59 Then
     WORKOFF = 59
    End If
    If TOOLNUM > 99 Then
     TOOLNUM = 99
    End If
    If TOOLNUM < 0 Then
     TOOLNUM = 0
    End If
    If TOOLNUM < 10 Then
     TOOLNUMSTRING = "0"+TOOLNUM
    Else
     TOOLNUMSTRING = TOOLNUM
    End If
    If SPINDIR < 3 Then
     SPINDIR = 3
    End If
    If SPINDIR > 4 Then
     SPINDIR = 4
    End If
    If SPINSPEED < 0 Then
     SPINDPEED = SPINSPEED * -1
    End If
    XPOS = XPOS - 1
    YPOS = YPOS - 1
    NCEdit Line = i,Output,Text=txt
    txt = "N"+TOOLNUM+"M06T"+TOOLNUMSTRING
    If Len(DESC) > 0 Then
     txt = txt+" ("+DESC+")"
    End If
    NCEdit Line = i,Text=txt, X = XPOS, Y = YPOS, Z = ZPOS, Output, NumLines=nl
    NCEdit Line = i+1,Output,Text=txt
    txt = txt+"G0G"+WORKOFF+"G90X????Y????S"+SPINSPEED+"M0"+SPINDIR
    NCEdit Line = i+1,Text=txt, X = XPOS, Y = YPOS, Z = ZPOS, Output, NumLines=nl
    NCEdit Line = i+2,Output,Text=txt
    txt = txt+"G43Z1.0H"+TOOLNUM+"M08"
    NCEdit Line = i+2,Text=txt, X = XPOS, Y = YPOS, Z = ZPOS, Output, NumLines=nl
    NCEdit Line = nl + 2, X = XPOS, Y = YPOS
    NCRenumber
    Window2
    This is the Sample NC code that I get...
    N1M06T01 (TEST)
    G0G54G90X????Y????S500M03
    G43Z1.0H1M08
    Can anyone help with what I need to change on the Highlighted section of the Macro/Script?


  2. #2
    Registered tjones's Avatar
    Join Date
    Oct 2005
    Location
    USA
    Posts
    851
    Downloads
    0
    Uploads
    0
    Not sure how to read the future?

    How can the script know what you will be doing next? You could put the tool change line in and then later run a script to read the position and update the x,y.

    Maybe some more info would help.

    Do you wish to have the script read a cad position or have the operator input the values when it runs?


  3. #3
    Registered
    Join Date
    Dec 2006
    Location
    USA
    Posts
    47
    Downloads
    0
    Uploads
    0
    Not sure how to read the future?
    Not looking to read the future...

    The Chain to be Cut has already been selected on the CAD side.
    I'd like the Script to read the X and Y of the start point of the First Entity of the Chain. Then Insert that X Y in place where I have the X???? Y????.

    If no Chain, or Entity is selected, then it would default to using the X???? Y????.

    I've examined every script that comes with BCC and most of the scripts that I've found through various posts. I haven't been able to find the variable or codes that I need to use to do this.

    I'm pretty sure that the Selected Chain would be available as an Array, but What Array? Then How do you determein if the Entity is a Point, Line or Arc?

    I'm also thinking that maybe it can be done after the fact with Generate, and then go back to the first line and search for the X and Y.


  4. #4
    Registered
    Join Date
    Aug 2003
    Location
    United States
    Posts
    449
    Downloads
    0
    Uploads
    0
    Try this, not exactly, it will need some formatting and changes to work in your script, but this gives you the basic idea.

    NCEdit Line = i
    Verify Output, NSel = NE
    If NE = 0 Then
    txt = X???Y???
    Else
    Generate
    NCEdit Line = i, Output, X = xpos, Y = ypos
    Undo
    txt = X + xpos + Y + ypos
    End If


    Then do the rest. You need to generate code, so that the the system knows where X and Y are. The scripting engine does not allow you to get information from the entities directly, so we create the locations and just store them to a variable before we undo the code generation.

    Regards


  • #5
    Registered
    Join Date
    Dec 2006
    Location
    USA
    Posts
    47
    Downloads
    0
    Uploads
    0
    You need to generate code, so that the the system knows where X and Y are. The scripting engine does not allow you to get information from the entities directly, so we create the locations and just store them to a variable before we undo the code generation.
    I'll experiment with your sample code and see what I can come up with.
    If I get it working, I'll post the finished code.

    Thanks, this might just be the missing info I need.


  • Similar Threads

    1. What is the X & Y Location
      By Joe Crumley in forum Commercial CNC Wood Routers
      Replies: 3
      Last Post: 04-09-2007, 01:42 AM
    2. Forum Location
      By adwsystems in forum General Metalwork Discussion
      Replies: 0
      Last Post: 05-16-2006, 08:15 AM
    3. Map your location
      By Rekd in forum CNCzone Club House
      Replies: 20
      Last Post: 10-20-2005, 10:49 PM
    4. location
      By mocnc in forum DIY CNC Router Table Machines
      Replies: 15
      Last Post: 04-08-2005, 05:12 PM
    5. location?
      By fastolds in forum Surfcam
      Replies: 11
      Last Post: 12-02-2004, 02:58 AM

    Posting Permissions


     


    About CNCzone.com

      We are the largest and most active discussion forum from DIY CNC Machines to the Cad/Cam software to run them. The site is 100% free to join and use, so join today!

    Follow us on

    Facebook Dribbble RSS Feed


    Search Engine Friendly URLs by vBSEO ©2011, Crawlability, Inc.