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:
I'm new at mastercam & VBA scpirt. I'm trying to write a script to auto draw Rectangles into the Mastercam 9. I have 1 text file with the original centre location of the objects, and 1 file is the objects size with center point. When it run till the end of the command it show error as " Microsoft VBScript runtime error Type mismatch "MakeRectangle' IActiveScriptSite::OnScriptError() Line: OK buttom"
Below is my script :
=================================================
Call Main()
Sub Main()
Const File_name1 = "C:mcam9vbtestTestData.txt"
Const File_name2 = "C:mcam9vbtestnetlist.txt"
Dim FSO,objTextFile1,objTextFile2,i,n,Lines_array1(99),Lines_array2(99),Row2,Rowa,Rect,color,level
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile1 = FSO.OpenTextFile(File_name1, 1)
Set objTextFile2 = FSO.OpenTextFile(File_name2, 1)
i = 0
Do Until objTextFile1.AtEndOfStream
Lines_array1(i) = objTextFile1.ReadLine
i = i + 1
Loop
n = 0
Do Until objTextFile2.AtEndOfStream
Lines_array2(n) = objTextFile2.ReadLine
n = n + 1
Loop
a = 1
b = 1
Row2 = Split(Lines_array1(a),",",-1,0)
Rowa = Split(Lines_array2(,",",-1,0)
If Row2(0) = Rowa(0) Then
Set Rect = New McRe
With Rect
.X1 = Rowa(1) - Row2(4)
.X2 = Row2(4) + Rowa(1)
.Y1 = Rowa(2) - Row2(5)
.Y2 = Rowa(2) + Row2(5)
End With
Call CreateRectangle(Rect, mcCONSTRUCTION_COLOR_CURRENT, mcCONSTRUCTION_COLOR_CURRENT)
End Sub
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.