What's new

Question about SetColor and DistanceTo

idslk

Alibre Super User
When I use print MyPart.GetColor()
I get the result: color [A = 255, R = 128, G = 128, B = 255]
If i want to change values an set them i can't get SetColor() to work.
I'm happy when someone tells me how SetColor() works.
Color_Tip.JPG

If I have two faces that are symetric to a plane and I use
CP.GetFace ('FaceAboveXYPlane'). DistanceTo (CP.GetFace ('FaceBelowXYPlane'))
I get a result of 0.0. Is this intended? Seems to be a kind of + distance + (- distance) = 0.
When I measure two faces on the same side of the plane, I get the expected result.
Am I doing something wrong?

thank you in advance
Stefan
 
When I use print MyPart.GetColor()
I get the result: color [A = 255, R = 128, G = 128, B = 255]
If i want to change values an set them i can't get SetColor() to work.
I'm happy when someone tells me how SetColor() works.

I just tried SetColor() and it worked. This is what I tested:
Code:
P = CurrentPart()

P.SetColor(55, 55, 55)

If I have two faces that are symetric to a plane and I use
CP.GetFace ('FaceAboveXYPlane'). DistanceTo (CP.GetFace ('FaceBelowXYPlane'))
I get a result of 0.0. Is this intended? Seems to be a kind of + distance + (- distance) = 0.
When I measure two faces on the same side of the plane, I get the expected result.
Am I doing something wrong?

I have not used those commands but your theory on them 'canceling out' makes sense to me. It seems you need to do 2 separate distances to the plane then add them together using absolute value to convert the negative to positive. Do this by surrounding it with abs(negative number).

Of course this all depends on the rest of the code and what it needs to do. Can you post more code?
 

idslk

Alibre Super User
Thank you for your response,

i've tried SetColor() again, and it worked also for me -- don't know what i've been doing wrong, anyway it's okay for me now :)
Thank you.

The DistanceTo() function accepts only faces (regarding the reference manual). So it seems not possible to measure against a plane.
If you take a look into https://www.alibreforum.com/forum/index.php?threads/sample-script-cut-keyway-in-shaft.20587/ you will see what i have done to get dimensions.
If you have good ideas, i will appreciate them...

Regards
Stefan
 

ajayre

Alibre Super User
If I have two faces that are symetric to a plane and I use
CP.GetFace ('FaceAboveXYPlane'). DistanceTo (CP.GetFace ('FaceBelowXYPlane'))
I get a result of 0.0. Is this intended? Seems to be a kind of + distance + (- distance) = 0.
When I measure two faces on the same side of the plane, I get the expected result.
Am I doing something wrong?

Works OK for me. Attached is my test part. Face<6> is 10mm above the XY-Plane and Face<12> is 10mm below the XY-Plane. The script prints out "20.0".

Code:
P = CurrentPart()
F1 = P.GetFace("Face<6>")
F2 = P.GetFace("Face<12>")

print F1.DistanceTo(F2)
print F2.DistanceTo(F1)

Andy
 

Attachments

  • DistanceTo.AD_PRT
    260 KB · Views: 4

idslk

Alibre Super User
Hello Andy,

thank you for your reply.Can't load your file, you're on a newer version than me ;-) (i'm on 19.1.1.19055)
I've build a own file (constrain symetric), adjusted the faces and:
DistanceTo.JPG

Sorry, but result stays at 0.0

Regards
Stefan
 
Top