-
-
Save itsanov/a6b9016dff5a5c0ee270ff8b82ebf66f to your computer and use it in GitHub Desktop.
Helps fix the one-frame delay problem when running Google Sketchup in Wine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fixes the view each time the view changes | |
require 'sketchup' | |
def refresh | |
UI.start_timer(0, false) { | |
Sketchup.active_model.active_view.invalidate.refresh | |
} | |
end | |
module NH | |
module ViewFix | |
@observer = nil | |
@selection_observer = nil | |
@model_observer = nil | |
@layer_observer = nil | |
@tool_observer = nil | |
@rendering_observer = nil | |
class MyViewObserver < Sketchup::ViewObserver | |
def onViewChanged( view ) | |
puts "New View changed: #{view.inspect}" | |
refresh | |
end | |
end | |
class MySelectObserver < Sketchup::SelectionObserver | |
def onSelectionBulkChange(selection) | |
puts "MySelectObserver.onSelectionBulkChange" | |
refresh | |
end | |
def onSelectionCleared(selection) | |
puts "MySelectObserver.onSelectionBulkChange" | |
refresh | |
end | |
end | |
class MyModelObserver < Sketchup::ModelObserver | |
def onActivePathChanged(model) | |
puts "onActivePathChanged: #{model}" | |
refresh | |
end | |
def onEraseAll(model) | |
puts "onEraseAll: #{model}" | |
refresh | |
end | |
def onExplode(model) | |
puts "onExplode: #{model}" | |
refresh | |
end | |
def onExplode(model) | |
puts "onExplode: #{model}" | |
refresh | |
end | |
# def onPidChanged(model, old_pid, new_pid) | |
# puts "onPidChanged: #{model}, #{old_pid} => #{new_pid}" | |
# refresh | |
# end | |
def onTransactionCommit(model) | |
puts "onTransactionCommit: #{model}" | |
refresh | |
end | |
def onTransactionAbort(model) | |
puts "onTransactionAbort: #{model}" | |
refresh | |
end | |
def onTransactionRedo(model) | |
puts "onTransactionRedo: #{model}" | |
refresh | |
end | |
def onTransactionUndo(model) | |
puts "onTransactionUndo: #{model}" | |
refresh | |
end | |
def onDeleteModel(model) | |
puts "onDeleteModel: #{model}" | |
refresh | |
end | |
def onPlaceComponent(instance) | |
puts "onPlaceComponent: #{instance}" | |
refresh | |
end | |
end | |
class MyLayersObserver < Sketchup::LayersObserver | |
def onCurrentLayerChanged(layers, layer) | |
puts "onCurrentLayerChanged: #{layer.name}" | |
refresh | |
end | |
def onLayerAdded(layers, layer) | |
puts "onLayerAdded: #{layer.name}" | |
refresh | |
end | |
def onLayerChanged(layers, layer) | |
puts "onLayerChanged: #{layer.name}" | |
refresh | |
end | |
def onLayerRemoved(layers, layer) | |
puts "onLayerRemoved: #{layer.name}" | |
refresh | |
end | |
def onRemoveAllLayers(layers) | |
puts "onRemoveAllLayers: #{layers}" | |
refresh | |
end | |
end | |
class MyToolObserver < Sketchup::ToolsObserver | |
def onActiveToolChanged(tools, tool_name, tool_id) | |
puts "onActiveToolChanged: #{tool_name}" | |
refresh | |
end | |
def onToolStateChanged(tools, tool_name, tool_id, tool_state) | |
puts "onToolStateChanged: #{tool_name}" | |
refresh | |
end | |
end | |
class MyRenderingOptionsObserver < Sketchup::RenderingOptionsObserver | |
def onRenderingOptionsChanged(rendering_options, type) | |
puts "onRenderingOptionsChanged(#{rendering_options}, #{type})" | |
refresh | |
end | |
end | |
def self.fix_view | |
fix_view_disable | |
fix_view_enable | |
end | |
def self.is_fix_set | |
!!@observer | |
end | |
def self.fix_view_disable | |
# Remove old observers | |
Sketchup.active_model.active_view.remove_observer( @observer ) if @observer | |
@observer = nil | |
Sketchup.active_model.selection.remove_observer( @selection_observer ) if @selection_observer | |
@selection_observer = nil | |
Sketchup.active_model.remove_observer( @model_observer ) if @model_observer | |
@model_observer = nil | |
Sketchup.active_model.layers.remove_observer( @layer_observer ) if @layer_observer | |
@layer_observer = nil | |
Sketchup.active_model.tools.remove_observer( @tool_observer ) if @tool_observer | |
@tool_observer = nil | |
Sketchup.active_model.rendering_options.remove_observer( @rendering_observer ) if @rendering_observer | |
@rendering_observer = nil | |
end | |
def self.fix_view_enable | |
# Attach the observers. | |
@layer_observer = MyLayersObserver.new | |
Sketchup.active_model.layers.add_observer( @layer_observer ) | |
@observer = MyViewObserver.new | |
Sketchup.active_model.active_view.add_observer( @observer ) | |
@selection_observer = MySelectObserver.new | |
Sketchup.active_model.selection.add_observer(@selection_observer) | |
@tool_observer = MyToolObserver.new | |
Sketchup.active_model.tools.add_observer(@tool_observer) | |
@rendering_observer = MyRenderingOptionsObserver.new | |
Sketchup.active_model.rendering_options.add_observer(@rendering_observer) | |
@model_observer = MyModelObserver.new | |
Sketchup.active_model.add_observer(@model_observer) | |
end | |
end | |
end | |
cmd = UI::Command.new("Refresh delay fix for Wine") { | |
if NH::ViewFix.is_fix_set | |
NH::ViewFix.fix_view_disable | |
else | |
NH::ViewFix.fix_view_enable | |
end | |
} | |
cmd.menu_text = "Refresh delay fix for Wine" | |
cmd.set_validation_proc { | |
if NH::ViewFix.is_fix_set | |
MF_CHECKED | |
else | |
MF_UNCHECKED | |
end | |
} | |
UI.menu("Plugins").add_item cmd | |
class MyAppObserver < Sketchup::AppObserver | |
def onNewModel(model) | |
puts "onNewModel: #{model}" | |
NH::ViewFix.fix_view | |
end | |
def onOpenModel(model) | |
puts "onOpenModel: #{model}" | |
NH::ViewFix.fix_view | |
end | |
def expectsStartupModelNotifications | |
return true | |
end | |
end | |
# Attach the observer | |
Sketchup.add_observer(MyAppObserver.new) |
Awesome and thank you!
Sketchup Make 2017 now completely works on my linux box.
STOP
…On Mon, May 20, 2024 at 5:55 PM sythem ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
Awesome and thank you!
Sketchup Make 2017 now completely works on my linux box.
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/itsanov/a6b9016dff5a5c0ee270ff8b82ebf66f#gistcomment-5063657>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APE64YAWR4SSDFWNXCPTUKDZDKLPLBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTAMJRGMYDGMZTU52HE2LHM5SXFJTDOJSWC5DF>
.
You are receiving this email because you commented on the thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is the short video I uploaded with instructions on how to install the plugin
https://youtu.be/sBG-eB576DM
I do have instructions on how to install SketchUp in PlayOnLinux, but they are from 2014.
http://www.gamersonlinux.com/forum/threads/sketchup-guide.828/
I really do not recommend the guide because it uses an old version of PlayOnLinux and an old version of Wine. Not to mention SketchUp Make 2017 is no longer available for download and the guide recommends SkechUp 32-bit. I kept an old copy for myself, which is what I'm using today.
Most of the steps still apply, but if anyone has questions I can help on GamersOnLinux as I have posted all the step-by-step guides for the last 9 years or so.
[edit] Updated the youtube link to my personal channel