Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

dotted pairs

15 REPLIES 15
Reply
Message 1 of 16
bro2g
737 Views, 15 Replies

dotted pairs

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

15 REPLIES 15
Message 2 of 16
Kent1Cooper
in reply to: bro2g


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

Kent Cooper, AIA
Message 3 of 16
hmsilva
in reply to: bro2g

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

EESignature

Message 4 of 16
dbroad
in reply to: bro2g

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.

Architect, Registered NC, VA, SC, & GA.
Message 5 of 16
Kent1Cooper
in reply to: hmsilva


@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, AIA
Message 6 of 16
hmsilva
in reply to: Kent1Cooper

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

EESignature

Message 7 of 16
hmsilva
in reply to: Kent1Cooper

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

EESignature

Message 8 of 16
Kent1Cooper
in reply to: hmsilva


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

Kent Cooper, AIA
Message 9 of 16
Rick-K
in reply to: Kent1Cooper

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

Message 10 of 16
hmsilva
in reply to: Kent1Cooper

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

EESignature

Message 11 of 16
Kent1Cooper
in reply to: hmsilva

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, AIA
Message 12 of 16
hmsilva
in reply to: Kent1Cooper

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

EESignature

Message 13 of 16
owenwengerd
in reply to: hmsilva

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
ManuSoft
Message 14 of 16
hmsilva
in reply to: owenwengerd

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

EESignature

Message 15 of 16
phanaem
in reply to: Kent1Cooper


@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))))))
        )
      )
    )
  )

 

Message 16 of 16
hmsilva
in reply to: phanaem

phanaem,
great explanation.

 

Thank you very much.

 

Henrique

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost