Right Click Edit
-
hey thanks I tried that and it worked... but when i look over this code I only see the context menu listed at the beginning as a comment. How does the script run it if it is only a comment? Is this script calling another external script that i am overlooking?
**```
#-----------------------------------------------------------------------------Name ; Window Maker 1.0
Description ; A tool to create parametric Double Hung and Slider windows.
Menu Item ; Tools->Windows
Context Menu; Edit Window
Usage ; Select window type and then specify the size.
; If the size needs to be changed after inserting into the model,
; right click on the window and select "Edit Window".
Date ; 9/10/2004
Type ; Dialog Box
#-----------------------------------------------------------------------------
-
That code in the first post is the entire script?
Chris
-
@chris fullmer said:
That code in the first post is the entire script?
Chris
No - it include's @last's Parametric.rb - as TIG mentioned. And the Window class it works with extends a Parametric class which I can only assume is from parametric.rb - so I'm guessing the parametric.rb contains the context-menu code.
-
require
'parametric.rb'
calls that ruby, so look at that file too... -
@unknownuser said:
require 'parametric.rb'
Thanks I did check that and there was no sign of anything, I still have no clue.@unknownuser said:
That code in the first post is the entire script?
Yup thats the entire script. sure it requires sketchup.rb and parametric.rb, but a lot of scripts do.I downloaded it right from the google website Window Maker http://sketchup.google.com/download/rubyscripts.html
-
Read to the end of the file
parametric.rb
and you will find...#============================================================================= # Add a context menu handler that will add a menu choice to a context menu # for editing parametric objects if( not $parametric_loaded ) UI.add_context_menu_handler do |menu| klass = Parametric.selection_parametric? if( klass ) menu.add_separator menu.add_item("Edit #{klass}") { Parametric.edit_selection } end end $parametric_loaded = true end
which looks suspiciously like the code for a context-menu ?
-
@tig said:
which looks suspiciously like the code for a context-menu ?
yeah i did another test and some how its passing the class name to parametric.rb but how? is it through the following code?
**```
def create_entity(model)
#TODO; try to find existing definition matching the parameters
@entity = model.definitions.add self.compute_name -
so my question now is if I require another script, such as, parametric.rb does that mean it loads the script and allows me to pass methods and variables back and forth between the two scripts?
-
class Window < Parametric
means that Window 'extends' [builds upon OR uses] the Parametric class - i.e. it's like they are parts of the same code: so making a Window gives it certain properties through the Parametric code, later on the property found in a selected object can trigger the Parametric 'checker' and make the context-menu appear, adjusted to suit the exact type of 'parametric' object that it is...
Window needs Parametric to work - it can't stand alone - if you were to remove parametric.rb Window wouldn't work...
They work in tandem.
Parametric can be used by lots of different scripts for other objects requiring similar dialogs etc... -
thanks, great explanation. I'm guessing nothing in parametric.rb is actually specifically changed to work with windows.rb and it is the windows.rb script that utilizes the methods and variables in the parametric.rb script. i'll keep working at it
Advertisement