SketchUp / api-issue-tracker

Public issue tracker for the SketchUp and LayOut's APIs
https://developer.sketchup.com/
39 stars 10 forks source link

PDF Export on Windows not supporting custom size #519

Open Eneroth3 opened 4 years ago

Eneroth3 commented 4 years ago

In both SketchUp 2018 and 2019 this code snippet generates PDFs at various sizes. In SU 2020 they are all identical.

dir = UI.select_directory

Sketchup.active_model.export(
  "#{dir}/100.0.pdf",
  {
    height_units: Length::Inches,
    window_height: 100.0
  }
)
Sketchup.active_model.export(
  "#{dir}/10.0.pdf",
  {
    height_units: Length::Inches,
    window_height: 10.0
  }
)
Sketchup.active_model.export(
  "#{dir}/1.0.pdf",
  {
    height_units: Length::Inches,
    window_height: 1.0
  }
)
Sketchup.active_model.export(
  "#{dir}/0.1.pdf",
  {
    height_units: Length::Inches,
    window_height: 0.1
  }
)

Have the keywords changed recently? I've also tried image_height, imageHeight and any other keyword I can think of but to no avail.

thomthom commented 4 years ago

Is this Windows or Mac?

thomthom commented 4 years ago

I ran the two first export examples, and Adobe Acrobar indicates matching document heights...

image

image

How are you verifying the sizes?

sketchupbot commented 4 years ago

Logged as: SU-46985

Eneroth3 commented 4 years ago

I am extremely confused. It works today. Not sure why it didn't the other day. Must have had the files locked or some other error. Closing this issue.

Eneroth3 commented 4 years ago

I'm not mad! I've been able to successfully reproduce this with the exact code above, but only in parallel projection.

It appears to also be an issue in SketchUp 2019, but with a slightly different behavior.

When running the script in 2019 I get this result when opening one of the resulting PDFs in Adobe Reader. Weird warning and icon not centered in the image.

2020-08-24_13h35_33 2020-08-24_13h35_39 2020-08-24_13h42_47

When running the same code in 2020, I get this result. The icon is now centered as it should be.

2020-08-24_13h42_07 2020-08-24_13h42_02

In both 2020 and 2019, the image height value is completely ignored and all 4 PDFs get the same height (although this value differs between the two versions).


For now I can probably use a perspective with a tiny fov and get something that mimics a parallel projection well enough not to be noticed, but in the long run it'd be nice to have this fixed.

I'd expect the image height parameter to set the scale for the generated 2d view, regardless of it being a perspective or parallel projection. In addition to my little icon pipeline, this would be highly useful to output scale drawings.

Eneroth3 commented 4 years ago

It appears to be a separate set of parameters used in parallel projection. With no proper error messages it is hard to figure this out, especially with no access to the code and no ability to read when what parameters are actually referenced.

More code examples would be very useful, but ideally there should also be a Ruby warning (or possibly an exception but it could break old extensions) when passing image_height for a parallel projection view, length_in_model and length_in_drawing when in perspective etc.

Matherone commented 4 years ago

Seconding Eneroth3's request. Fixing this would be useful.

It would enable e.g. a Sketchup extension for dependably turning Sketchup models into vector icons for use in Sketchup extensions - doogfooding at its finest.