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

Hi everyone,

 

Could anyone please help me with how I could add this center drill tool to the toolmanager??? The problem is tool_manager function accepts only tp_tool as a parameter but how do I add TlToolCenterDrill to it????

 

tp_tool mcToolData;

op_tool_info mcToolInfo;

mcToolInfo.type = 1;

mcToolInfo.dia = 8;
mcToolInfo.tip_angle = 118;
mcToolData.arbor_dia = 8;
mcToolData.oa_length = 45;
mcToolData.flute_length = 8;
mcToolData.shldr_length = 8;
mcToolData.shoulderDiameter = 1;
mcToolData.taperLength = 1;
mcToolData.op = mcToolInfo;
            
TlToolCenterDrill centerDrill( mcToolData );
centerDrill.SetDrillDiameter( 2.5 );
centerDrill.SetDrillLength( 3.5 );
centerDrill.SetShoulderAngle( 63 );
centerDrill.SetShoulderLength( 8 );
centerDrill.SetTipAngle( 118 );
centerDrill.SetOverallLength( 45 );
centerDrill.SetOverallDiameter( 8 );
centerDrill.SetToolNumber( mcToolInfo.tlno );
centerDrill.SetName( "Sample Center Drill" );

Link to comment
Share on other sites

What version of Mastercam?  Always good information for us to know - especially when talking about "Tools".

 

1> I assume you show this tp_tool /op_tool_info to TlTool... construction method because you thought that you needed to have a tp_tool.

     Just instantiate the TlTool... type you need and then use its Set…() methods to load it up.

 

2> You want to get away from the old tool_manager method if possible.

 

3> You want to be ultimately thinking Tool “Assembly".

/// <summary> Constructs a Tool Assembly and adds it to the active Machine Group's tool list. </summary>
///
/// <param name="toolPtr">     A pointer to the Tool. </param>
/// <param name="holderPtr">   A pointer to the Holder. </param>
/// <param name="assemblyPtr"> [out] A pointer to the new Assembly. </param>
///
/// <returns> true if it succeeds, false if it fails. </returns>
bool AddToolAssembly (TlToolMillPtr toolPtr, TlHolderPtr holderPtr, TlAssemblyPtr &assemblyPtr)
	{
	// Construct a new (empty) Tool Assembly to stick the Tool and Holder into.
	TlAssemblyPtr tempPtr (new TlAssembly ());

	// We must have a Machine Group to add to.
	auto pMachineGroup = OMgetActiveMachineGroup ();
	if (pMachineGroup == nullptr)
		{
		return false;
		}

	if (!tempPtr->SetMainTool (toolPtr))
		{
		return false;
		}

	// Don't add an "empty" Holder.
	if (holderPtr->GetSegments ().size () > 0)
		{
		if (!tempPtr->SetMainHolder (holderPtr))
			{
			return false;
			}
		}

	// This Assembly belongs in this Machine Group.
	tempPtr->SetMachineGroup (pMachineGroup->grp_idn);

	// Add this Assembly to the Machine Group's tool list.
	bool result = TpMainToolMgr.GetMainMillToolList ().AddMillAssembly (tempPtr);
	if (result)
		{
		// Set the out [out] parameter for return to the caller.
		assemblyPtr = tempPtr;

		// Double check that it all went well. (optional).
		result = assemblyPtr->GetID () != TlID::EmptyID;
		}

	return result;
	}

/// <summary> Demonstrate making a Center Drill. </summary>
///
/// <returns> true if it succeeds, false if it fails. </returns>
bool MakeCenterDrill ()
	{
	TlToolCenterDrill centerDrill;
	centerDrill.SetToolNumber (1234);
	centerDrill.SetDrillDiameter (2.5);
	centerDrill.SetDrillLength (3.5);
	centerDrill.SetShoulderAngle (63);
	centerDrill.SetShoulderLength (8);
	centerDrill.SetTipAngle (118);
	centerDrill.SetOverallLength (45);
	centerDrill.SetOverallDiameter (8);
	centerDrill.SetTaperLength (1);
	centerDrill.SetName ( "Sample Center Drill" );
	//centerDrill.Set... etc, etc.

	// Construct a shared_ptr to this Center Drill Tool.
	TlToolCenterDrillPtr spTool (new TlToolCenterDrill (centerDrill));

	// The Holder - "define" it if desired.
	// Note that this Holder is 'empty' and our AddToolAssembly function will NOT add it to the Assembly.
	// Mastercam will then give the Assembly the "default" Holder. - (which we all know and love).
	TlHolderPtr spHolder (new TlHolder ());

	// Our AddToolAssembly function gives us back the new Assembly.
	TlAssemblyPtr spAssembly (new TlAssembly ());

	return AddToolAssembly (spTool, spHolder, spAssembly);
	}
Link to comment
Share on other sites

* Does other lower versions CHooks behave differently for the same code?

This may not work for versions earlier than X8.

Maybe X7 (though I've not tried this specific code in X7), but certainly not earlier than that.

The handling of Tools has been undergoing many changes.

As you can see from the code snippet I posted, not using “tp_tool” and/or the “tool_manager”.

 

* Is tool_manager deprecated?

Not officially, but… I’d suggest that it’s time to start moving away from using it.

There are the more “modern” ways of doing what you need without using it.

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

Roger,

thanks for the code snipet ;-)

 

Is there an easy way to create a default tool?

Let's say i want to add a bullmill. When I add a bullmill in Mastercam, it get's its defaults from Mastercam. How can I get the same defaults with a chook?

 

I tried to add a tool in X9 with the code above. It adds the tool. But when I try to select the tool in an operation, it crashes. I asume that I missed to correctly initialize some more parameters.

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