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:

problem in vbs


Recommended Posts

Hi Mick;

this is my frist vb.

 

' -- Start Script

Call Main()

 

 

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

' Sub Declaration

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

Sub Main()

 

 

Dim intLevelNumber

Dim strMc

Dim strOriginalPath

 

' -- Ask for a level

If askValue("Input level number",0,255, intLevelNumber) Then

SetLevelByNumber(intLevelNumber)

Call SetLevelVisibleByNumber(intLevelNumber,True)

Call RunMastercamCommand("fit")

'If Not IsDrawing Then

' ShowString "No drawing"

' Exit Sub

 

'intLevelNumber=GetEntityLevel

 

strOriginalPath = GetCurrentFileName

 

'renname with LevelNumber

strMC= Replace(LCase(GetCurrentFileName), ".mc9", "-intLevelNumber.mc9")

' save file

Call SaveMCAs(strmc,True)

 

Call RepaintScreen (True)

 

 

 

'End If

End If

End Sub

 

'entity serach

Function IsDrawing()

Dim Ret

Ret = StartDBSearch(mc_alive, -1)

IsDrawing = Ret

End Function

thanks!

Link to comment
Share on other sites

Maks, is this closer to what you're looking for?

 

code:

' -- Start Script

Call Main()

 

 

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

' Sub Declaration

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

Sub Main()

Dim intLevelNumber

Dim strMc

Dim strOriginalPath

Dim strNewExt

 

 

If IsDrawing Then

' -- Ask for a level

If askValue("Input level number",0,255, intLevelNumber) Then

SetLevelByNumber(intLevelNumber)

Call SetLevelVisibleByNumber(intLevelNumber,True)

Call RunMastercamCommand("fit")

 

strOriginalPath = GetCurrentFileName

 

'renname with LevelNumber

strNewExt = "-" & intLevelNumber & ".mc9"

strMC= Replace(LCase(GetCurrentFileName), ".mc9", strNewExt)

 

' save file

Call SaveMCAs(strmc,True)

Call RepaintScreen (True)

End If

End If

End Sub

 

 

'entity serach

Function IsDrawing()

Dim Ret

 

Ret = StartDBSearch(mc_alive, -1)

IsDrawing = Ret

End Function

Link to comment
Share on other sites

maks,

 

Not sure if this is what you are after but it might give you some ideas.

 

code:

' -- Start Script

Call Main()

 

 

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

' Sub Declaration

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

Sub Main()

 

 

Dim intLevelNumber

Dim strMc

Dim strOriginalPath

 

 

' -- Turn on all levels

'Call ShowAllLevels()

 

 

If Not IsDrawing() Then

ShowString "No drawing"

Exit Sub

End If

 

' -- Ask for a level

If askNumber("Input level number", 0, 255, intLevelNumber) Then

 

'-- Loop all levels, hide all except the one the user wants

Dim i

 

For i = 0 To 255

 

If i <> intLevelNumber Then

Call SetLevelVisibleByNumber(i,False)

Else

Call SetLevelVisibleByNumber(i,True)

End If

 

Next

 

SetLevelByNumber(intLevelNumber)

Call RepaintScreen(True)

 

strOriginalPath = GetCurrentFileName()

 

'renname with LevelNumber

strMC= Replace(LCase(strOriginalPath), ".mc9", "-" & intLevelNumber & ".mc9")

 

' save file

Call SaveMCAs(strmc,True)

'Call ShowAllLevels()

Call RepaintScreen(True)

 

ShowString "File '" & strMC & "' has been saved"

 

End If

End Sub

 

'entity serach

Function IsDrawing()

Dim Ret

Ret = StartDBSearch(mc_alive, -1)

IsDrawing = Ret

End Function

 

 

 

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

' Function Declaration

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

Public Sub ShowAllLevels

 

'-- Loop all levels and show them

Dim i

 

For i = 0 To 255

Call SetLevelVisibleByNumber(i,True)

Next

 

End Sub

Link to comment
Share on other sites

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