How to create face with size relative to screen


when using the section tool the size of the “mouse pointer” (the blue square) has the same size relative to the screen regardless you are zoomed in or zoomed out.
zoom in:

zoom out:

I try to achieve the same effect when inserting a face with a tool. In which direction should I look to create a face depending og the screen size and not on xyz coordinate?

A face using X,Y,Z coordinates is in 3D model space not 2D screen space.

If you are drawing to screen space inside a tool, and need to account for display scaling on High DPI monitors, then have a look at:

and / or this:

There really isn’t a set “default zoom factor” per se. Although we could think of zoom to model extents as being a standard zoom factor of 1.0.

But you might need to know what the zoom setting is compared to a zoom extents when your tool begins. I’m not sure how to achieve this as this factor would change if the user changes the camera position (ie, by orbiting etc.)

You might just have to use an internal var in your tool and assume 1.0 when the tool begins.
Or use a standard like …

@scale = Sketchup.active_model.active_view.pixels_to_model(1,ORIGIN)

… or …

@scale = Sketchup.active_model.active_view.pixels_to_model(

You might need to temporarily attach a ViewObserver when your tool is activated to know whenever the view changes. (Be sure to detach it when your tool is deactivated.)

ok, thank you. I will try it out!