SketchUp 2027: vector PDF export loses foreground faces (GUI and Ruby; 2026 works)
In this small scene, SketchUp 2026 exports correctly, while SketchUp 2027 exports only the purple board, omitting the pyramid and geometric text. The viewport and PNG export remain correct.
The issue occurs with both manual GUI export and Ruby Model#export. It was also reproduced on a second computer.
Environment and sample
-
Windows builds: SketchUp 2026 26.2.243 / SketchUp 2027 27.0.267.
-
Opaque, solid-colored faces and geometric text in copied/nested groups with four active section planes.
-
The purple board is a real model face. No textures or transparency are involved.
-
PDF pages are approximately 340 × 211 mm. No proprietary model or business extension is required.
Steps to reproduce
-
Start SketchUp 2027 with a new, empty model. Remove the default person and any existing geometry.
-
Run the attached
export_pdf_ruby.rbin the Ruby Console or Ruby Code Editor. It creates the sample scene and automatically exports one PDF. -
After the script finishes, also try exporting manually through File > Export > 2D Graphic > PDF, using full scale (1:1).
-
Open the exported PDFs: both contain only the purple board, although the foreground remains visible in SketchUp and in the exported PNG.
-
Run the same script in an empty SketchUp 2026 model for comparison: the exported PDF includes the text and pyramid correctly.
The reproduction script was generated using GPT-6.1 Sol (Extra High reasoning). The export behavior described here was tested in SketchUp.
Expected result
The PDF contains the purple board, white geometric text, and colored pyramid.
Actual result
In SketchUp 2027, the PDF contains only the purple board. The Ruby export call returns true despite the missing foreground.
Impact
This blocks material-colored vector elevation and fill output in our CAD/BIM workflow. PNG cannot replace the required vector faces.
Could the SketchUp team investigate this regression and suggest a workaround that preserves vector face fills?
MyCode
export_pdf_ruby.rb (17.3 KB)
# encoding: UTF-8
# Windows SketchUp 2026 / 2027: run in a NEW EMPTY model (remove default person).
# Ruby Console: load 'D:/your/path/export_pdf_ruby.rb'
# Ruby Code Editor: execute this entire file. Stop: ExportPdfRuby.stop!
# One native vector PDF, then PNG / SKP / TXT / JSON under Desktop/TS_Debug.
# No business plugin, API interception, PDF rewriting or automatic retries.
# A successful API return or a small PDF does NOT determine reproduction/root cause.
require 'json'
require 'time'
require 'fileutils'
unless defined?(ExportPdfRuby::VERSION)
module ExportPdfRuby
VERSION = '1.0.0'
OWNER = 'export_pdf_ruby'
MM = 1.0 / 25.4 # Native SU coordinates are inches, regardless of template units.
RENDER = {'RenderMode'=>2, 'EdgeDisplayMode'=>0, 'EdgeColorMode'=>0,
'DrawSilhouettes'=>false, 'DisplayColorByLayer'=>false, 'DrawHidden'=>false,
'DisplaySectionCuts'=>true, 'DisplaySectionPlanes'=>false,
'SectionCutDrawEdges'=>true, 'SectionCutFilled'=>true}.freeze
SHADOW = {'UseSunForAllShading'=>true, 'Light'=>0, 'Dark'=>80, 'DisplayShadows'=>false}.freeze
class << self
attr_reader :current
def clock; Process.clock_gettime(Process::CLOCK_MONOTONIC); end
def desktop
return File.join(Dir.home, 'Desktop') unless Sketchup.platform == :platform_win
require 'win32ole'
path = WIN32OLE.new('WScript.Shell').SpecialFolders('Desktop').to_s
raise '系统桌面路径为空' if path.empty?
path
end
def run
if @current && !@current.done?
puts '[export_pdf_ruby] 本轮仍在运行,不重复启动;可用 ExportPdfRuby.stop! 停止。'
return @current
end
raise '请在 SketchUp Ruby 控制台或 Ruby Code Editor 中执行' unless defined?(Sketchup::Model)
model = Sketchup.active_model
raise '请退出组/组件编辑,再新建空白模型运行' if model.active_path
raise '请新建空白模型并移除默认人物;脚本不会清空已有几何' unless model.entities.length.zero?
@current = Session.new(model)
@current.start
@current
rescue StandardError, LoadError => e
@current.stop!("setup_failed: #{e.message}") if @current && !@current.done?
message = "[export_pdf_ruby] 未启动:#{e.class}: #{e.message}"
puts message
UI.messagebox(message) if defined?(UI)
nil
end
def stop!; @current.stop! if @current && !@current.done?; end
end
class Session
attr_reader :directory, :data, :scene
def initialize(model)
@model=model; @view=model.active_view; @started=Time.now; @started_clock=ExportPdfRuby.clock
@scene={}; @timers=[]; @done=false; @stopped=false; @busy=false; @attempted=false; @phase='starting'
year=Sketchup.version.to_i; @year=year<2000 ? year+2000 : year
@stamp=@started.strftime('%Y%m%d_%H%M%S_')+format('%03d', @started.usec/1000)
@data={'owner'=>OWNER, 'script_version'=>VERSION, 'status'=>'running', 'errors'=>[], 'events'=>[],
'stage_ms'=>{}, 'native_export_called'=>false, 'reproduction_status'=>'not_assessed', 'root_cause'=>'not_determined',
'environment'=>{'sketchup_version'=>Sketchup.version, 'sketchup_version_number'=>Sketchup.version_number,
'ruby_version'=>RUBY_VERSION, 'ruby_description'=>RUBY_DESCRIPTION, 'ruby_platform'=>RUBY_PLATFORM,
'sketchup_platform'=>Sketchup.platform.to_s, 'pid'=>Process.pid, 'time'=>@started.iso8601(3),
'utc_offset_seconds'=>@started.utc_offset},
'scene_parameters'=>{'units'=>'mm', 'board_width'=>300, 'board_height'=>200,
'frame_min'=>[-140,-70,10], 'frame_max'=>[140,70,190], 'board_offset'=>10, 'cut_overlap'=>2,
'label'=>"SKETCHUP\n#{@year}", 'font'=>'Arial Bold', 'letter_height'=>16,
'pdf_scale'=>'1:1; actual PDF MediaBox must be checked separately'}}
failures=[]
[proc { File.join(ExportPdfRuby.desktop, 'TS_Debug') }, proc { File.join(Sketchup.temp_dir, 'TS_Debug') }].each_with_index do |candidate,i|
begin
root=candidate.call; FileUtils.mkdir_p(root)
base="#{OWNER}_#{@stamp}_su#{@year}_pid#{Process.pid}"
100.times do |n|
path=File.join(root, base+(n.zero? ? '' : "_#{n}"))
begin; Dir.mkdir(path); @directory=path; break; rescue Errno::EEXIST; end
end
raise '无法分配新的取证目录' unless @directory
@data['environment']['output_fallback_to_temp']=i==1
@data['environment']['output_directory']=@directory
checkpoint
break
rescue StandardError, LoadError => e
failures << "#{e.class}: #{e.message}"; @directory=nil
end
end
raise "桌面与临时取证目录均不可写:#{failures.join(' | ')}" unless @directory
@data['environment']['output_directory_warnings']=failures unless failures.empty?
end
def done?; @done; end
def event(name, extra={})
@data['events'] << {'stage'=>name, 'time'=>Time.now.iso8601(3),
'elapsed_ms'=>((ExportPdfRuby.clock-@started_clock)*1000).round(3)}.merge(extra)
end
def error(stage, exception)
@data['errors'] << {'stage'=>stage, 'class'=>exception.class.to_s,
'message'=>exception.message, 'backtrace'=>Array(exception.backtrace).first(5)}
end
def attempt(stage)
began=ExportPdfRuby.clock
yield
rescue StandardError, NotImplementedError => e
error(stage,e); nil
ensure
@data['stage_ms'][stage]=((ExportPdfRuby.clock-began)*1000).round(3)
end
def checkpoint
json=JSON.pretty_generate(@data)
File.write(File.join(@directory, 'evidence.json'), json+"\n", mode:'w:UTF-8')
File.write(File.join(@directory, "collect_evidence_#{@stamp}.txt"),
"Owner=#{OWNER}\n#{@started.iso8601(3)}\nPDF content / root cause: not assessed / not determined.\n\n#{json}\n", mode:'w:UTF-8')
end
def later(seconds, &block)
id=nil
id=UI.start_timer(seconds, false) do
@timers.delete(id)
begin; block.call if live?; rescue StandardError, NotImplementedError => e; error(@phase,e); finish; end
end
@timers << id
end
def live?
return false if @done || @stopped
unless Sketchup.active_model.equal?(@model) && !@model.active_path
stop!('active_model_or_edit_context_changed'); return false
end
true
end
def start
puts "[export_pdf_ruby] SU #{Sketchup.version},PID #{Process.pid};本轮只导出一次 PDF。\n[export_pdf_ruby] #{@directory}"
later(30.0) { stop!('view_callback_timeout') unless @attempted }
later(0.0) { build }
end
def group(entities,name)
g=entities.add_group; g.name=name; g
end
def material(name,rgb)
m=@model.materials.add("#{OWNER}_#{name}"); m.color=Sketchup::Color.new(*rgb); m.alpha=1.0; m.texture=nil; m
end
def paint(face,mat)
raise '素材面创建失败' unless face
face.material=mat; face.back_material=mat; face.edges.each { |e| e.hidden=true }; face
end
def build
return unless live?
@phase='building'; began=ExportPdfRuby.clock
@model.start_operation('Small native PDF reproduction',true); @operation=true
source=group(@model.entities,'source_geometry'); @scene['source']=source
white=material('white',[255,255,255]); purple=material('purple',[170,85,255])
# Filled zero-extrusion text becomes ordinary faces, not a screen overlay.
ok=source.entities.add_3d_text("SKETCHUP\n#{@year}",TextAlignLeft,'Arial',true,false,16*MM,0.0,0.0,true,0.0)
raise '版本文字生成失败(Arial)' unless ok && !source.entities.grep(Sketchup::Face).empty?
box=source.bounds
transform=Geom::Transformation.axes([-75*MM-box.center.x,-45*MM,100*MM-box.center.y],[1,0,0],[0,0,1],[0,-1,0])
source.entities.transform_entities(transform,source.entities.to_a)
source.entities.grep(Sketchup::Face).each { |f| paint(f,white) }
@data['text_face_count']=source.entities.grep(Sketchup::Face).size
# Diamond base: front view sees two differently colored triangular faces.
vertices=[[10,0,30],[70,-60,30],[130,0,30],[70,60,30],[70,0,160]].map { |p| p.map { |n| n*MM } }
colors=[[0,210,210],[255,220,30],[255,145,30],[100,210,80],[80,160,255]]
[[0,3,2,1],[0,1,4],[1,2,4],[2,3,4],[3,0,4]].each_with_index do |indices,i|
paint(source.entities.add_face(indices.map { |n| vertices[n] }),material("pyramid_#{i}",colors[i]))
end
@data['pyramid_vertices_mm']=vertices.map { |p| p.map { |n| (n/MM).round(6) } }
[['current_background',-80],['opposite_background',80]].each do |name,y|
board=group(@model.entities,name)
paint(board.entities.add_face([[-150,y,0],[150,y,0],[150,y,200],[-150,y,200]].map { |p| p.map { |n| n*MM } }),purple)
board.visible=name=='opposite_background'; @scene[name]=board
end
# Original copy + four nested active sections; recompute each local plane
# because native add_group may choose a local origin. All lengths are small.
move=Geom::Transformation.new([0,0,100*MM])
copy=source.copy; copy.visible=true; copy.material=white; copy.transform!(move.inverse)
@scene['visible_copy']=copy
g=copy
%w[top bottom left right].each_with_index do |side,i|
g=@model.entities.add_group(g); g.name="cut_#{side}"; g.material=white
o=Geom::Point3d.new(0,0,0).transform(g.transformation.inverse)
planes=[[0,0,-1,o.z+92*MM],[0,0,1,92*MM-o.z],[1,0,0,142*MM-o.x],[-1,0,0,142*MM+o.x]]
s=g.entities.add_section_plane([1,1,1],[1,1,1]); s.set_plane(planes[i]); s.hidden=true; s.activate
end
g.transform!(move); @scene['cut_group']=g; source.visible=false
RENDER.each { |k,v| @model.rendering_options[k]=v }; SHADOW.each { |k,v| @model.shadow_info[k]=v }
@model.selection.clear
camera=@view.camera; camera.perspective=false; camera.aspect_ratio=0.0
camera.set([500*MM,0,100*MM],[0,0,100*MM],[0,0,1]); camera.height=240*MM; @view.camera=camera
@model.commit_operation; @operation=false
@data['stage_ms']['build']=((ExportPdfRuby.clock-began)*1000).round(3)
event('scene_created'); request('viewRight:','right')
rescue StandardError, NotImplementedError => e
attempt('abort_build') { @model.abort_operation } if @operation
@operation=false; error('build',e); finish
end
class Observer < Sketchup::ViewObserver
def initialize(session,role); @session=session; @role=role; @count=0; end
def onViewChanged(view); @count+=1; @session.changed(self,view,@count,@role); end
end
def request(action,role)
return unless live?
@phase="waiting_#{role}"; @observer=Observer.new(self,role)
raise '无法添加视图观察器' if @view.add_observer(@observer)==false
event('view_request',{'action'=>action})
raise "视图请求失败:#{action}" if Sketchup.send_action(action)==false
end
def detach
@view.remove_observer(@observer) if @observer
@observer=nil
end
def changed(observer,view,count,role)
return unless live? && @observer.equal?(observer) && view.equal?(@view)
event('view_callback',{'role'=>role,'index'=>count})
if count==1
@model.selection.clear
# Preserve original nil @cur_gri guard semantics: only opposite board.
@model.selection.add(@scene['opposite_background'])
event('zoom_selection',{'names'=>@model.selection.map(&:name)})
return unless live? && @observer.equal?(observer)
raise '缩放请求失败' if Sketchup.send_action('viewZoomToSelection:')==false
@view.refresh if live?
elsif count==2
detach; @model.selection.clear; @scene['current_background'].visible=false
view.invalidate; view.refresh
role=='right' ? later(0.01) { request('viewFront:','front') } : export_pdf
end
rescue StandardError, NotImplementedError => e
error('view_callback',e); finish
end
def entity_info(g)
b=g.bounds; f=g.entities.grep(Sketchup::Face).first
{'name'=>g.name, 'persistent_id'=>g.persistent_id, 'visible'=>g.visible?, 'hidden'=>g.hidden?,
'bounds_in'=>[b.min.to_a,b.max.to_a], 'transformation'=>g.transformation.to_a,
'color'=>f && f.material && [f.material.color.red,f.material.color.green,f.material.color.blue]}
end
def snapshot
c=@view.camera; w=@view.vpwidth.to_f; h=@view.vpheight.to_f
raise '视口宽高无效' unless w>0 && h>0
chain=[]; g=@scene['cut_group']
while g && (s=g.entities.active_section_plane)
chain << {'group'=>g.name, 'transform'=>g.transformation.to_a,
'plane'=>s.get_plane, 'active'=>s.active?, 'hidden'=>s.hidden?}
g=g.entities.grep(Sketchup::Group).first
end
{'camera'=>{'eye'=>c.eye.to_a,'target'=>c.target.to_a,'up'=>c.up.to_a,'direction'=>c.direction.to_a,
'perspective'=>c.perspective?,'height_mm'=>c.height.to_f/MM,'aspect_ratio'=>c.aspect_ratio,
'estimated_view_width_mm'=>c.height.to_f/MM*w/h},
'viewport'=>{'width'=>w,'height'=>h}, 'model_guid'=>@model.guid,
'rendering'=>RENDER.keys.to_h { |k| [k,@model.rendering_options[k]] },
'shadow'=>SHADOW.keys.to_h { |k| [k,@model.shadow_info[k]] },
'selection'=>@model.selection.map(&:name),'section_chain'=>chain,
'source'=>entity_info(@scene['source']), 'visible_copy'=>entity_info(@scene['visible_copy']),
'cut_group'=>entity_info(@scene['cut_group']),
'current_background'=>entity_info(@scene['current_background']),
'opposite_background'=>entity_info(@scene['opposite_background'])}
end
def file_info(path)
{'path'=>path,'exists'=>File.file?(path),'bytes'=>File.file?(path) ? File.size(path) : nil}
end
def export_pdf
entered=false
return unless live? && !@attempted
@attempted=true; @busy=true; entered=true; @phase='exporting'
options={show_summary:false, output_profile_lines:false, output_section_lines:false, map_fonts:false,
drawing_units:Length::Millimeter, extension_units:Length::Millimeter, height_units:Length::Millimeter,
width_units:Length::Millimeter, model_units:Length::Millimeter,
full_scale:true, length_in_drawing:1.0, length_in_model:1.0}
@data['pdf_options']=options.dup
@data['before_pdf']=attempt('snapshot') { snapshot }
return unless live? # State reads may pump UI; recheck at the actual native boundary.
path=File.join(@directory,"export_pdf_su#{@year}.pdf")
event('pdf_export_before'); @data['native_export_called']=true
result=attempt('native_pdf') { @model.export(path,options) }
@data['pdf']=file_info(path).merge('return_value'=>result)
error('native_pdf_result',RuntimeError.new('PDF export returned false/nil or file is missing')) unless result && File.file?(path)
event('pdf_export_after'); checkpoint
if live?
attempt('png') do
w=@view.vpwidth.to_f; h=@view.vpheight.to_f
ratio=[1.0,1280.0/[w,h,1].max].min
if live?
png=File.join(@directory,'after_export.png')
ok=@view.write_image(filename:png,width:[1,(w*ratio).round].max,height:[1,(h*ratio).round].max,antialias:false)
@data['png']=file_info(png).merge('return_value'=>ok,'timing'=>'after_native_pdf')
raise 'PNG export failed or file is missing' unless ok && File.file?(png)
end
end
end
if live?
attempt('model_copy') do
skp=File.join(@directory,'after_export.skp'); ok=@model.save_copy(skp)
@data['model_copy']=file_info(skp).merge('return_value'=>ok,'timing'=>'after_native_pdf')
raise 'SKP copy failed or file is missing' unless ok && File.file?(skp)
end
end
rescue StandardError, NotImplementedError => e
error('export',e)
ensure
if entered
@busy=false
finish
end
end
def stop!(reason='manual_stop')
return if @done || @stopped
@stopped=true; error(@phase,RuntimeError.new(reason))
cleanup; finish unless @busy
end
def cleanup
attempt('detach_observer') { detach }
@timers.each { |id| attempt('stop_timer') { UI.stop_timer(id) } }; @timers.clear
end
def finish
return if @done
@done=true; cleanup
@data['status']=@data['errors'].empty? ? 'completed' : 'partial'
@data['finished_at']=Time.now.iso8601(3); @data['elapsed_ms']=((ExportPdfRuby.clock-@started_clock)*1000).round(3)
checkpoint
puts "[export_pdf_ruby] 实验结束:#{@data['status']};PDF 内容是否漏导需核对,根因尚未确定。\n[export_pdf_ruby] #{@directory}"
rescue StandardError => e
@data['status']='partial'
puts "[export_pdf_ruby] 取证日志保存失败:#{e.class}: #{e.message}\n[export_pdf_ruby] #{@directory}"
end
end
end
end
ExportPdfRuby.run
export_pdf_ruby.rb (17.3 KB)
Usage export_pdf_ruby.rb (17.3 KB)
- Start SketchUp and open a new, empty model. Remove the default person and any existing geometry.
- Open SketchUp’s Ruby Console.
- Paste the following command into the console and press Enter:
path = UI.openpanel('Select export_pdf_ruby.rb', nil, '*.rb'); load(path) if path
- In the file selection dialog, locate
export_pdf_ruby.rb, select it, and click Open. - The script automatically creates the sample scene and exports a PDF, followed by a PNG, a model copy, and diagnostic logs. Keep the model active and avoid changing the view until the completion message appears.
Results are saved under Desktop/TS_Debug, in a separate folder for each run. The Ruby Console prints the actual output path, including any fallback to the temporary directory.
For comparison, repeat these steps in SketchUp 2026 and 2027 using the same script. Use a fresh empty model for each run.






