Layout model_to_paper_point is not correct after changing model scale

The model_to_paper_point gives wrong points after changing the model scale. It looks like model_to_paper_point doesn’t take the scale into account.
Is this a bug in the layout api?

bounds = Geom::Bounds2d.new(10.mm, 10.mm, 410.mm, 287.mm)
model = Layout::SketchUpModel.new(Sketchup.active_model.path, bounds)
model.preserve_scale_on_resize = true
model.display_background = false
model.scale = 0.02
model.model_to_paper_point(Geom::Point3d.new(0,0,0))

A couple of questions …

  1. You did not tell us the results

    a. What is the returned 2D point "before" ?
    b. What is your expectation for afterward ?
    c. What is the unexpected result ?
    
  2. Do you need to re-render the model viewport after making changes ?
    Ie, check render_needed?

      model.render if model.render_needed?
    
  3. Does the render mode make any difference ?
    Ie, would Vector be more precise than say Raster ?

  4. Is scaling and resizing synonymous ?

    • I’d think that resizing is the changing of the LayOut 2D viewport’s bounds.
      But don’t see a via the LayOut API to modify the model viewport’s bounds once created.

    • I’m speculating that changing the scale may not be the same as “resizing”.

    • Also, I wonder if the model is positioned within the viewport anchored from it’s origin.
      Ie, your testing the model’s 3D origin, and I wonder if the lack of change is correct ?
      Or, perhaps the model is positioned using the center of the model’s view ?

1 Like

model.render if model.render_needed? did the trick. The api is not very clear about this.

1 Like