Created
March 6, 2020 07:36
-
-
Save merwaaan/d8dd9e11f5afc1409d3dd3bc487906be to your computer and use it in GitHub Desktop.
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
# Code adapted from https://forums.sketchup.com/t/mac-extension-doesnt-load-when-installed-in-several-locations-user-folder-machine-folder/118206/4 | |
module FakeCompany | |
module FakeExtension | |
unless defined?(EXTENSION) | |
EXTENSION = SketchupExtension.new( | |
'FakeExtension', | |
'fake_extension/main' | |
).instance_eval { | |
self.version = '1.2.3' | |
self.creator = 'Fake Company' | |
self.copyright = '(c) ' << Time.now.year | |
self.description = 'Fake description.' | |
Sketchup.register_extension(self,true) | |
self | |
} | |
end | |
end | |
end |
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
# Code adapted from https://github.com/SketchUp/sketchup-ruby-api-tutorials/tree/master/tutorials/01_hello_cube | |
require 'sketchup.rb' | |
module FakeCompany | |
module FakeExtension | |
def self.create_cube | |
model = Sketchup.active_model | |
model.start_operation('Create Cube', true) | |
group = model.active_entities.add_group | |
entities = group.entities | |
points = [ | |
Geom::Point3d.new(0, 0, 0), | |
Geom::Point3d.new(1.m, 0, 0), | |
Geom::Point3d.new(1.m, 1.m, 0), | |
Geom::Point3d.new(0, 1.m, 0) | |
] | |
face = entities.add_face(points) | |
face.pushpull(-1.m) | |
model.commit_operation | |
end | |
unless file_loaded?(__FILE__) | |
menu = UI.menu('Plugins') | |
menu.add_item('Create Cube Example') { | |
self.create_cube | |
} | |
file_loaded(__FILE__) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment