Sign in to follow this  
peter ~

CHOOK question : using "chains_overlap_pct"

Recommended Posts

Hi I am trying to determine the overlap percentage between 2 chains, however I keep getting a result of zero when I check the value. This is the relevant section of the code :

int SortSplines()
	{
		std::vector<ent> spl1;

		std::vector<ent> spl2;

		sort_lines(1000, 500, spl1, spl2);

		std::vector<CHAIN*> chn1;

		std::vector<CHAIN*> chn2;
		
		for (auto spline : spl1)
		{
			sel_bit_turn_on(&spline, SELECT_BIT);
			write_ent_sel(&spline, spline.eptr);
			auto chn = CreateChain(spline);
			chn1.push_back(chn);
		}
		
		for (auto spline : spl2)
		{
			sel_bit_turn_on(&spline, SELECT_BIT);
			write_ent_sel(&spline, spline.eptr);
			auto chn = CreateChain(spline);
			chn2.push_back(chn);
		}
		
		for (auto chain1 : chn1)
		{
			for (auto chain2 : chn2)
			{
				double pct1 = 2.0; double pct2 = 2.0;
				chains_overlap_pct(chain1, chain2, 0.005, &pct1, &pct2);
				auto ret = chains_intersect(chain1,chain2,.005);

				char message1[5000];
				bool allok1 = true;
				sprintf_s(message1, "x : %lf y: %lf ret : %d", pct1,pct2,ret);//2275712//2275680
				MessageBox(NULL, allok1 ? message1 : "Operation Failed", "SharkBait", MB_OK);
			}
		}
		
		return 1;
	}
};

 

Share this post


Link to post
Share on other sites
52 minutes ago, Roger Martin from CNC Software said:

What version of Mastercam ?

Sorry Roger, it is Mcam 2018.

Share this post


Link to post
Share on other sites

The chains intersect returned a value but not the overlap

Share this post


Link to post
Share on other sites
3 minutes ago, Roger Martin from CNC Software said:

Peter,

Is Mastercam in "Design" mode when executing - chains_overlap_pct (...) ?
You need to have at least a Machine Group so Mastercam is not in Design.
Otherwise it will always return 0 in the (2) out variables.

I will need to check. I will ensure the machine group is active while calling the function. Do you know if the chains_intersect function requires an active machine group?

Share this post


Link to post
Share on other sites
7 minutes ago, Roger Martin from CNC Software said:

Yes, if there is no Machine Group(s), it will return '-1' (error).

When I ran the test chains_intersect returned 1 then chains_overlap_pct returned 0.0 depite the overlap between the two chains. I will still retry the test ASAP. Thank you Roger.

Share this post


Link to post
Share on other sites

Seems to be working now thanks Roger

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • 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