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:

How to ublank entities in a Chook ?


Recommended Posts

Good day,

I am blanking the entities in my mcx files with this function


int doentblnk(long selectionMask = ALL_ENTITIES_MASK, int level = 0, MC_BYTE color = 0)
{
	long count = 0; bool succf, suc = false; ent entity; DB_LIST_ENT_PTR foundPtr; DB_LIST_ENT_PTR eptr = db_start;
	do
	{
		get_raw_ent(false, &eptr, &foundPtr, &entity, 0, ALL_ENTITIES_MASK, &succf);

		if (succf)
		{
			if (entity.id != selectionMask)
			{
				suc = true;

				sel_bit_turn_on(&entity, BLANK_BIT);

				write_ent_sel(&entity, entity.eptr);
			}

		}
	
	} while (succf); 

	return suc ? 1 : 0;
}

However, when I try to reverse the process by setting BLANK_BIT off it does not work.

Link to comment
Share on other sites

Not sure what you mean about "does not work".

This worked for me (tested in 2018 and 2020) ->

extern "C" __declspec (dllexport) int m_main (int not_used)
	{
	// Must call this prior to accessing any Resources in the C-Hook DLL !
	ChangeResCl res (GetChookResourceHandle ());

	ent entity;
	if (AskForGeometry (_T ("Select an Arc..."), A_ID, entity))
		{
		sel_bit_turn_on (&entity, BLANK_BIT);
		write_ent_sel (&entity, entity.eptr);
		AfxMessageBox (_T ("Entity was Blanked"));

		sel_bit_turn_off (&entity, BLANK_BIT);
		write_ent_sel (&entity, entity.eptr);
		AfxMessageBox (_T ("Entity was UnBlanked"));
		}

	return MC_NOERROR | MC_UNLOADAPP;
	}

 

 

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

Not sure what you mean about "does not work".

This worked for me (tested in 2018 and 2020) ->


extern "C" __declspec (dllexport) int m_main (int not_used)
	{
	// Must call this prior to accessing any Resources in the C-Hook DLL !
	ChangeResCl res (GetChookResourceHandle ());

	ent entity;
	if (AskForGeometry (_T ("Select an Arc..."), A_ID, entity))
		{
		sel_bit_turn_on (&entity, BLANK_BIT);
		write_ent_sel (&entity, entity.eptr);
		AfxMessageBox (_T ("Entity was Blanked"));

		sel_bit_turn_off (&entity, BLANK_BIT);
		write_ent_sel (&entity, entity.eptr);
		AfxMessageBox (_T ("Entity was UnBlanked"));
		}

	return MC_NOERROR | MC_UNLOADAPP;
	}

 

 

Hi Roger,

some of the entities are not returning from their blanked state even manually after processing, but they are registered in the level manager.

I used this function

int doentunblnk(long selectionMask = ALL_ENTITIES_MASK, int level = 0, MC_BYTE color = 0)
{
	std::vector<ent> ents; std::vector<ent> ents2;
	long count = 0; bool succf, suc = false; ent entity; DB_LIST_ENT_PTR foundPtr; DB_LIST_ENT_PTR eptr = db_start;
	do
	{
		get_raw_ent(false, &eptr, &foundPtr, &entity, 0, ALL_ENTITIES_MASK, &succf);

		if (succf)
		{
				sel_bit_turn_off(&entity, BLANK_BIT);

				write_ent_sel(&entity, entity.eptr);
				
			

		}

	} while (succf);
	return suc ? 1 : 0;
}

 

Link to comment
Share on other sites

The now un-blanked entities are not appearing visually on-screen?

ref: interfaces\GUI\CGui_ch.h

// Try this first after the un-blanking.
repaint_graphics ();  

// This 'repaint_graphics' does do it for you, replace it with this ->
rebuild_graphics();  //  Only use if really needed, as this can take time.

} while (succf);

if (suc) //  Was anything changed?
  repaint_graphics ();  

return suc ? 1 : 0;

 

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

The now un-blanked entities are not appearing visually on-screen?

ref: interfaces\GUI\CGui_ch.h

// Try this first after the un-blanking.
repaint_graphics ();  

// This 'repaint_graphics' does do it for you, replace it with this ->
rebuild_graphics();  //  Only use if really needed, as this can take time.


} while (succf);

if (suc) //  Was anything changed?
  repaint_graphics ();  

return suc ? 1 : 0;

 

Thanks Roger, that fixed the problem, although jeeez I don't think I can afford the performance loss on that one.

Link to comment
Share on other sites

My problem is the management of existing geometry, in my project I host a collection of c++/cli nethook entry points each designed to :

->get a solid if there is 1 solid in the file

->blank the existing non solid entities ,lines,arcs, notes,splines etc.

->create geometry on the min/max z extends of the part using the psbodyaskfaces and psbodyaskedges on a unique level for each top and bottom group

->creates a silhouette boundary using mastercams silhouette boundary function onto a unique level

->separating the outer "external" profile of the silhouette boundary ,top geometry and bottom geometry levels using nethook chainmanger and sort chains by area functions

->separating the "full" 360 degree arcs onto a unique level for top and bottom

->comparing the xy CenterPoint and diameter values to find the "through" holes then storing them on a unique level

->converting all non full circle wireframe geometry to splines via nethooks createparametricsplinefromchains to avoid parts of the chain being dropped by nesting undetected

->using c++ chains_intersect and comparing the spline length on the remaining "internal" top and "internal" bottom group against the remaining silhouette boundary "internal" group and deleting the "through" pockets

->repeating the above process to filter out the full circles entities from the silhouette boundary "internal" group

-> assign specific toolpaths to each group of geometry on each level : top plane pockets, bottom plane pockets, top blind holes, bottom blind holes,bottom through holes,and the outer profile final contour 

In order to avoid inadvertently chaining existing geometry on the target levels I blank them with the first function, however it would be nice to return any notes or geometry for the

user, although this is not critical since we will be nesting after some parts may contain engineering notes pertaining to customer requirments for a specific part.

We make private jet interiors so there are a lot of "special cases" that need documentation and because of the fast pace production line style of programming notes in mastercam save a lot of time and ensure important information for the programmer is delivered.

 

 

 

Link to comment
Share on other sites
Quote

could the call set_clr_sel_bits() be interfering

Depends if you're messing with the BLANK_BIT when using this.

So you are "blanking" the items you don't want included in the chain(s) and then chaining all on that level?

Quote

In order to avoid inadvertently chaining existing geometry on the target levels

Is that the only way you have to separate the items to be chained?
Can you separate the desired items - by type, by color, or...
 

Edited by Roger Martin from CNC Software
Link to comment
Share on other sites
22 minutes ago, Roger Martin from CNC Software said:

Depends if you're messing with the BLANK_BIT when using this.

It is only clearing SELECT_BIT

23 minutes ago, Roger Martin from CNC Software said:

So you are "blanking" the items you don't want included in the chain(s) and then chaining all on that level?

Yes.

 

23 minutes ago, Roger Martin from CNC Software said:

Is that the only way you have to separate the items to be chained?
Can you separate the desired items - by type, by color, or...

Same problem since I am concerned with what would happen were the chook would to be ran twice.

Link to comment
Share on other sites

I have an Idea but I do not know how, could I recolor all the existing entities in the database then use color schemes to define which geometry to chain? I am chaining with the .net api chainmanager. (my efforts to do chaining in c++ have not been very successful)

Link to comment
Share on other sites

OK...

 You're trying to chain what, on which level, while having the chaining ignore what type(s) of geometry?

You're said you're doing this by blanking the unwanted entities, which while this will work...

You don't like the need to have to call rebuild_graphics after. Fair enough, as that can take some time to complete.

There may be other ways to segregate the wanted from the unwanted geometry when chaining.

If I have details, I may be able to offset suggestions,

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

You're trying to chain what, on which level, while having the chaining ignore what type(s) of geometry?

CHAIN Level : 10000000  + Level 500000000 as top pocket operation

CHAIN Level : 5000000  + Level 500000000 as bottom pocket operation

CHAIN Level : 50 as bottom pocket operation

CHAIN Level : 100 as top pocket operation

CHAIN Level : 5000 as contour osciliation bottom plane

CHAIN Level : 5000 as 2d contour bottom plane

CHAIN Level : 50000000 as contour osciliation top plane

CHAIN Level : 50000000 as 2d contour top plane
 

Our programmers are currently using an older chook I wrote to program full  360 degree arcs so I will deal with those at a later date.

We are currently using the new chooks also as of yesterday, It is working well, the issue is really just the blank entities requiring refresh.

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