How to leave a mark d'water in an object or wall

sketchup

#1

Good day, I have a job in college and need to put a &Quot;mark d’water" on a wall or object, to signal that that object/wall was already modified.

Anyone know any Ruby API the code that do this? I managed to leave this mark on the floor, but I would like to put on the wall and/or object.

Thank You


#2

The easiest way might be to create a component with glue-to set to “Any” but not “cuts opening”. You can then place an instance of this component on any face you want to mark.


#3

Hello SIbaumgartner, thank you for your response.
I tried to first use this code:

model = Sketchup.active_model
path = "Plugins"
image_file = Sketchup.find_support_file(“c.jpg”, path)
image = model.active_entities.add_image(image_file, ORIGIN, 30)

And then the Face.get_glued_instances
but the two code only the image on the floor and I can’t take to the walls.


#4

Images are strange beasts that are confusing to manipulate via the Ruby API. I’m not where I can write and test sample code just now, but the general idea is:

  • add the image as you have done
  • create a sequence of Geom:Transformations that moves and rotates the image appropriately to place it in front of the target Face
  • use image#transform! to put the image in the required place

There are lots of gotchas along the way that the basics above don’t elaborate.

When first imported, the image’s upper left corner will be at the point you used in add_image and it will always lay flat on the red-green plane.

You will likely want to place the image’s center point at the center of the Face. The image’s initial center point is at (image.width/2, image.height/2, 0). You can find the geometric center of a Face by, for example, ctr=face.bounds.center. So you need to move the image using a translate Transformation based on the Vector3d from the image center to the face center.

Then you will want to rotate the image about its center and the appropriate axis to align it with the face. If you are doing walls, these rotations will most likely be purely around the X_AXIS or Y_AXIS depending on the direction of the wall’s normal.

Finally, SketchUp has a perverse habit of putting the image onto the back of a face, where it looks reversed. To get it showing on the front, translate it a small amount along the Face’s normal so that it comes proud of the surface.


#5

Thank you Slbaumgartner!!

it helped a lot