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:

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;
	}
};

 

Link to comment
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?

Link to comment
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.

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