ok, now i want can change my text contained in a group.
In my second plugin, i have a menu to change "Name_zone" of the object selected.
I can't change the 2D text of my object, because it contained in a group of entities.
In my second plugin i want do this after "#I wish change my 2D text in the object selected
#??? "
It's possible or i delete my object and i create a new?
My code who associate my text in a group of entities.
thx again and again. I'am begining...
First plugin:
def add_etiquette
# Get "handles" to our model and the Entities collection it contains.
model = Sketchup.active_model
entities = model.entities
# Create a series of "points", each a 3-item array containing x, y, and z.
pt1 = [0, 0, 0]
pt2 = [30, 0, 0]
pt3 = [30, 0, 17]
pt4 = [0, 0, 17]
coordinates = [0, 0, 8.5]
# Call methods on the Entities collection to draw stuff.
# new_face = entities.add_face pt1, pt2, pt3, pt4
group = entities.add_group
point = Geom;;Point3d.new coordinates
group.entities.add_face(pt1,pt2,pt3,pt4)
prompt = ["Zone Name"]
val = group.get_attribute("MyDico", "Name_zone")
default = [val]
result = UI.inputbox prompt, default, "Enter the Zone Name"
adrresult = result[0].to_s
group.set_attribute("MyDico", "Name_zone", adrresult.to_s)
group.entities.add_text adrresult.to_s, point
UI.messagebox ("@ ; " + adrresult.to_s + " saved")
end
Second plugin:
def zonename
prompt = ["Name"]
val = Sketchup.active_model.selection[0].get_attribute("MyDico", "Name_zone")
default = [val]
result = UI.inputbox prompt, default, "Enter the Zone Name"
adrresult = result[0].to_s
adr = Sketchup.active_model.selection[0].set_attribute("MyDico", "Name_zone", adrresult.to_s)
#I wish change my 2D text in the object selected text=adrresult
#???
UI.messagebox ("@ ; " + adr.to_s + " saved")
end
#Menu
if (not file_loaded?("zEtiquette_config2.rb"))
UI.add_context_menu_handler do |menu|
if (Sketchup.active_model.selection.length == 1)
menu.add_separator
if ((Sketchup.active_model.selection[0].get_attribute("MyDico", "Name_zone")) != nil)
menu.add_item("Change Zone Name (@" + Sketchup.active_model.selection[0].get_attribute("MyDico", "Name_zone").to_s + ")") { zonename }
end
end
end
$VSX = Vsx.new
file_loaded("zEtiquette_config2.rb")
end