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:

Ca I change NC file name without op.Regenerate()?


Recommended Posts

Hi. All.

 

I've been looking for a way to change NC file name, (nci name), in each operation.

I found some similar questions and code snippets in this forum, and applied the same idea from those.

 

Here is the partial code.

            foreach (Operation op in selectedOps)

                switch (op.Type)
                {
                  case OperationType.Pocket:


                     if (DialogReturn == DialogReturnType.Yes)
                     {
                         DialogManager.OK("No." + cntr1 + Environment.NewLine + " Operation Name: " + op.Name.ToString() + Environment.NewLine + " Operation NCI Name; "
                         + op.NCIName.ToString() + Environment.NewLine + " Pocket:GroupNumber = " + op.GroupNumber.ToString()
                         + Environment.NewLine + " OperationID = " + op.GetOperationID().ToString(), "Operation info");
                     }

                             op.NCIName = ("C:\\mcamx\\mill\\nci\\" + New_NCI_Name + ".NCI");
                            OperationsManager.NCCurrentFileNameMode = NCFileNameMode.UseUserDefinedName;
                            OperationsManager.RefreshOperationsManager();

                            op.Commit();
                            op.Regenerate();
                            cntr1++;
                     break;

 

My problem is, once execute op.Commit(), then an operation becomes "dirty", and it needs to regenerate a tool path.

I don't want to regenerate a tool path again, just for renaming NC file name.

Are there any way to rename NC file name without regenerating a tool path?

 

Before I made this C# program, I found a VB script, "post_selected.vbs", in this forum created by

Mr. Roger Peterson on 10/15/04.

And I modified the original script, and made it to rename nci name.

It worked, but it didn't change Toolpath Group NC file name.

 

Here is the partial code.

If contrenaming = 1 Then

	For counter1 = start_opnum1 To end_opnum1

		If GetOperationPostingFromID(vbNullString, counter1) = False Then
			nci_name1 =  GetNciNameFromOperationID(vbNullString, counter1) 
			'ShowString "op num: " & counter1 & "  nci_name1: " & nci_name1 

			' rename NCI file name
			'Call SetNciNameFromOperationID(counter1, "MM_test111")
			Call SetNciNameFromOperationID(counter1, sname)
			nci_name1 =  GetNciNameFromOperationID(vbNullString, counter1) 
			'ShowString "op num: " & counter1 & "  nci_name1: " & nci_name1
	 	End If 
	Next
End If

 

I tried to do it by C-hook, posted a question few weeks ago, but it will take a long time,

because of lack of knowledge and experience.

I'm still struggling for learning basics of C-hook...

 

Any advice will be appreciated.

If an answer would be for C#, it would be very nice.

Thank you, appreciated.

Link to comment
Share on other sites
Are there any way to rename NC file name without regenerating a tool path?

With a NETHook in X5, the short answer is "you can't".

In the "soon to be released" X5-MU1 there is a new overloaded .Commit(bool)

that will allow for updating everything except for the geometry in the operation.

 

For Ekke -> Rename operations - lost geometry

I gave him a (CHook) DLL that his NETHook could call to do the the NCI rename without affecting anything else.

Link to comment
Share on other sites

Roger,

 

Thanks for your prompt reply.

 

OK, looking forward to seeing X5 MU1...

 

Yes, I was VERY interested in Ekke's post.

However, we couldn't look at the code you wrote for Ekke, because e-mail was directly sent to Ekke.

 

Is it possible that you can send me the same C-hook program that you wrote for Ekke?

I'm sure it will be a big help for me.

 

I double checked my e-mail address registered here, eMastercam, and it is correct.

Thanks for your help, appreciated.

Link to comment
Share on other sites

Roger,

Hello.

 

Thanks for sending NetHook & C-hook programs.

 

First of all, tried it on X4 MU3. It worked fine.

Used Visual C# 2010 Express for Nethook program, I modified C# program a little, like take only selected operations.

Used VS 2008 for C-hook program, no problem as long as I compile for X4 MU3.

 

However, when I changed for X5, some compile error messages shown.

Compiling...
StdAfx.cpp
SetOperationNCI.cpp
main.cpp
c:\program files\mcamx5\sdk\interfaces\core\TlDefFunctions_CH.h(26) : error C2039: 'shared_ptr' : is not a member of 'std::tr1'
c:\program files\mcamx5\sdk\interfaces\core\TlDefFunctions_CH.h(26) : error C2143: syntax error : missing ';' before '<'
c:\program files\mcamx5\sdk\interfaces\core\TlDefFunctions_CH.h(26) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\mcamx5\sdk\interfaces\core\TlDefFunctions_CH.h(27) : error C2039: 'shared_ptr' : is not a member of 'std::tr1'
c:\program files\mcamx5\sdk\interfaces\core\TlDefFunctions_CH.h(27) : warning C4091: 'typedef ' : ignored on left of 'int' when no variable is declared
c:\program files\mcamx5\sdk\interfaces\core\TlDefFunctions_CH.h(27) : error C2143: syntax error : missing ';' before '<'
c:\program files\mcamx5\sdk\interfaces\core\TlDefFunctions_CH.h(27) : error C2059: syntax error : '<'
c:\program files\mcamx5\sdk\interfaces\core\TlToolMill_CH.h(64) : error C2065: 'tp_tool_ptr' : undeclared identifier
c:\program files\mcamx5\sdk\interfaces\core\TlToolLathe_CH.h(59) : error C2065: 'LATHETOOL_PTR' : undeclared identifier
Build log was saved at "file://h:\MacamX5_dwnlded\test_C-hook\from_eMastercam_Roger_M\SetOperationNCI (CHook DLL)\Release\BuildLog.htm"
SetOperationNCI - 8 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

 

 

If compiled for X4, no error messages.

------ Build started: Project: SetOperationNCI, Configuration: Debug Win32 ------
Compiling...
StdAfx.cpp
SetOperationNCI.cpp
main.cpp
Compiling resources...
Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
Copyright (C) Microsoft Corporation.  All rights reserved.
Compiling manifest to resources...
Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
Copyright (C) Microsoft Corporation.  All rights reserved.
Linking...
  Creating library Debug\SetOperationNCI.lib and object Debug\SetOperationNCI.exp
Embedding manifest...
Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
Copyright (C) Microsoft Corporation.  All rights reserved.
Build log was saved at "file://h:\MacamX5_dwnlded\test_C-hook\from_eMastercam_Roger_M\X4_SetOperationNCI (CHook DLL)\Debug\BuildLog.htm"
SetOperationNCI - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

 

I even tried on different PC, took time to set up, but it's worth.

Unfortunately, the same result. Compiled for X5, the same error messages.

 

I took your advice, setting environment variables, SDK_X4 and SDK_X5.

Am I still missing something?

 

Thanks for your help.

Link to comment
Share on other sites

You must have the "Service Pack 1" installed for Visual Studio 2008

 

SP1 is also out for VS 2010, but that is "optional".

 

Note!

If you wish to build a CHook using VS 2010, you MUST set the Platform Toolset in the project settings to 'V90',

and to be able to do that you MUST have VS 2008 also installed on your computer!

 

The code C++/MFC code generated by VS2008 and VS2010 is NOT "binary compatible".

Link to comment
Share on other sites

Mr. A. Lapointe,

 

Hello. Thanks for your advice, appreciated.

 

What I wanted to do was to change NC file name, (nci name), of Toolpath Group and operations

under the group.

 

My colleague said that one of X+ Tool, chgnci.dll, from GMCCS was exactly what we, (my colleague and I), were

looking for.

 

Although chgnci.dll will take care of daily job, I still want to make C-hook or NetHook program(s) myself.

 

Thank you.

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