- I’m writing a program inruby to lay out components on a surface，but I couldn’t predict the coordinates of that surface and its orientation and inclination by ruby. * What should I do or how should I write the program？
Can you show us what you have so far? Relevant (minimal) code snippet. Screenshots. Example models.
Also some illustration of what you are trying to achieve.
When you say ‘surface’ do you mean a ‘face’ or several faces combined into a complex surface - like a landscape ?
A single face has vertices and loops, the outer_loop gives you the points around the face.
Also face.bounds gives you the outer limits of the face within a bounding box.
A face.normal vector also indicates the face’s ‘angle’ with the main three planes of the model XYZ…
For example, in this picture, I want to lay out the components on the inclined plane, but I can only lay out the components with all the information of him, but in the actual project, he can’t tell me the details. How can I get the information of this plane by myself through ruby language
It depends on your script input, but assuming that this is the model you can write something like this :
reference_face = Sketchup.active_model.entities.grep(Sketchup::Face) reference_face.plane
Now you also have the
Sketchup::Face.vertices method that alows you the get the plane boundaries.
I don’t understand it,the code is short,could you please give me an example, just like I select a face ,and then I get the coordinate by using the code.Thanks again!
Ok if you want to retrieve the face coordinates you can use this (assuming that your face and only your face is selected) :
If not only your face is selected you will have to filter your selection first and then retrieve the vertices positions.