I am using entmake to create a line but I want the transparency to be a percentage. I know that the (440 . xxxxxx) dotted pair controls transparency. I don't understand the number that has to be used with 440. Does anyone know what numbers to put in for different transparencies?
Thanks,
BRO
@bro2g wrote:I am using entmake to create a line but I want the transparency to be a percentage. I know that the (440 . xxxxxx) dotted pair controls transparency. I don't understand the number that has to be used with 440. Does anyone know what numbers to put in for different transparencies?
....
I don't have a new-enough version to be able to give Lines transparency, but I would suggest that you draw some Lines, give them a range of different transparencies by whatever means you can do that, and just look at the 440-code values in their entity data. Presumably some kind of relationship to the values you've used, or perhaps the range of valid values, should be apparent.
bro2g,
as Kent Cooper wrote
looking at the 440-code values, we have
one percent = 33554684
ninety percent = 33554457
maybe something like this
(setq num 10);the desired percentage
(setq num1 (fix (- 33554687 (/ (* num 227) 89))))
Henrique
Unless you must use DXF values, I would suggest using activeX which has a more direct and readable value.
(vla-put-entitytransparency <object> "40") ;40% transparency.
@hmsilva wrote:....looking at the 440-code values, we have
one percent = 33554684
ninety percent = 33554457
maybe something like this
(setq num 10);the desired percentage
(setq num1 (fix (- 33554687 (/ (* num 227) 89))))....
That is indeed a mysterious system. It makes me wonder -- it may not be a linear relationship. I would guess if it were, it could be a lot more straightforward and obvious. But maybe it's logarithmic, or has some other basis [like the trigonometric basis for the 42-code bulge factor for Polyline arc segments]. If it's not linear, that kind of calculation won't always get the right answer.
It should be easy enough to check [for someone with a recent-enough version of AutoCAD]. What are the values for 0% and 100%, if those are both valid settings? Is the value for 50% exactly half-way between those, or if those aren't both valid, half-way between the values for 10% and 90%? Is the difference in value for any, say, 10% difference in transparency the same all the way along, i.e. is the difference between the values for 5% and 15% the same as that between 45% and 55% and between 85% and 95%?
Kent Cooper wrote:
It should be easy enough to check [for someone with a recent-enough version of AutoCAD]. What are the values for 0% and 100%,
if those are both valid settings? Is the value for 50% exactly,,,
I tested for various percentages and
the maximum error is one.
Henrique
EDITED
the valid values are from 1% to 90%.
The rhythm for 10% is about 25, sometimes 26 and another 24,
therefore approximately 2.5 per 1%,
Minimally tested for 1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 60, 70, 80 and 90%
Henrique
@hmsilva wrote:...
I tested for various percentages and
the maximum error is one....
The rhythm for 10% is about 25, sometimes 26 and another 24,
therefore approximately 2.5 per 1%,....
Being no more than one off out of about thirty-three-and-a-half million is rather remarkable accuracy! It does make me really wonder, though, why it's done that way, rather than in some more pedestrian way.
Its not truly 33 1/2 mil. all the numbers start with 33554 (i think).
1% = 684
90% = 457 (I couldnt get it to go past 90%)
Maybe the OP can create his entity then chprop the last entity's transparency.
Or use vla-put-EntityTransparency on it.
I think you can use a percent number for both of these.
I understand this is an extra step.
Rick
Kent,
with
(setq num 10);the desired percentage
(setq num1 (fix (- 33554686 (/ (* num 227) 89))));changed from 33554687 to 33554686 for more accuracy
I get:
%----from AC----by code
1----33554684----33554684
2----33554681----33554681
3----33554679----33554679
4----33554676----33554676
5----33554674----33554674
10---33554661----33554661
20---33554636----33554635
30---33554610----33554610
40---33554585----33554584
50---33554559----33554559
60---33554534----33554533
70---33554508----33554508
80---33554483----33554482
90---33554457----33554457
How the original numbers are generated?
Is too much for me!!!
Henrique
Even forgetting the 33-1/2 million size of the full-length numbers, and considering only the range in values between the extremes, being off by 1 out of 227 is still pretty good -- less than 1/2 of 1% off. I can't imagine that the difference in appearance could possibly be detectable. I would still love to know what those first 5 digits that are the same in all values are accomplishing.
Kent Cooper wrote:
...I would still love to know what those first 5 digits that are the same in all values are accomplishing.
is puzzling!
Henrique
The high byte is the transparency method (0 = ByLayer, 1 = ByBlock, 2 = ByAlpha), the low byte is the alpha value from 0 to 255.
Owen Wengerd wrote:
The high byte is the transparency method (0 = ByLayer, 1 = ByBlock, 2 = ByAlpha), the low byte is the alpha value from 0 to 255.
I Owen,
Is possible to explain me little more?
Thanks
Henrique
@Kent1Cooper wrote:Even forgetting the 33-1/2 million size of the full-length numbers, and considering only the range in values between the extremes, being off by 1 out of 227 is still pretty good -- less than 1/2 of 1% off. I can't imagine that the difference in appearance could possibly be detectable. I would still love to know what those first 5 digits that are the same in all values are accomplishing.
Acording to DXF reference, code 440 holds a 32 bit integer and the high-order byte (8 bits) is 2.
That is hexadecimal 0x02000000 and decimal 33554432.
To represent transparency, to this value is added a number between 0 (100% transparency) and 255 (0% transparency). (well, you can't set a transparency higher than 90% so the minim value, coresponding to 90%, is 25)
You can get this value by interpolating linear for n% transparency: x = integer(255-n*255/100)
For demonstration, look at this lisp:
(defun C:TEST ( / e n) (if (and (setq e (car (entsel))) (setq n (getint "\nTransparency: ")) (<= 0 n 90) ) (entmod (append (entget e) (list (cons 440 (+ (lsh 2 24) (fix (- 255 (* n 2.55)))))) ) ) ) )