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:

Adding a note with chook


Recommended Posts

Have a look at the v8_note structure in m_dfvars.h:

 

code:

typedef struct              /* structure for notes */

{

byte type; /* 0=witness, 1=leader, 2=label, 3=note */

p_3d ref_pt; /* reference point (text in view) (Z=depth) */

short view; /* view number that note was created in */

real scale; /* internal scale for detail view */

font_attr params; /* font attributes */

ulong mtid; /* memory table index (allocated string) */

v8_wit_ldr ldr; /* leader/witness associated with entity */

eptr_type xptr; /* conversion pointer: note (always null_eptr) */

boolean assoc; /* this entity uses associativity */

p_3d txtpos; /* incremental position used to regenerate note */

short ldr_count; /* number of leaders */

byte pad[2]; /* pad to 8 bytes "none" */

} v8_note;

Or better yet, create an label entity:

 

code:

ent label_ent;   // an entity var

 

InitNOTE(&label_ent); // it's gonna be a note

 

// add structure fields to label_ent.u.n...

 

// store entity with store_ent()

Link to comment
Share on other sites

No, but I did find this, which is what I need but how do I use it.

 

typedef struct

{

char comment[MAX_MANUAL_ENTRY + 1];

short source; // 0=operation, 1=external text file

short save; // 0=save in mc8, 1=read at post time

long file_size; // file size

short gcode; // 1005, 1006 or 1007

byte pad[40];

} prm_manual_entry;

 

 

Girus

Link to comment
Share on other sites

Hi,

 

Here is where I am and I am having problems.

 

This is a small sample of code that I am using.

 

operation op_me_note; // manual entry.

db_ptr_type d_ptr;

 

 

op_me_note.op_idn = 1;

op_me_note.slot = 1;

op_me_note.opcode = TP_MANUAL_ENTRY;

 

strcpy (op_me_note.u.manual_entry.comment, "This is a test");

op_me_note.u.manual_entry.source = 0;

op_me_note.u.manual_entry.save = 0;

op_me_note.u.manual_entry.gcode = 1006;

 

 

 

operation_manager (

&op_me_note, // IO: pointer to operation

OPMGR_ADD, // I: OPMGR_ADD, OPMGR_EDIT, etc

&d_ptr, // O: db pointer to operation entity

&succf); // O: operation manager successfull

 

 

While it does create an operation and shows the the note, it seems like it also has grabage characters after the "this is a tes" message.

 

I dont know exactly how ot initialize an operation? Maybe someone can help me out.

 

TIA.

 

Girus

Link to comment
Share on other sites

Never mind I solved the issue with this.

 

memset( &op_me_note,0,sizeof(operation));

 

but should I be doing this:

 

op_me_note.op_idn = 1;

op_me_note.slot = 1;

 

I dont know if I have to or not? In other words how much stuff do I need to initialize the operation?

 

Girus

Link to comment
Share on other sites

How about copying the string in a safer manner like this:

 

code:

char szTestString[] = "This is a test";

 

// strncat automatically adds the null char to the end (strncpy doesn't)

strncat(op_me_note.u.manual_entry.comment, szTestString, strlen(szTestString));

Does that still produce garbage characters?

 

[ 06-24-2004, 11:38 AM: Message edited by: Bullines ]

Link to comment
Share on other sites

quote:

but should I be doing this:

 

op_me_note.op_idn = 1;

op_me_note.slot = 1;

 

I dont know if I have to or not? In other words how much stuff do I need to initialize the operation?


In my experience, the majority of the members of the various structures in the SDK are initialized to global defaults. So your best bet is to initialize all the members that you need. The more the merrier, so to speak smile.gif

Link to comment
Share on other sites

Here is a quick and dirty routine that I created to handle this. It does not have all of the protection code that I would like to see.

 

code:

static void make_manual_entry( 

char *szString ){

 

 

boolean succf;

operation op_me_note; // manual entry operation.

db_ptr_type d_ptr;

 

 

 

memset( &op_me_note,0,sizeof(operation));

//op_me_note.op_idn = 1;

//op_me_note.slot = 1;

op_me_note.opcode = TP_MANUAL_ENTRY;

 

operation_manager (

&op_me_note, // IO: pointer to operation

OPMGR_INIT, // I: OPMGR_ADD, OPMGR_EDIT, etc

&d_ptr, // O: db pointer to operation entity

&succf); // O: operation manager successfull

 

// the following operation is necessary because when a second call to

// opereation_manager is made with the OPMGR_INIT it atomatically picks up the

// previous manual entry text. And if the current text has shorter text it will

// end up over the old text and part of the old text will still show in the NC code.

memset( &op_me_note.u.manual_entry.comment,0,sizeof(op_me_note.u.manual_entry.comment));

 

 

strncpy (op_me_note.u.manual_entry.comment, szString, strlen(szString));

op_me_note.u.manual_entry.source = 0;

op_me_note.u.manual_entry.save = 0;

op_me_note.u.manual_entry.gcode = 1006;

 

 

operation_manager (

&op_me_note, // IO: pointer to operation

OPMGR_ADD, // I: OPMGR_ADD, OPMGR_EDIT, etc

&d_ptr, // O: db pointer to operation entity

&succf); // O: operation manager successfull

 

}

I placed this here for anyone who may want to do something similar.

 

Girus

Link to comment
Share on other sites
  • 19 years later...
On 6/24/2004 at 6:34 PM, Girus said:

Here is a quick and dirty routine that I created to handle this. It does not have all of the protection code that I would like to see.

 

 

 

code:

static void make_manual_entry( 

 

char *szString ){

 

 

 

 

 

boolean succf;

 

operation op_me_note; // manual entry operation.

 

db_ptr_type d_ptr;

 

 

 

 

 

 

 

memset( &op_me_note,0,sizeof(operation));

 

//op_me_note.op_idn = 1;

 

//op_me_note.slot = 1;

 

op_me_note.opcode = TP_MANUAL_ENTRY;

 

 

 

operation_manager (

 

&op_me_note, // IO: pointer to operation

 

OPMGR_INIT, // I: OPMGR_ADD, OPMGR_EDIT, etc

 

&d_ptr, // O: db pointer to operation entity

 

&succf); // O: operation manager successfull

 

 

 

// the following operation is necessary because when a second call to

 

// opereation_manager is made with the OPMGR_INIT it atomatically picks up the

 

// previous manual entry text. And if the current text has shorter text it will

 

// end up over the old text and part of the old text will still show in the NC code.

 

memset( &op_me_note.u.manual_entry.comment,0,sizeof(op_me_note.u.manual_entry.comment));

 

 

 

 

 

strncpy (op_me_note.u.manual_entry.comment, szString, strlen(szString));

 

op_me_note.u.manual_entry.source = 0;

 

op_me_note.u.manual_entry.save = 0;

 

op_me_note.u.manual_entry.gcode = 1006;

 

 

 

 

 

operation_manager (

 

&op_me_note, // IO: pointer to operation

 

OPMGR_ADD, // I: OPMGR_ADD, OPMGR_EDIT, etc

 

&d_ptr, // O: db pointer to operation entity

 

&succf); // O: operation manager successfull

 

 

 

}

I placed this here for anyone who may want to do something similar.

 

Girus

Hello, I am searching to create a Manual Entry Operation. I have tried this code and it doesnt work, Is it for C# or C++.

I am using C# and I need the code for create a Manual entry Operation.

Can you help me. Peease.

Link to comment
Share on other sites
23 hours ago, eltklas said:

Hello, I am searching to create a Manual Entry Operation. I have tried this code and it doesnt work, Is it for C# or C++.

I am using C# and I need the code for create a Manual entry Operation.

Can you help me. Peease.

That looks like C++ 

I could be wrong, but I don't think manual entry is supported in C#.

Link to comment
Share on other sites

I cannot understand that the information page about chooks does not have access to information in C++ but it does have access to C# and .Net.  Is it payment information?  How can I access it?

Thanks for answer.

Link to comment
Share on other sites
2 minutes ago, eltklas said:

I cannot understand that the information page about chooks does not have access to information in C++ but it does have access to C# and .Net.  Is it payment information?  How can I access it?

Thanks for answer.

Sounds like you're on the wrong page. You can find chook samples and the sdk here:

my.mastercam.com > Communities > 3rd Party Developers > C++ Downloads

If you do not have access to this page you can email [email protected] to request access

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