[req]rename objects with name of the layer
-
Thanks! Thanks! Thanks!
I like "door - 001"...
Can you code this to add some option in some menu?
And I also like to know if we can do it in the whole model or only visible layers....Thanks very much!
-
Any suggestions for what should be the name of the plugin?
Below are potential names...- Name by Layer
- Rename by Layer
- Entities Name by Layer
- [Re]Name
- Renamer
-
[Re] name
I think you could create something that rename numerous things, such as materials, components, Layers, etc ...
"Central [Re] name"
http://sketchucation.com/forums/viewtopic.php?f=323&t=47234
http://sketchucation.com/forums/viewtopic.php?f=323&t=53329 -
@bagatelo said:
[Re] name
I think you could create something that rename numerous things, such as materials, components, Layers, etc ...
"Central [Re] name"
viewtopic.php?f=323&t=47234
viewtopic.php?f=323&t=53329Really like that idea and the name "[Re]Name" is very fitting. But since that idea is more ambitious its advised to work our way there little by little.
Maybe starting with renaming groups & components by layer for now and making that into an extension by itself with a different name than "[Re]Name".
We can name the extension "Rename by Layer". Here is a Logo for the plugin...Any feedback is welcome.
I started working on making the extension with web-dialog and plan to keep you posted on further progress...cheers!
-
Thanks for the work, friend.
Very much appreciated.
Your logo was very interesting.You could change the code to rename the definition name?
The reason I asked this plugin is because I'm trying to use the plugin "Solid Quantify by TAK2HATA". It's a wonderful plugin, and I need something to easily modify the names of components. Note the attachment files.
-
Look what I have when I try to execute the last code...
Cleared the editor
Running the code...
Done. Ruby says: Run aborted. Error: undefined method ‘bytesize’ for "1":String -
Great plugin! It would be useful to have "append layer name as prefix/suffix" to the component's name.
-
@dedmin said:
Great plugin! It would be useful to have "append layer name as prefix/suffix" to the component's name.
Great idea! I saw this just about when I published the first version to Plugin Store but maybe for next update your suggestion will be added.
Here are some links for the plugin;
http://sketchucation.com/resources/pluginstore?pln=RND_Renamer_v1.0.0
http://sketchucation.com/forums/viewtopic.php?f=323&t=54165
Note: Something important that I noticed about definition names is that if you have 2 entities which are component instances they can't have different definition names.
For example;
Will not be named like below;
Layer: Door
component instance#1 definition name = Door - 001
component instance#2 definition name = Door - 002
component instance#3 definition name = Door - 003
component instance#4 definition name = Door - 004They will be name like this;
component instance#1 definition name = Door - 004
component instance#2 definition name = Door - 004
component instance#3 definition name = Door - 004
component instance#4 definition name = Door - 004Remember that its a rule that they must be the same. The numbers for definition name will only serve to display the total amount.
Cheers!
-
-
@bagatelo said:
Look what I have when I try to execute the last code...
Cleared the editor
Running the code...
Done. Ruby says: Run aborted. Error: undefined method ‘bytesize’ for "1":StringThis was an error on my part by using bytesize’ method which I will change to 'length' so it will work. Will try to update all the code example above to eliminate that issue.
I also published the plugin as an extension on Plugin Store as 'Rename by Layer' here is the link... http://sketchucation.com/resources/pluginstore?pln=RND_Renamer_v1.0.0
Also I made another topic here for future updates and stuff... http://sketchucation.com/forums/viewtopic.php?p=490834#p490834
Any feedback about the plugin will be great so I know that to fix on next update...Cheers!
-
I will eventually make an extension plugin with web-dialog that offers some options for the user. For now the code bellow displays the numbers like you suggested.
model = Sketchup.active_model ents = model.active_entities groups = ents.grep(Sketchup;;Group) components = ents.grep(Sketchup;;ComponentInstance) num = 0 groups.each do |group| group.name = nil.to_s end groups.each do |group| if group.name == nil.to_s num=0 end groups.each do |g| if group.layer.name == g.layer.name if g.name == nil.to_s num+=1 bytenum = num.to_s.length if bytenum == 1 zeros = "00" end if bytenum == 2 zeros = "0" end if bytenum >= 3 zeros = nil.to_s end g.name = group.layer.name.concat(" - #{zeros}#{num}") end end end end components.each do |component| component.name = nil.to_s end components.each do |component| if component.name == nil.to_s num=0 end components.each do |c| if component.layer.name == c.layer.name if c.name == nil.to_s num+=1 bytenum = num.to_s.length if bytenum == 1 zeros = "00" end if bytenum == 2 zeros = "0" end if bytenum >= 3 zeros = nil.to_s end c.name = component.layer.name.concat(" - #{zeros}#{num}") end end end end
Will keep you posted on further development...Cheers!
@bagatelo said:
And I also like to know if we can do it in the whole model or only visible layers....
Right now it does it to all layer no matter if they are visible or not. But an option for only renaming visible layers could be done.
-
@bagatelo said:
You could change the code to rename the definition name?
With the code below the definition name is created.
model = Sketchup.active_model ents = model.active_entities groups = ents.grep(Sketchup;;Group) components = ents.grep(Sketchup;;ComponentInstance) num = 0 groups.each do |group| group.name = nil.to_s end groups.each do |group| if group.name == nil.to_s num=0 end groups.each do |g| if group.layer.name == g.layer.name if g.name == nil.to_s num+=1 bytenum = num.to_s.length if bytenum == 1 zeros = "00" end if bytenum == 2 zeros = "0" end if bytenum >= 3 zeros = nil.to_s end g.name = group.layer.name.concat(" - #{zeros}#{num}") end end end end components.each do |component| component.name = nil.to_s end components.each do |component| if component.name == nil.to_s num=0 end components.each do |c| if component.layer.name == c.layer.name if c.name == nil.to_s num+=1 bytenum = num.to_s.length if bytenum == 1 zeros = "00" end if bytenum == 2 zeros = "0" end if bytenum >= 3 zeros = nil.to_s end #c.name = component.layer.name.concat(" - #{zeros}#{num}") c.definition.name = component.layer.name.concat(" - #{zeros}#{num}") end end end end
@bagatelo said:
The reason I asked this plugin is because I'm trying to use the plugin "Solid Quantify by TAK2HATA". It's a wonderful plugin, and I need something to easily modify the names of components. Note the attachment files.
Will check it out indeed.
Advertisement