Let's start with YOUR_PLUGIN_base. rb file.
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
#---------Plugin Info--------------------------------------------------------- | |
#----------------------------------------------------------------------------- | |
# Name : | |
# Copyright : (c) 2013 | |
# Designed : Author | |
# Icons by : | |
# Description : Opis | |
# Menu Item : Plugins > YOUR_PLUGIN MENU | |
# Context Menu: N/A | |
# Usage : | |
# Date : | |
#----------------------------------------------------------------------------- | |
# Permission to use, copy, modify this software for | |
# any non-commercial purpose is hereby granted | |
#----------------------------------------------------------------------------- | |
# CHANGELOG: | |
# | |
#----------------------------------------------------------------------------- | |
require "sketchup.rb" | |
require "YOUR_LIB.rb" | |
require "YOUR_PLUGIN/YOUR_PLUGIN.rb" | |
if !file_loaded?(__FILE__) then | |
#---menu---------------------------------------------------------------------- | |
YOUR_PLUGIN_menu = UI.menu("plugins").add_submenu("YOUR_PLUGIN") | |
#---toolbar------------------------------------------------------------------- | |
YOUR_PLUGIN_tb = UI::Toolbar.new("YOUR_PLUGIN") | |
#---command------------------------------------------------------------------- | |
cmd = UI::Command.new("YOUR_PLUGIN") {YOUR_PLUGIN.new()} | |
cmd.small_icon = "YOUR_PLUGIN/YOUR_ICONs.png" | |
cmd.large_icon = "YOUR_PLUGIN/YOUR_ICON.png" | |
cmd.tooltip = "YOUR_PLUGIN" | |
cmd.status_bar_text = "YOUR_PLUGIN" | |
cmd.menu_text = "YOUR_PLUGIN" | |
YOUR_PLUGIN_tb.add_item(cmd) | |
YOUR_PLUGIN_menu.add_item("YOUR_PLUGIN") {YOUR_PLUGIN.new()} | |
#----------------------------------------------------------------------------- | |
end | |
#----------------------------------------------------------------------------- | |
file_loaded( File.basename(__FILE__) ) | |
#----------------------------------------------------------------------------- |
Lines 21, 22 and 23 are call-outs for 3 files that are necesary for our plugin to function.
"sketchup.rb" includes all genereal ruby function definitions that sketchup normaly uses,
"YOUR_LIB.rb" includes definitions of Your functions and
"YOUR_PLUGIN.rb" includes definition of tour plugin.
Lines from 25 are executed only if this file was not already loaded.
Line 27 adds new submenu YOUR_PLUGIN to Sketchup's Plugin menu.
Line 29 adds new toolbar YOUR_PLUGIN to Sketchup.
Line 33 defines a new comand "cmd , which calls out a new tool - YOUR_PLUGIN.
Line 34 and 35 show path to icons that will sit in toolbar.
Line 36 is a tooltip - a text that will appeara whrn you hold a cursor above your toolbar.
Line 37 - sets the status bar text for your plugin
Line 38 - sets the menu item name for your plugin
Lines 39 and 40 - add YOUR_PLUGIN tool to new menu and toolbar
No comments:
Post a Comment