Calculate linear length of characters in text VBA

Calculate linear length of characters in text VBA

Anonymous
Not applicable
2,218 Views
7 Replies
Message 1 of 8

Calculate linear length of characters in text VBA

Anonymous
Not applicable
This problem I think is very complex because I need to calculate the ink plotter consumption based on the linear lenght of all objects on drawing, for example if I found a circle on drawing I obtain the perimeter, and if the drawing have one Arc I calculate or get the Arc Length in both case I obtain the linear length, but what append with the Text, how to calculate the linear length of each letter on autocad by VBA the letter are different(upper case and lower case(A, a), A-Z and a-z 0-9), the size is different too. Now I calculate the linear length of the others objects but the text, I couldn't. Edited by: Zeusovsky on Sep 17, 2009 6:34 PM
0 Likes
2,219 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
its more complex than that, im afraid. You didnt include line weights, raster images, solid fills, hatches, etc.... and that will throw the calculations off far more than a pall-parked text width.

if I had to tackle something like this, id probably try and estimate it by plotting it to a raster file format, and scanning the pixels of the resultant image. if its a strictly monochrome image, its just a matter of counting/perentages. if its greyscale, you'll probably want to apply different values to the different shaed of grey. Edited by: rocheey on Sep 21, 2009 1:08 PM
0 Likes
Message 3 of 8

Anonymous
Not applicable

In this case we don't have hatch, solid fills or diferents line weights, only the drawing and some notes, if is possible to convert the text in to lines, arcs and circles, maybe I could calculate.


Why is the reason, Ok We have arround 30 plotters working all the day(24/7) we use one program (CutWorks) for minimize the used material, we put for example 1000 drawings (*dxf) on the program and CutWorks minimize the used material(Nesting), like sort the drawings on the material.

The new drawing (Nesting) is send to plotter and each nesting have different length for example:
Nesting1: 5000 inches
Nesting2: 7800 inches
Nesting3: 4358 inches

but each nesting have differents details for example we can't use the time used by the plotter for complete the nesting1 because maybe the plotter are using more ink for complete the nesting1 that the ink used for nesting2 this depending of the details on the each drawing and for each nesting.

We have tried to estimate the consumption of ink by a ratio of the weight of the pen and avoids the time but not a correlation between weight and time to help us maximize the use of refilled cartridges for plotters.

So in this case we have a real relation and is to calculate the linear length of all the drawing, if we could calculate the linear length we could maximize the cartridges for the plotters(pen).

The technical specification for the pen (Cartridges) said it could be draw around of 50000 linear inches at specific velocity. If we know the linear lenght of each drawing on the nesting we could know if the plotter need other pen, the idea of "use the pen until the ink finish", interesting idea the problem is that the material could be damage if the ink finish. Each roll of material have a cost around of $15,000 dls.and the time for setup the plotter.

if is possible to convert the text in to lines, arcs and circles, this is the solution and I could estimate with more precision the ink consumption.

It's complex but I think this is possible. :-)

0 Likes
Message 4 of 8

Anonymous
Not applicable
Hi Zeusovsky,

You can't explode AutoCAD text.

The sorts of options you have are:
1 Follow "rocheey's" advice. To get meaningful refinement you would
need to do this for all characters in all fonts, then set up a database
containing the data. That way you could code to get the ink usage of a
character with an SQL query from the database.

2 With Font.SHX files, if you have access to the Font.SHP file, you
can read the length information from the character definition. Although
I haven't worked with these files sine the 1980's, I seem to remember
that the method of definition of the characters includes overlap. Again
you would need to do this for all the characters in all the fonts. Put
the results in a database as above.

With TTF fonts it is far less likely you will be able to access the font
definition, so the problem is more difficult and I have no suggestions.

3 Plot samples of the text and measure the ink usage. Again put
results in a database.

Note that all of these techniques are very labour intensive and you
would have to have very large ink wastage issues to warrant the
refinement you could get over doing an analysis of several hundred
typical drawings going through your system and then applying some averages.


Regards,


Laurie Comerford


Zeusovsky wrote:
> In this case we don't have hatch, solid fills or diferents line weights,
> only the drawing and some notes, if is possible to convert the text in
> to lines, arcs and circles, maybe I could calculate.
>
>
> Why is the reason, Ok We have arround 30 plotters working all the
> day(24/7) we use one program (CutWorks) for minimize the used material,
> we put for example 1000 drawings (*dxf) on the program and CutWorks
> minimize the used material(Nesting), like sort the drawings on the material.
>
> The new drawing (Nesting) is send to plotter and each nesting have
> different length for example:
> Nesting1: 5000 inches
> Nesting2: 7800 inches
> Nesting3: 4358 inches
>
> but each nesting have differents details for example we can't use the
> time used by the plotter for complete the nesting1 because maybe the
> plotter are using more ink for complete the nesting1 that the ink used
> for nesting2 this depending of the details on the each drawing and for
> each nesting.
>
> We have tried to estimate the consumption of ink by a ratio of the
> weight of the pen and avoids the time but not a correlation between
> weight and time to help us maximize the use of refilled cartridges for
> plotters.
>
> So in this case we have a real relation and is to calculate the linear
> length of all the drawing, if we could calculate the linear length we
> could maximize the cartridges for the plotters(pen).
>
> The technical specification for the pen (Cartridges) said it could be
> draw around of 50000 linear inches at specific velocity. If we know the
> linear lenght of each drawing on the nesting we could know if the
> plotter need other pen, the idea of "use the pen until the ink finish",
> interesting idea the problem is that the material could be damage if the
> ink finish. Each roll of material have a cost around of $15,000 dls.and
> the time for setup the plotter.
>
> if is possible to convert the text in to lines, arcs and circles, this
> is the solution and I could estimate with more precision the ink
> consumption.
>
> It's complex but I think this is possible. 🙂
>
0 Likes
Message 5 of 8

Anonymous
Not applicable
Looking at the -specific- drawing, and the -exact- parameters you describe, one could probably kludge it through using express tools: the "text explode" function, and then "overkill". (Text explode leaves a lot of duplicate and overlapping characters.)

These commands are, I believe, both lisp routines, and would be callable from VB.

But you'd have to remember that doing it this way could well be setup for failure: if you are already using questionable methods at a coding projects inception, many times you'll find that some time down the road, (maybe even in a week!) something will be changed, or added, to what is needed- and then suddenly your app will be useless.

Even something as simple as them using 'standard' windows fonts, instead of the acad 'line' type fonts.... exploding the text would only give you the outline, and not all the filled area.

But again, to kludge this specific instance through, id scan modelspace for anything that would not be the basic line, arc, or circle. Id then use the standard explode methods where I could (remembering that vb explode explodes to new geometry, and leaves the original intact),
then call the text explode function. Then overkill. If these -are- lisp routines, you'd have to hook an acad event, probably the lisp ended event, to know when each lisp routine ended.
0 Likes
Message 6 of 8

Anonymous
Not applicable
one way would be to record the plotter's ink usage, print a few thousand letter 'A's and see how much ink has been used for each 'A' and create a database that way.
0 Likes
Message 7 of 8

norman.yuan
Mentor
Mentor
Even you can calculate linear length of all entities (including texts) in a drawing, if these "linear" tracks have lots of overlaps, intersections (that is natural in a drawing, right), the calculated linear lenght may be quite different from the actual ink-painted linear track. Say, you have 10 lines (1mm in width when printed) all pass through one points (1x1 mm square, assuming), the ink-painted track at that point is 1mm long in 1 mm wide, while your calculated linear track should be 1x1mm x 10. So how useful the calculated linear lenght is here? Can you have fairly accurate estimate on the overlaps/intersections iin a drawing that makes your calculation useful or not useful? Not to mention to calculate text's linear lenght itself could be just as not reliable as one can imagine. Oh, text's linear track itself has a lot intersections/overlaps.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 8 of 8

Anonymous
Not applicable
well, id assumed what he said was correct, that line widths were not an issue.
as far as overlaps goes, that would hopefully be addressed by 'overkill'

and intersection points ... well, if you arent using line widths, then your lines are (effectively) a width of 0.0
which would make the intersection 'width' 0.0
0 Likes