I am trying to set up a macro for my 3D Connexion mouse that includes a step for setting Camera>Parallel Projection. Unfortunately the shortcut key settings only create a toggle between parallel & perspective mode. The same happens assigning a shortcut to Camera>Perspective. Is there a way to force SU into parallel mode with a macro regardless of the current camera mode ?
You can copy and paste this to Ruby Console (Menu Extensions>>Developer>>Ruby Console) then hit Enter (Return).
Sketchup.active_model.active_view.camera.perspective = false
Thanks @dezmo, but I donât think we are on the same page. 3D Connexion will let me enter shortcut keys to form a macro. You have however lit the spark for me to start getting my head into Ruby. Iâve done machine code back in 1980âs, BASIC, LISP & GDL; how hard can it beâŠ
You could set up the code snippet as an extension under âToolsâ. Youâd need a registration file (same name as extension folder) in your Plugins folder and an extension folder (same name as your registration file). Then assign a shortcut in SU that you can assign in the 3D Connexion software.
For example, a (ruby) file registration file:
idk_p_p_m.rb
module IDKProgramming
module ParallelProjectionMacro
VERSION = "1.0.0"
EXTENSION_NAME = "Parallel Projection"
LOADER_PATH = "idk_p_p_m/p_p_m_loader.rb"
CREATOR = "IDK Programming"
COPYRIGHT = "©2024 by IDK Programming. All rights reserved."
DESCRIPTION = 'An extension for changing camera perspective to parallel perspective.'
extension = SketchupExtension.new(EXTENSION_NAME, LOADER_PATH)
extension.version = VERSION
extension.creator = CREATOR
extension.copyright = COPYRIGHT
extension.description = DESCRIPTION
Sketchup.register_extension(extension, true)
end
end
Your extension folder (idk_p_p_m) could have a loader file (not needed, but thatâs how I do it) like this:
p_p_m_loader.rb
module IDKProgramming
module ParallelProjectionMacro
PLUGIN_PATH = File.dirname(__FILE__).freeze
require File.join(PLUGIN_PATH, 'p_p_m_main.rb')
end
end
That file would point to a âmainâ file that has the snippet:
p_p_m_main.rb
module IDKProgramming
module ParallelProjectionMacro
extend self
def activate_parallel_projection
model = Sketchup.active_model
view = model.active_view
camera = view.camera
camera.perspective = false
end
unless file_loaded?(__FILE__)
menu = UI.menu('Tools')
menu.add_item(EXTENSION_NAME) { activate_parallel_projection }
file_loaded(__FILE__)
end
end
end
Then assign a shortcut that wonât take up anything youâd use all time, like ctrl+shift+p and create that as a macro.
I have been taking a crash course in Ruby this evening⊠If I can get Ruby to do what I want it could save me hours on scene management.