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 get the type of entity.


Recommended Posts

SigmaWave! What is your way to go through the db?

I use this to rotate all entities:

 

DL_DB_POS pos;

rewind_dl_db(ALIVE_BIT, L_ID|A_ID, &pos, false);

 

while (succf)

{

get_dl_db_ent(&pos, &e);

rotate_silent(&e.eptr, true, false, CenterPont, forgatasiszog, 1, &rotSuccf);

draw_ent(&e, e.color);

repaint_graphics();

 

if ((pos.u.db_ptr == db_start) | (pos.u.db_ptr == db_end)) {succf = false;}

 

}

 

BUT. This solution overflows with 1 ent. I mean one of my entities always rotate again (2times)... Why? What is what I left out?

Link to comment
Share on other sites

I tried this way also:

 

succf = true;

ptr = db_start;

e_ptr = db_start;

dbEptr = db_end;

 

while (ptr != dbEptr)

{

get_ent(&ptr, &e_ptr, &e, ALIVE_BIT, L_ID|A_ID|S_ID|NB_ID, &succf);

 

rotate_silent(&e.eptr, true, false, CenterPont, forgatasiszog, 1, &rotSuccf);

draw_ent(&e, e.color);

repaint_graphics();

}

 

 

BUT. In this case one of my entities not rotate... Different than in my prev post... frown.gif

Link to comment
Share on other sites

...and yes 1 more think... smile.gif

 

What is the proper way to use the rewrite_ent?

I use alone itself:

rewrite_ent(&e, 0);

 

I tried to use it to change color of an entity (in the same cycle with rotating). But no lot of luck.

 

The color of entities changed well but I can' higligth them... frown.gif

 

 

Oh MyGod, all of thinks above were much easy in VB as a simple NET-Hook... cool.giffrown.gifheadscratch.gif

Link to comment
Share on other sites

SigmaWave, it's nothing to say sorry about!!!

But Thank You for reply!!!

 

Today I tried some things:

I put the endptr watching in the first line in my cycle:

while (succf2)

{

if (ptr == dbEptr){succf2 = false;}

get_ent(&ptr, &e_ptr, &e, ALIVE_BIT, L_ID|A_ID|S_ID|NB_ID, &succf);

.

.

.

}

 

It works better as yesterday, but it's sometimes joking with me. Sometimes overflow with 1 entity but sometimes not... smile.gif

Sometimes work well. Sometimes left out 1 entity. biggrin.gifbanghead.gif

Maybe my given IGES playin' with me? Maybe I have to upgrade to MR2 SP1 SDK? No idea. Yet.

headscratch.gif

 

SigmaWave, if You want, you can mail me a small snippet... Many Thanks! rolleyes.gifcool.gif

Link to comment
Share on other sites

Today. smile.gif

 

I saw that, when I load my IGES and play a little with via Mastercam->xForm Translate/Rotate etc... And after then run my C-Hook (which rotate) everything fine... So I wrote a little cycle in my C-Hook before the rotating cycle. This short cycle only go trough the DB and rotate all entity with zero (yes, 0) degree... cool.gif

 

After than I can rotate/translate etc. well via my C-Hook... biggrin.gif

 

Projects for the next days: delete entity, change color/level... headscratch.gif

 

( Slowly this topic become my blog... biggrin.gif )

Link to comment
Share on other sites

I think it is very easy to go through the DB.

 

Here we go:

 

code:

 

 

DB_LIST_ENT_PTR d_ptr = db_start;

CString tempStr;

ent entity;

CList<CString, CString&> entList;

 

 

do

{

get_ent_from_eptr(d_ptr, &entity);

tempStr.Format(_T("idn: %d, ID: %d"), entity.ent_idn, entity.id);

entList.AddTail(tempStr);

d_ptr=d_ptr->next;

}while( d_ptr != db_end);

 

 

POSITION pos;

 

if (entList.GetCount() >0 )

{

pos = entList.GetHeadPosition();

while(pos)

{

tempStr = entList.GetAt(pos);

AfxMessageBox(tempStr);

entList.GetNext(pos);

}

}


I retrieved all the entity's ent_idn and ID, and store them in a CList. Then show them one by one.

 

The only problem of this code section is it is no good when there is nothing in DB_LIST. But It seems impossible, even it is an empty program.

Link to comment
Share on other sites

Here is a method I've used if you are looking for something "specific".

Using the get_ent I can have the system match up on what I am looking for; entity type(s), only items that are "alive", etc.

 

code:

#include "DbGet_ch.h"

 

// __ ScanArcs __

// Loads the supplieed vectors with the arc/circles in the database

// Returns: The number of arcs that where found

//

ulong ScanForArcs(std::vector<CArcEntity*>& vCircles,

std::vector<CArcEntity*>& vArcs)

{

DB_LIST_ENT_PTR ptr, found_ptr;

MC_BOOL succf;

ent entity;

ulong arc_count = 0;

ulong circle_count = 0;

CArcEntity *a; // CArcEntity is a 'package' Class to hold info about an Arc

 

hourglass_cursor();

ptr = db_start; // start at the beginning

for (;
;)
// Find all the ARC entities

{

get_ent (&ptr, &found_ptr, &entity, ALIVE_BIT, A_ID, &succf);

if (!succf) // No more arcs

{ break; }

 

arc_count++; // Count the total number of Arcs in the database (Full circle or not)

a = new CArcEntity(entity.eptr, entity.u.ar.r, entity.u.ar.view);

 

if (requal(fabs(entity.u.ar.sw), TWO_PI)) // Is it a "full" (360 deg) Circle?

{

vCircles.push_back(a); // Add it to the Full Circle list

}

else // It is an Arc segment"

{

vArcs.push_back(a); // Add it the the Arc segment list

}

} // looping thru the database - finding all arc entities

restore_cursor();

 

return arc_count;

}

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