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:

VBScript - Print named level list


Recommended Posts

Script of the day.

 

Print out list of all named levels directly to notepad.

 

code:

'///////////////// My Constants /////////////////

Public Const DEF_NOTEPAD = "C:WindowsNotepad.exe"

Public Const DEF_NOTEPAD_NT = "C:WINNTNotepad.exe"

Public Const DEF_LIST = "mcLevelList.txt"

Public Const DEF_ALL_LEVELS = 255

 

' -- Start Script

Call Main()

 

 

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

' Sub Declaration

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

Sub Main()

 

Dim intCurrentLevel, strCurrentLevelName()

Dim FSO, fsoLevelsList, intCount, strTemp, strShell

 

 

intCount = -1

 

' -- Iterate all levels

For intCurrentLevel = 1 To DEF_ALL_LEVELS

 

strTemp = Trim(GetLevelName(intCurrentLevel))

 

' -- Is this level named?

If Len(strTemp) <> 0 Then

' -- Resize our array

intCount = intCount + 1

ReDim Preserve strCurrentLevelName(intCount)

' -- Assign level name and nunber

strCurrentLevelName(intCount) = "Level #" & intCurrentLevel & " = " & strTemp

End If

Next

 

' -- Test

If intCount = -1 Then

' -- No named levels found

ShowString "No named levels found in current drawing"

Else

 

Set FSO = CreateObject("Scripting.FileSystemObject")

 

Set fsoLevelsList = FSO.CreateTextFile(GetPathOfThisScript & DEF_LIST)

 

For intCurrentLevel = 0 To intCount

fsoLevelsList.WriteLine strCurrentLevelName(intCurrentLevel)

Next

 

fsoLevelsList.Close

 

 

' -- Where is Notepad?

If FSO.FileExists(DEF_NOTEPAD) Then

strShell = DEF_NOTEPAD

ElseIf FSO.FileExists(DEF_NOTEPAD_NT) > 0 Then

strShell = DEF_NOTEPAD_NT

Else

strShell = vbNullString

End If

 

' -- Are we ok?

If Len(strShell) = 0 Then

'EditFile GetPathOfThisScript & "mcLevelList.txt"

' -- Stays modal to mc

Else

' -- Ok, show the file

strShell = strShell & " " & GetPathOfThisScript & DEF_LIST

Call ShellAndWait (strShell, False)

End If

 

' -- Clean up

Erase strCurrentLevelName

 

 

End If

 

 

' -- Clean up

Set FSO = Nothing

Set fsoLevelsList = Nothing

 

End Sub

Link to comment
Share on other sites

Just for fun, you can assemble the path to Notepad programatically. Fun wink.gif

 

code:

Dim objWSHShell     ' WSH Shell

Dim strNotepadPath ' path to Notepad

 

 

' create the WSH Shell object

Set objWSHShell = CreateObject("WScript.Shell")

 

' assemble path to Notepad

strNotepadPath = objWSHShell.ExpandEnvironmentStrings("%WinDir%") & "NOTEPAD.EXE"

Link to comment
Share on other sites

excuse my english

 

ok it is possible when i use the LEVELS.DLL fonction

i put the number of level (that it's ok) and after we have another choice put the name level

 

not going after in the level manager

 

thank's

 

confused.gif

 

[ 12-04-2003, 10:15 PM: Message edited by: mario ]

Link to comment
Share on other sites

mario,

 

Easy enough in script.

 

code:

' -- Start Script

Call Main()

 

 

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

' Sub Declaration

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

Sub Main()

 

 

Dim strLevelName, intLevelNumber

 

' -- Ask for a level

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

 

strLevelName = AskString("Input a level name")

 

' -- Ask for a name

If Len(Trim(strLevelName)) > 0 Then

 

Call SetLevelName (intLevelNumber, strLevelName)

 

ShowString "Level name set"

 

End If

 

End If

 

 

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