Got it!
I suspected that the problem was that the normal vector's coordinates are expressed relative to the axes of the object.
Thank you for your explanations and your valuable advice.
Gerard
Got it!
I suspected that the problem was that the normal vector's coordinates are expressed relative to the axes of the object.
Thank you for your explanations and your valuable advice.
Gerard
Hi everybody,
I'm a beginner in the study sketchup API's.
I don't understand the following behavior: If I test the normal vector of a face before and after a rotation, it does not seem to change.
Here is my code:
ent = Sketchup.active_model.entities
face = ent.add_face [0,0,0], [1,0,0], [1,1,0], [0,1,0]
face.reverse!
face.pushpull 1
group1 = ent.add_group face.all_connected
puts face.normal
rot=Geom;;Transformation.rotation(Geom;;Point3d.new(0, 0, 0), Geom;;Vector3d.new(0, 1, 0), 30.degrees)
ent.transform_entities rot, group1
puts face.normal,"_______________________"
group1.entities.each{|e|
if e.typename =="Face"
puts e.normal
end
}
and here is the ruby console return:
load "Tests/testnormalvector.rb"
(0.0, 0.0, -1.0)
(0.0, 0.0, -1.0)
_______________________
(0.0, 0.0, -1.0)
(0.0, 0.0, 1.0)
(0.0, -1.0, 0.0)
(1.0, 0.0, 0.0)
(0.0, 1.0, 0.0)
(-1.0, -0.0, -0.0)
true
The normal vector still point to the same direction. If I loop on each faces.normal of my object, the results are the same as if there was no rotation.
Have I missed something?
My goal is to rotate gradually an entity and stop the rotation when the normal vector of a reference face reaches a certain direction.
I'm using Sketchup 7 pro.
Thank you in advance
Gerard
Hello,
I think I found where the problem lies:
After testing many variations to my formulas, without success, I had the idea of changing the internal units of the component.
Being Belgian, I naturally use metric units, so my component was configured with "cm".
So I converted all numeric values in inches and reconfigured the component to use same unit.
Miraculously, everything works now as expected , even when using the component in a model configured in metric units.
I think there's a bug in the function CURRENT("LenX/Y/Z") which should return a value expressed in inches, whatever the choice of internal units.
Well, I hope my experience will serve the other!
Thank you for your attention,
Gerard
Hello,
I'm trying to create a dynamic component whose length and width are limited to a maximum value, and whose thickness is fixed .
I used the following formulas
LenX; =SMALLEST(60, CURRENT ("LenX"))
LenY; =SMALLEST(120, CURRENT ("LenY"))
LenZ; = 2
Scaling handles are limited to the X and Y axes.
When I resize the component by using the handles or by typing a numeric value, the result is completely erratic.
The component is always resized, and not at the size, and in different dimensions than those I imposed, even if I chose dimensions lower than allowable maximum size.
And finally, the component is always resized on both axes, while I can only act on one axis at a time.
I also tried another formula, with the same result:
= IF (CURRENT ("LenX")> 60,60,CURRENT ("LenX"))
I would be grateful if you could tell me why it does not work, or give me some tips to achieve the goal sought.
Thank you in advance
Gerard