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:

Recommended Posts

  • 1 month later...
  • 2 weeks later...

Fred,

I came up with this with a little help. It outputs the points XYZ value to an Excel file. You will need an empty Excel file named xyz.xls in the root of C.

 

HTH

Steve

 

code:

' -- Start Script

Call Main()

 

 

' ////////////////////

' Sub Declaration

' ////////////////////

 

Sub Main()

 

Dim dblExcelRow ' Stores the current Excel Row number we are writing to

Dim dblRowInc ' Row incrimentation for the Excel sheet.

Dim cPoint ' MasterCam point variable.

Dim cExcelFileName ' Full Name and Path to the Excel file.

 

' Start on the 1st Row on the XLS...

dblExcelRow = 1

 

' We want to advance 1 row at a time.

dblRowInc = 1

 

' Setup the Excel file...

cExcelFileName = "c:xyz.xls"

'

' NOTE : This REALLY should be obtained from the user via popup

' and include the option to create a new file.

 

' Open the Excel file...

OpenExcelFile cExcelFileName

 

 

' Initialize the Database for Searching.

If IsDrawing() Then

 

' Loop for each Enitity in the database.

DO

 

' Make sure our point var is empty.

Set CPoint = New McPt

 

' Get the x,y,z point data for the current Entity (-1)

If GetPointData(-1, cpoint) Then

 

' Store the x,y,z data

StorePointData2Excel cPoint, dblExcelRow

 

' Advance our row pointer so we are ready next trip..

dblExcelRow = dblExcelRow + dblRowInc

 

End If ' End If for : GetPointData(-1, cpoint)

 

' NextDBSearch() : selects and makes current the Next Entity if any.

' Returns True/False based on availability.

If NextDBSearch() = False Then

' No next point was available...

Exit Do

End IF ' End If for : NextDBSearch()

Loop

 

End If ' End If for : IsDrawing()

 

 

SaveExcelFile"c:xyz1.xls"

CloseExcelFile

 

' The EXCEL process remains open after this script terminates.

' It does close when Mastercam is closed however.

' Repeated calls do NOT open multiple copies of Excel

' (unless something wrong happened during excecution)

 

 

End Sub

 

 

' ////////////////////

' Function Declaration

' ////////////////////

 

Function IsDrawing()

Dim Ret

'Initialize the Database for access.

' This also sets the first Entity as the current Entity.

Ret = StartDBSearch(mc_alive, mc_pointtype)

IsDrawing = Ret

End Function

 

 

' ////////////////////

' Function Declaration

' ////////////////////

 

Function StorePointData2Excel(ByRef pcPoint, ByVal pdblRowInc)

 

Dim strCellA

Dim strCellB

Dim strCellC

' Dim strCellD

 

StorePointData2Excel = False

 

'get point data

strCellA = "a" & pdblRowInc

strCellB = "b" & pdblRowInc

strCellC = "c" & pdblRowInc

' strCellD = "d" & pdblRowInc

 

WriteExcelValue strCellA,Round(pcPoint.x,5)

WriteExcelValue strCellB,Round(pcPoint.y,5)

WriteExcelValue strCellC,Round(pcPoint.z,5)

' WriteExcelValue strCellD,pdblRowInc

 

StorePointData2Excel = True

 

End Function

Link to comment
Share on other sites

Fred,

 

I believe that is a VB script. To make it work, copy the text and paste it into a text editor like the Mastercam X editor or Notepad. Save the file as "points.vbs". I would save it into your C:"Mastercam X installation folder"vb file location.

 

Then open your file in Mastercam, and go to Settings | VBScript...

 

In the dialog box, navigate to your VB script file and press "Run".

 

That should work.

 

HTH,

Link to comment
Share on other sites
  • 2 weeks later...
  • 1 month later...

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