Thanks TIG ! That's perfect !
I don't know why but I thought Ruby would handle it automatically !
Posts
-
RE: Auto-naming plugin ?
-
RE: Auto-naming plugin ?
Sorry again for double post, but there's something strange going on with my script.
It works fine ... once
I created the dictionnary as you suggested, and it's fine, I can read from it, name my group according to it and then increment but only one time.It seems like the incrementation is not even executed the second time. Here's what I have :
` # Read data from the dict
data1 = Sketchup.active_model.get_attribute "NAME", "data1"
data2 = Sketchup.active_model.get_attribute "NAME", "data2"
data3 = Sketchup.active_model.get_attribute "NAME", "data3"
data4 = Sketchup.active_model.get_attribute "NAME", "data4"Name the selected group according to the dict
as.each {|g|
Sketchup.active_model.selection.clear
Sketchup.active_model.selection.add(g)
g.name = "#{data1} #{data2} #{data2} #{data3}"
Sketchup.active_model.selection.clear
}Write in the dict with an incremented variable
Sketchup.active_model.set_attribute "NAME", "data4", "#{data4 + 1}"`
I also tried creating a variable
newdata4
, increment it withdata4 += 1
and then update the dict with this variable, but it doesn't work eitherHow could this work once but not twice ?
Thanks in advance !
-
RE: Auto-naming plugin ?
Wow, thanks for this very clear answer TIG, didn't know it was possible to add a dictionary to the SKP itself !
I'll try this when I get back home, thank you again !
EDIT : That's perfect, it works as expected ! Thanks !
-
RE: Auto-naming plugin ?
Hi all,
Sorry for updating this topic after such a long time, but I've just started again working on my project. Thanks for your help Jim, those plugins helped me understand about Sketchup scripts !
The only thing here is that I'd like to keep track of my variables between each time I launch the script. So here's what I did :
I created a first script that generates a text file with values in it, and then a second script that :
- Parses this text file
- Puts variables inside a "naming convention"
- Names the group I've selected according to this naming convention
- Increments the variable
- Updates the textfile
Thing is, I'd like to avoid using a text file : if the person using my script gives his sketchup file without this textfile, then all previous work would be lost. Is there a way I could store values somewhere in the program and use them as I want ?
I thought about creating "invisible groups" and use their names as data storage, but I don't know if it's a good practice !
If you have any idea please let me know !
Thanks !
-
RE: Auto-naming plugin ?
-
Auto-naming plugin ?
Hi everyone,
I'm totally new to Sketchup plugin development, and I'd like to create a plugin that automatically names groups according to a naming convention. I've already developped a first version that works fine, but there's one last feature that I don't realy know how to implement.
What I have now :
When I create a group, I right-clic on it and I select my plugin. A pannel with a textfield appears, I enter a number, press OK and the script concatenates this number with my naming convention and names the group.
What I'd like to do :
I'd like to save as much time as possible because there are possibly gonna be a looooot of groups to name. My naming convention would be something like "line1 group1, line1 group2, etc."
So, would it be possible to "autoincrement" the group number ? Maybe with something like a variable that increments each time I launch the script ? And with a possibility to set it back to 1 if I start a new "line" ? Maybe with a global variable that would be declared with SU startup or something, but then how could I set it back to zero ? With a UI button ?Sorry, lots of questions here, just to be clear I'm not asking for someone to do the job for me, just if someone could give me some leads, tips, tricks or whatever, that's great
Thanks in advance