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:

Does the drill type operation contain a feature to check for duplicate point positions?


Guest
 Share

Recommended Posts

Hi,

I have been having issues on occasion with toolpaths containing overlapping drill point causing problems, I was wondering if there is a way to prevent this that is part of the operation?

Link to comment
Share on other sites

Thanks Leon, If I understand you correctly duplicate position check is done only during the point selection process, not on regen.

 

This is my problem, I need the check to happen after point selection. That is what I needed to know, thank you.

Link to comment
Share on other sites
1 minute ago, Leon82 said:

Maybe try a resort ?

That's a good idea, I am working with the api, so a resort would be a viable option, if that doesn't work I will loop through the list of points checking for duplicates and deleting them.

Link to comment
Share on other sites
Just now, gcode said:

I would use the command "Delete duplicate entities" on my set of points before selecting them

 

gcode, thanks for your input, you are correct, however my selection is happening via the api, I will check with the sdk team if there is a similar function I can use but I haven't seen one.

Link to comment
Share on other sites

The intial problem was my own fault, I did not initially think the .net api was looking at the blanked entities, so when users would run the function twice points would get doubled up. 

I fixed the issue but I need some security features as part of my containment.

Link to comment
Share on other sites

Some lines were also typecasted incorrectly as arc but we should be able to resolved that by building our list of arcs with the chook sdk then redrawing the arcs in .net on assignment time.

Link to comment
Share on other sites
22 minutes ago, c++ said:

gcode, thanks for your input, you are correct, however my selection is happening via the api, I will check with the sdk team if there is a similar function I can use but I haven't seen one.

Could you create a macro that runs that command

BTW, it will not find and delete duplicates if the duplicate was blanked

Link to comment
Share on other sites
10 minutes ago, gcode said:

Could you create a macro that runs that command

Yes, that would not be a problem to do.

12 minutes ago, gcode said:

BTW, it will not find and delete duplicates if the duplicate was blanked

Good to know. 

Link to comment
Share on other sites

I found a way, I can pass the geometry via the chain manager check if its a closed chain, then check the arc radius if it is positive then for sure its a valid arc:

int MakeDrillOpFromGeometry(const MakeDrillOpFromGeometryParams &params)
////double clearancePlane, double feedPlane, double topOfStock, double depth, int viewId, int FeedRate, int spindlespeed, int slot, int targetlevel
{
		CString strname = "Mastercam";
		CString entryname = "delete_duplicates_basic";
	post_FT_command (
		strname,
	entryname);
	operation op = {};

	const auto views = Mastercam::Support::SearchManager::GetViews();

	Mastercam::IO::ViewManager::GraphicsView = views[params.viewId];

	Mastercam::IO::ViewManager::CPlane = views[params.viewId];

	Mastercam::IO::ViewManager::TPlane = views[params.viewId];
	//////////////////////////////////////////////////////////////////////////////////////////////////
	Mastercam::Database::ChainManager::ChainTolerance = .015;
	//create a new mastercam drilling opertation
	auto drilloperation = gcnew Mastercam::Operations::DrillOperation;
	//use the chainmanager to get the geometry from the mastercam database //closed chains only
	const auto chains = Mastercam::Database::ChainManager::ChainAll(true, false, nullptr, Mastercam::Database::Types::ChainDirectionType::Clockwise, params.targetlevel);
	//array
	int size = 2;
	System::Collections::Generic::List<Mastercam::Database::CurveGeometry^>^ curvegeometry = gcnew System::Collections::Generic::List<Mastercam::Database::CurveGeometry^>(0);
	//array<Mastercam::Database::CurveGeometry^>^ curvegeometry;
	//check that we have something
	if (chains != nullptr && chains->Length > 0)
	{
		//loop through the chains of the target geometry
		for (auto i = 0; i < chains->Length; i++)
		{
			//System::Windows::Forms::MessageBox::Show("chains Detected");
			//get the tot
			//retrieve the geometry in the target level
			const auto selectedEnts = Mastercam::Database::ChainManager::GetGeometryInChain(chains[i]);
			if (selectedEnts != nullptr)
			{
				//loop through the geometry assicuated with the chains
				for (auto j = 0; j < selectedEnts->Length; j++)
				{
					//System::Windows::Forms::MessageBox::Show("Curvegeometry Detected");
					//add the geometry to the list
					curvegeometry->Add(selectedEnts[j]);

				}
			}

		}
	}

	System::Collections::Generic::List<Mastercam::Curves::ArcGeometry^>^ arcgeometry = gcnew System::Collections::Generic::List<Mastercam::Curves::ArcGeometry^>(0);
	//convert the list to an array
	auto curvearray = curvegeometry->ToArray();
	//loop through the array
	for (auto i = 0; i < curvearray->Length; i++)
	{
		//declare the arc type id as a variable
		const auto arcType = Mastercam::Curves::ArcGeometry::typeid;
		//get the current type id
		const auto gt = curvearray[i]->GetType();

		//System::Windows::Forms::MessageBox::Show(gt->ToString());
		//check if we have an arc
		if (gt == arcType)
		{
			//add the arc into the arc list
			arcgeometry->Add(dynamic_cast<Mastercam::Curves::ArcGeometry ^> (curvearray[i]));
			//System::Windows::Forms::MessageBox::Show("Arc Detected");
		}
	}
	curvegeometry = gcnew System::Collections::Generic::List<Mastercam::Database::CurveGeometry^>(0);
	//convert the arc list to an array
	auto arcarray = arcgeometry->ToArray();
	//define a variable to count the amount of arcs assigned as drill point
	auto ptcount = 0;
	//loop through the arc array
	for (auto i = 0; i < arcarray->Length; i++)
	{
		auto drillPt = gcnew Mastercam::Database::DrillPoint(arcarray[i]);
		if (arcarray[i]->Validate())
		{
			if (!arcarray[i]->Blanked)
			{

				if (arcarray[i]->Data.Radius > 0.0)
				{
					drilloperation->DrillPoints->Add(drillPt);
					ptcount++;
				}
			}
		}
	}

	arcgeometry = gcnew System::Collections::Generic::List<Mastercam::Curves::ArcGeometry^>(0);
	
			
		drilloperation->AssignMillToolBySlot(params.slot);

		//linking params
		drilloperation->Linking->FeedPlane = params.feedPlane;

		drilloperation->Linking->Depth = params.depth;

		drilloperation->Linking->ClearanceOn = true;

		drilloperation->Linking->Clearance = params.clearancePlane;

		drilloperation->Linking->Retract = params.clearancePlane;

		drilloperation->Linking->RetractOn = true;

		drilloperation->Linking->TopStock = params.topOfStock;

		drilloperation->MiscValues->UseValuesFromPost = true;

		drilloperation->ForceToolChangeOn = false;

		drilloperation->RotaryAxis.Enabled = false;

		drilloperation->PlungeRate = 75.0;

		drilloperation->RetractRate = 500.0;
		//lead in

		//entry params

		//end lead in
		//
		drilloperation->SpindleSpeed = params.spindlespeed;
		//set feedrate
		drilloperation->FeedRate = params.FeedRate;

		drilloperation->NCIName = "Drill #1";

		drilloperation->Name = "Drilling operation created via API";

		drilloperation->Commit();

		//cntrop->Regenerate();

		DB_LIST_ENT_PTR ptr{};

		bool succf{};

		op.op_idn = drilloperation->GetOperationID();

		operation_manager(&op, OPMGR_GET, &ptr, &succf);

		op.cmn.stk_remain = 0.0;

		op.dcuts.stock_t_l = 0.0;

		op.misc.on = false;

		op.cmn.rapid_retract = true;

		op.cmn.retract_inc = false;

		op.cmn.retract_on = false;

		op.cmn.clearance_inc = false;

		op.cmn.depth_inc = false;

		op.cmn.top_stock_inc = false;

		op.cmn.feed_inc = false;
		op.u.prm_drl.brk_thru = 0.0;
		op.u.prm_drl.calcDepthFromStock = false;
		op.u.prm_drl.cycle = 1;
		op.u.prm_drl.drill_tip = false;
		op.u.prm_drl.dwell = 0.0;
		op.u.prm_drl.peck1 = 0.55;
		op.u.prm_drl.peck2 = 0.05;
		op.u.prm_drl.peck_clr = 0.5;
		op.u.prm_drl.start_hole = false;
		op.u.prm_drl.sub_pgm = false;
		op.u.prm_drl.do_custom = false;
		op.u.prm_drl.TipControl = 0;
		operation_manager(&op, OPMGR_REWRITE, &ptr, &succf);
		operation_manager(&op, OPMGR_NCI_REGEN, &ptr, &succf);
	
		return 1;
	
}

 

Link to comment
Share on other sites
21 hours ago, gcode said:

Could you create a macro that runs that command

BTW, it will not find and delete duplicates if the duplicate was blanked

I set the chainmanager to get the geometry and the pass it to the drillpoint manager and then I checked the blank bit.

I added the delete_duplicates_basic ft command so it runs all the op's then displays a report if any duplicates are deleted.

Since it is not looking at the entities we already blanked and it is deleting any duplicates It does just what I want.Brilliant solution thanks a lot gcode!!!!

Link to comment
Share on other sites

I know you already figured out the way to make this, in particular work, but I wanted to let you know that I'm not aware of any way to do a duplicate geometry check at regen time, currently.   Duplicate filtering is (and has been) on the selection side, not on the toolpath generation side. 

That said, this sort of thing is one of our goals during refactoring so in the near future you should have access to everything in the toolpath hole definition panel in a very modular manner.   The sorting engine, masking, duplicates, etc.

Link to comment
Share on other sites
2 minutes ago, Aaron Eberhard - CNC Software said:

I know you already figured out the way to make this, in particular work, but I wanted to let you know that I'm not aware of any way to do a duplicate geometry check at regen time, currently.   Duplicate filtering is (and has been) on the selection side, not on the toolpath generation side. 

That said, this sort of thing is one of our goals during refactoring so in the near future you should have access to everything in the toolpath hole definition panel in a very modular manner.   The sorting engine, masking, duplicates, etc.

Thanks Aaron, that sounds good, I sent some samples of the issues we had previously encountered via my reseller, hopefully it can help you with your development. I look forward to the new enhancements.

Link to comment
Share on other sites
2 minutes ago, Aaron Eberhard - CNC Software said:

Also, make sure you're asking questions like this to our API team...

They're sort of our direct "customer" for this sort of thing (if that makes sense to you), so it's always good to be in touch with them so we know how in-demand work like this is when I'm trying to plan out our year.. 

I talked to Mick about it a bit on the developer forum, he was the one who had me send some samples, I really should bring it up with Roger, but I am always brimming at the lid with questions for him I forgot to mention it. I will when he gets back, thanks!

Link to comment
Share on other sites
1 hour ago, Aaron Eberhard - CNC Software said:

I know you already figured out the way to make this, in particular work

It is not a hundred percent yet, I still need to add a loop to check the current point against existing points, although I think it is in good shape now. Going forward I may use a chook op to inherit the drill properties then add a function to the regen to check for duplicates..although you may have your new drilling operation out by then!

Link to comment
Share on other sites
  • 1 month later...
On 2/3/2020 at 4:13 PM, Aaron Eberhard - CNC Software said:

I know you already figured out the way to make this, in particular work, but I wanted to let you know that I'm not aware of any way to do a duplicate geometry check at regen time, currently.   Duplicate filtering is (and has been) on the selection side, not on the toolpath generation side. 

That said, this sort of thing is one of our goals during refactoring so in the near future you should have access to everything in the toolpath hole definition panel in a very modular manner.   The sorting engine, masking, duplicates, etc.

@Aaron Eberhard - CNC Software My initial attempt did not solve the issue, with some help from the SDK team I finally managed to "repair" and operation affected by some type of external geometry trapped in the drilling operation. I finally just deleted the operation and added back in the parameters and the points.

My code from the test was like this : 

auto operationlist = OperationManagerFunctions::GetOperations(TP_DRILL);

	for (auto drillop : operationlist)

	{

		auto op = *drillop;

		auto WCS = drillop->WCS;

		auto tpln = drillop->tpln;

		auto cpln = drillop->cpln;

		DB_LIST_ENT_PTR pr; DB_LIST_ENT_PTR ptr; bool s;

		std::vector<ent_tp> drillPointTPEnts;

		std::vector<ent> drillPointEnts;

		OperationManagerFunctions::GetPointsInOperation(drillop, drillPointTPEnts);

		for (auto point : drillPointTPEnts)

		{

			

			ent entity;

			get_ent_from_eptr(point.u.tp.eptr, &entity);

			drillPointEnts.push_back(entity);

		}

		operation_manager(&op, OPMGR_INIT_ADD, &ptr, &s);

		operation_manager(drillop, OPMGR_DELETE, &pr, &s);

		

		operation_manager(&op, OPMGR_ADD, &ptr, &s);

		OperationManagerFunctions::AddPointsToOperation(&op, drillPointEnts);

		op.WCS = WCS;

		op.tpln =tpln;

		op.cpln = cpln;

		operation_manager(&op, OPMGR_REWRITE, &ptr, &s);

		operation_manager(&op, OPMGR_NCI_REGEN, &ptr, &s);

I believe this will solve my issue. Up until now nothing I did would remove the geometry from the operation..although I suppose I technically still did not..

 

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