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:

Exporting MCX levels as seperate files


Recommended Posts

Hi everybody,

 

I have an MCX-8 file that consists of over 900 Levels!  Each level has
a separate 2D shape on it, and every level has a unique name.  Has
anyone seen a C-hook or VB Script that will parse the MCX and export
each level as a separate file?  Ideally each file could inherit the name
of the original Level.

 

To give a bit more info, I want to use either
geometry or toolpath nesting on this project, and I think that importing
the parts (or toolpaths) using the "from files" method is the way to go.
Thanks in advance!
 

Link to comment
Share on other sites

I know you can use file save some and then select information by level, but 900 levels,.....

Do you have an intern?

 

Haven't seen a c-hook or net-hook that would do that.

Have you tried contacting Rodger or Mick @ CNC Software?

Link to comment
Share on other sites

I created a X9 NET-Hook attached to this post. Copy the files to your C-Hook folder, make sure the DLL is not blocked (right click properties unblock)

 

Add a button to a tool bar, got to settings customize and select the NET-Hook category and drag the button to a tool bar.

 

Open a file and click the button, all levels that have geometry will be saved to a new drawing located in the same folder as the original drawing with the level name for  the file name.

 

Code for those interested:

           // All levels that have geometry
            var levels = LevelsManager.GetLevelNumbersWithGeometry();

            // Sanity check
            if (levels.Any())
            {
                // Get the current filename
                var currentFileName = FileManager.CurrentFileName;
                var currentPath = Path.GetDirectoryName(currentFileName);

                if (!string.IsNullOrEmpty(currentPath))
                {
                    LevelsManager.SetMainLevelVisibleSetting(false);

                    foreach (var level in levels)
                    {
                        SearchManager.SelectAllGeometryOnLevel(level, true);

                        LevelsManager.SetMainLevel(level);

                        // Build a new filepath
                        var levelName = LevelsManager.GetLevelName(level) + ".mcx-9";
                        var newFile = Path.Combine(currentPath, levelName);

                        PromptManager.WriteString("Saving file " + newFile + "...");

                        if (!FileManager.SaveSome(newFile, false))
                        {
                            EventManager.LogEvent(MessageSeverityType.ErrorMessage, newFile, "File save failed.");
                        }
                    }

                    SelectionManager.UnselectAllGeometry();
                    PromptManager.Clear();

                    DialogManager.OK(levels.Length + " files saved", "Save level to drawing");
                }
            }

SaveLevelsToDrawings.zip

Edited by Mick from CNC Software Inc.
  • Like 3
Link to comment
Share on other sites

I made some tweaks to he NET-Hook from the feed back. The file name now includes the level name and the level number to avoid any duplicate name collisions. I also added a different tool bar icon.

 

I also wrote the project in Visual Basic.NET and C# and I'll be attaching them to this post shortly.

SaveLevelsToDrawings.zip

VBNET_VS2013_Project.zip

post-4901-0-92680200-1436542049_thumb.png

CSharp_VS2013_Project.zip

Edited by Mick from CNC Software Inc.
  • Like 1
Link to comment
Share on other sites

Hey Mick,  thanks once again for this utility, I appreciate the work you've put in.  Hopefully you were able to stay away from the computer screen over the weekend!  Now I am encountering one issue, the customer who I am working with for this little project has been trying to run the Net-hook at his site but is getting an error message when he tries it: "Invalid user application"  He has both files in the correct folder (so he assures me).  The Net-Hook doesn't care whether the dongle is Dealer or Industrial does it? 

 

Or is it more likely a missing MS component, such as .Net 4.5?  or a C++ Redistributable?

Link to comment
Share on other sites

Hello,

 

I have had the same issue with one of my chooks (not the one from Mick). The customer gets the same message: "Invalid user application".

 

Every help to resolve this issue would be greatly appreciated.

 

I have tried to find the UnBlock option but couldn find it.

Link to comment
Share on other sites

The "Unblock" option (if the file is blocked) would be found by right-clicking on the DLL file, selecting Properties tab and in the lower-right you'd see an "Unblock" button.

 

*Note that this unblock issue is is only for NET-Hooks, not C-Hooks.

 This .NET issue is not new and not really a Mastercam issue, but it will be addressed in the next major release.

 Google: "File Zone Identifier" for more information if you're interested.

 

If you're getting "Invalid user application", a couple thing to look at ->

* The DLL was not built for the version of Mastercam you're trying to run it on.

* The DLL is dependent on other (usually DLL) files that could not be found and/or loaded.

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

Hey Mick,  thanks once again for this utility, I appreciate the work you've put in.  Hopefully you were able to stay away from the computer screen over the weekend!  Now I am encountering one issue, the customer who I am working with for this little project has been trying to run the Net-hook at his site but is getting an error message when he tries it: "Invalid user application"  He has both files in the correct folder (so he assures me).  The Net-Hook doesn't care whether the dongle is Dealer or Industrial does it? 

 

Or is it more likely a missing MS component, such as .Net 4.5?  or a C++ Redistributable?

Is he on X8??

 

i am on X8 and it sure would be cool if I could get this to work...

 

But alas.....Invalid user app here as well

Link to comment
Share on other sites

Bump....

 

Look guys (CNC)

 

Let's assume someone doesn't know anything about vb scripts, NET whatever or C++ programming and just wants to drop a couple of files in the C-hook Folder...press alt-c. and run the app without getting the invalid user app error message.

 

I am going to assume that since the dlls were crunched for X9. They won't work for X8...I have to assume that because neither of the 2 files shows blocked....

 

If the C-hook is suppose to also work with X8 perhaps Mick Gould give one more look see and figure out why myself and others are getting the error message...

 

I don't have 900 levels but do have about 50 and this little C hook looks like something that is real cool for one to have in their toolbox..

 

Thanks...

Link to comment
Share on other sites

I have updated the NET-Hook slightly to remove any invalid characters that might be on a level so that the file can be saved, the invalid characters are replaced with an underscore '_'

 

fred***  becomes fred___

 

 

X8 and X9 NET-Hooks are attached as is the X8 source.

 

Remember to unblock the dll  by right clicking and go to properties and make sure to uncheck unblock

 

You can add a new menu or toolbar for the NET-Hook by going to Settings->Customize->Category NETHook (see image)

post-4901-0-51798000-1438268911_thumb.png

X8_SaveLevelsToDrawings.zip

X9_SaveLevelsToDrawings.zip

X8VBSaveLevelsToDrawings_Source.zip

Link to comment
Share on other sites
  • 3 years 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...