- I am attempting to set attributes, for example, a string with a key-value pair, using the method “model.set_attribute()”. This way, I can retrieve that value when the active session is running.
- However, when I close the model and reopen it, the value does not persist with the saved model.
3.After setting the property once, I would like to be able to retrieve the property whenever needed, even if the model is closed and reopened.
here is ruby script :
require 'sketchup'
module SketchUpDataLoad
def self.set_string(input_string)
# Get the current model
model = Sketchup.active_model
# Set a custom attribute with the input string
model.set_attribute('SketchUpDataLoad', 'ModelInfo', input_string)
end
def self.get_string
# Get the current model
model = Sketchup.active_model
# Retrieve the custom attribute
return_string = model.get_attribute('SketchUpDataLoad', 'ModelInfo')
# Return the result
return_string
end
end
Thank you in advance for help