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:

Letters from C-hook


Recommended Posts

I am trying to replicate "Create Letters" functionality in a C-hook. I did not find a simple function to do that, but after fiddling around with other functions, I was able to do it for "MCX" fonts (Block, Box, Roman and Slant) - I found a geometry file for each glyph in the Mastercam installation directory. But I would like to do the same thing for "Drafting" fonts for which I could not find the definition files - CNC either hid them well or they are somehow embedded into some of the other Mastercam files. It would be nice to be able to handle TrueType font too, but at least in theory I could do that: just interprete the curve and lines commands (hey, I did not say that was easy, just possible!). Of course, a preffered way would be to use a function Mastercam is using itself, assuming they exported it!

 

So, my question is simple:

a) Is there a function that I have missed that would create geometry from letters of a given font? I am not asking how to create notes which are entities of their own, but geometry (lines, arcs, splines) that form glyphs.

B) If a) is not available, is there a geometry file that I can read and import myself for "Drafting" fonts?

Link to comment
Share on other sites

Greetings, biggrin.gif

 

I also could not find the function like what you said, though I did not ask CNC guys for the function,

and I have made a chook like you are trying to make now.

 

In my chook , I read the bezier spline curve data from a .ttf or .ttc file, and break it into pieces of lines.

And I have also made a centerline/stroke font data in my own format.

 

if you use read_ent/write_ent_to_disk functions, you can read/write geometry entity from/to a file anyway.

(but the file is not compatible with previous version of mastercam..)

 

And there are also .FNT files in C:mcamxcommonfonts folder,

but I dont know the file format for it,

and I hope there is a file format description for it. smile.gif

Link to comment
Share on other sites

That (read_ent) is exactly what I did to create a geometry with "MCX" fonts. And what you did with TTF fonts is exactly what I was reffering to in my original post as "not easy" because I would need to analyze the file format. But at least TTF is fully documented if I ever need to do that. But I am facing the request for "Drafting" fonts that do not seem to be available as the standalone geometry files.

 

I do not know what "*.FNT" files are, but I highly doubt that those are the fonts I need.

Link to comment
Share on other sites
  • 1 month later...

------

"...Is there a function that I have missed that would create geometry from letters of a given font?..."

------

 

Markov,

 

You can add the following prototype to the exported, but non-documented drw_string() function which is exported from MCCore.Lib.

 

extern DllImpExp void drw_string (

p_3d ref_pt,

short view,

font_attr *attr,

real width,

MC_BYTE color,

MC_BYTE dds_mode,

MC_BYTE *string);

 

If you havethe text stored in a Mastercam note entity, call it as follows…

 

MC_BYTE *t = (MC_BYTE *) mTableFindData (entity->u.n.mtid);

 

drw_string (entity->u.n.ref_pt, entity->u.n.view, &entity->u.n.params, entity->a.width,

main_color, 1, t);

 

 

If you don’t have a note entity, do this…

 

font_attr params;

init_attribs_note (&params);

p_3d ref_pt; // set this to the position it should be drawn at

char t[100]; // or whatever the size should be – replace this with a malloc/calloc if you want

// set this to the string text

 

drw_string (ref_pt, 1, &params, 1.0, main_color, 1, (MC_BYTE*)t);

 

Setting the ‘dds_mode’ to 1 will cause the entities to be created, whereas 0 will simply draw the text.

The font_attr .font field is a number which matches the list of loaded fonts seen in Config/NoteText or Config/DimensionText

Link to comment
Share on other sites

Pete,

 

I'm trying to create the 'top of arc', 'bottom of arc', 'arc radius' of the create letters with drw_string. I tried setting the .path var of font_attr to 4 - arc cw, and 5 - arc ccw and (arc) .center, but it's not working. Do you know what the correct params are for setting this?

 

Bryan smile.gif

Link to comment
Share on other sites

Thanks Pete,

 

doh! headscratch.gif

font_attr in 3dvars_ch.h had the 4 and 5 values that way.

 

The 6 and 7 values seem to work better but I get some a spiraly type pattern. How do I get a result like the point/radius of create letter?

 

It looks like the only thing that I sould have to set beyond calling init_attribs_note is the .path (6/7) and .center values. But I seem to be missing something. frown.gif

 

Bryan smile.gif

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