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

Is there a way using the script engine to search for a file in multiple directories?  I have this working in the script:

Set FileList = CreateObject("System.Collections.ArrayList")
If FSO.FileExists(Directory & JobNumber & ".MCAM") Then '// File found
    FileList.add (Directory & JobNumber & ".MCAM")
End If

But I really need it to search the sub folders and return all the files found. Is this possible?

 

Thanks in advance.

Link to comment
Share on other sites

Hi,

I know nothing about the capabilities of the VB script dll.

But, if you swapped over to a NET-Hook this is easily done with the EnumerateFiles method and Linq.

            var mastercamExtentions = new List<string> { ".MCAM-CONTROL",
                                                         ".MCAM-MMD",
                                                         ".MCAM-LMD",
                                                         ".MCAM-RMD",
                                                         ".MCAM-WMD",
                                                         ".PST",
                                                         ".PSB",
                                                         ".PSM",
                                                         ".MCPOST",
                                                         ".MCBPOST",
                                                         ".MCDPOST",
                                                         ".MACHINE",
                                                         ".MCAM"
                                                        };

            var allFiles = Directory
                           .EnumerateFiles(folderPath, "*", SearchOption.AllDirectories)
                           .Where(file => mastercamExtensions.Any(file.ToUpper().EndsWith))
                           .ToList();

You can read more about this here.
   

Link to comment
Share on other sites
  • 2 weeks later...
19 hours ago, Karl@CP PISTONS said:

I looked in the commands from  add-ins.

What you're seeing in that list are special Add-Ins already "known" by Mastercam.

You let Mastercam know about your Add-In with a (.FT) Function Table file.

Now in Options, select in the Choose command from:

Commands Not in the Ribbon -or- All Commands

If your FT is proper, your add-in TipString will appear in the command list.

If not, check the Mastercam Log as it will complain if something is incorrect in the .FT file.

 

 

 

Link to comment
Share on other sites
17 hours ago, Karl@CP PISTONS said:

Can I just add the info from the FT file into the MC_chooks.ft file?

NO - Do not do that!

You create your own separate .FT file for your C-Hook (or NET-Hook) Add-In. 

Something like this ->

*Shown below is a sample FT for a C-Hook type Add-In.

The .FT for a NET-Hook Add-In would differ in the fact that it would have a FUNCTION NET section where you declare the entry point method and the tip-string and icons resources and the addition of a dnRES_NAME line where you would specify the "name" of the Resources in the .NET Assembly where Mastercam is to look to find those "resource" items.

# MyAwesomeAddIn.FT
#
# Application name should be uniquely named and be specific 
# to your company and/or product.
# 3rd party add-ins should NOT make this "Mastercam"!
APPLICATION "MyAwesomeAddIn_CP_PISTONS"

# Point to the locations of your function and resource libraries.
FUNC_DLL "chooks\MyAwesomeAddIn.dll"
RES_DLL    "chooks\MyAwesomeAddIn.dll"

CATEGORY "CP PISTONS Add-Ins"

# Specify the name of your entry point function,
# the Resource IDs of the tool tip string and 
# the small and large icon images for your add-in.
# The small icon must be a 16x16 pixel PNG image.
# The large icon must be a 32x32 pixel PNG image.
FUNCTION CPP "m_main"
    TIP  1
    SPNG 18001 
    LPNG 18002    
END_FUNCTION
 

 

Edited by Roger Martin from CNC Software
  • Like 1
Link to comment
Share on other sites

Yes my FT file looks similar ( also similar to existing .net ft files i.e. atp.ft which DOES show in the all commands list ) here is in entirety:

###############################################################################
# NET-Hook function table            
###############################################################################
#
# Name        : UHM_Open.ft
# NETHook     : UHM_Open.dll
# Date        : 
# Author    :  K Stickel
# Notes        : Rename all YOUR_NETHOOK with the name of this project
# Language    : VB.NET
#
###############################################################################


#######################################
# ASSIGN A UNIQUE NAME FOR THIS NETHOOK
#######################################
APPLICATION "UHM_Open"

######################
# NET-Hook PATHS
######################
#
# Update paths below to match your install path and project name.
# you can use folders if you wish to have your NETHook in a CHooks sub folder
# just make sure to edit this path to match.
FUNC_DLL   "CHOOKS\UHM_Open.dll"
RES_DLL    "SAME"
dnRES_NAME "UHM_Open.NETHook"
CATEGORY   "CP-Custom"

##############################################################################
# Public functions here
##############################################################################
#
# The main system entry point
FUNCTION NET "Run"
    dnSPNG "Run16"
    dnLPNG "Run24"
    dnTIP  "UHM Open"
END_FUNCTION

#
# EOF
 

Link to comment
Share on other sites

First off thanks all of the above who replied and helped out. The  icons showed up in the all commands section now..

But,  how do I get tMastercam to show the name as it is only just an icon without a description? Also when they are added to the toolbar the tool tip does not show up on mouse hover, should it?

 

 

Capture.JPG

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