Plugin has been updated. This is still an alpha release, but there are big improvements.
Release Notes
v 0.2.0
- Renamed plugin to "Entity Info +" which is describes its intention better
- New user customisable list of entity properties
- New properties available
- Classifications can be edited, although this is early days at the moment, with lots of bugs
- New system for adding properties allows developer contributions
Developer Contributions Welcome
There is a dizzying array of potential properties that can be edited in SketchUp, which will take a lot of coding to complete. I have developed a way to organise each property in this plugin, so developers (myself included) will be able to write just 4 methods (propertyName, get, set, validate) for each property that they wish to add to the mix.
If you are interested, have a look at the propertyType.rb file in the plugin, and see if you can't write the code needed to get your favourite property into the plugin. I will be happy to review and integrate contributions.
###############
### EXAMPLE ###
###############
# Each new property type needs to define 4 methods as in the example below.
# Note that all methods are class methods, so it can be called without creating
# an instance of the class.
# The first method simply defines the name of the property type, and the name of
# the 'get', 'set' and 'validate' methods it uses.
def self.example
# getNameFunc is an optional variable, which builds the name from parameters
#passed to the method. This is required for property types such as atributes,
# which need to include the attribute dictionaries and attribute label in the name
values = {'name' => 'example', \
'label' => 'Example', \
'getNameFunc' => 'exampleName', \
'getValueFunc' => 'getExample', \
'setValueFunc' => 'setExample', \
'validateFunc' => 'validateExample'}
return values
end
def self.exampleName(options)
name = 'example;' + options.to_s
return name
end
# The get method takes a Sketchup;;Selection object, and any parameters required.
# Parameters are required when getting deeper structured information about attributes
# or Classifications, for example.
#
# Params;
# +selection+;; Sketchup;;Selection object from which to get the values from.
# +params+;; Additional parameters required to get the value (optional).
def self.getExample(selection, params)
result = {}
result['label'] = 'example' # the label shown to the user (optional - defaults to existing label)
result['hidden'] = false # if true, the input box on the editor window will be hidden (optional - defaults to false)
result['message'] = "This is a message, not that you need it" # this shows the help text that can be displayed on the editor window (optional)
result['warning'] = "Watch out" # a warning to be displayed prominently to the user next to the label text (optional)
result['value'] = selection[0].definition.description # the output value. Can be a string, or an array of result objects with the same values as above (required)
result['form-type'] = 'text' # the form type, can be 'text', 'textarea', 'checkbox', 'select'
return result
end
# The set method sets the property of the selection.
#
# Params;
# +selection+;; Sketchup;;Selection object to which we can apply the properties.
# +params+;; The values to set the property with.
def self.setExample(selection, params)
if selection.length > 0
# Make your edits here
stuff = params['value'] # values normally reside in this hash
params['success'] = true # mark your values as successfully set
return params # return the params
else
params['success'] = false # report that something went wrong
params['warning'] = "something went wrong" # optional message to be displayed to the user
return params # return the params
end
end
# The validate method validates the input parameters, and amends them if necessary.
#
# Params;
# +selection+;; Sketchup;;Selection object to which the properties are to be applied.
# +params+;; A hash object containing values.
def self.validateExample(selection, params)
if params['value'] == "oh no" # check for problems with values
params['error'] = true # report an error - this will stop the setting of the property
params['warning'] = "Value given is not a string" # optional message to be displayed to the user
end
return params # return the parameters for the next step; set the property.
end