PLUGIN for component definition naming
-
Is it possible to have a plugin that will configure the definition (not the name) as the text that is attached to the component?
I have one of TIG's console scripts for TIG.selected_connected_into_components and works great for defining 'component#1', 'component#2' ..... But since the version of cultist 4.1.4 and even before of the 4.1 versions do not have the list description using "name" instead of "definition", and we have the ability to auto change definition upon a group command stated above, is there a way to add to this script to have it instead of saying "component#" but say the text that is attached to the component?
This way, when I create a cultist, I can first auto rename all components independently defined but in a single command so the cultist recognizes them as unique names instead of 'component#'. I know I can simple click on the component and manually change each one to the text I have identified them with, but was not sure if it was possible to have this plugin (as it is the only one I found that works well for auto component anything so far) take the text name as the definition.
Hope that makes sense.
My workflow goes where I create a model (without components, just because it is easier for me to do it that way since my models require adjusting for optimizing them, then I take off parts to see the assembly and add text to identify it BEFORE it is exploded, then manually explode (since its not components yet) and again re-text them pieces and then use the mentioned above command to turn them all into components at once.
I just want to try to speed up the workflow by having the text show up as the definition if possible.
-
Yes, here is the file I was working on. It might have hidden dynamic components to it also that I am not sure how to get rid of lol, because when I run a script to set components in order by grid size of 1 x 1 it duplicates the number of visual components (25) to 50. But aside from that, it has the text on them I believe I have as a separate layer also (not sure if that makes a difference or not but worth mentioning I imagine). And the correct labels are there now because I did it by hand, but with the TIG.selected_connected_into_components script if you use that, you will see the definitions will be 'component#' instead of what I have now, which cutlist uses instead of the name field when generating the csv file in the "description" column (where the names should be). Hope this helps. If you need me to revert to TIG.selected_connected_into_components script components, let me know. I have the .rb.
-
Could you post a sample model, version 2014 or earlier, for testing purposes.
I have created my own but I prefer to test against yours.
-
As you can see from my previous post, I assumed that I would be working with a pre TIG.selected_connected_into_components.
So I copied the parts to a new model and exploded them before remaking the components with this simple method
mod = Sketchup.active_model ent = mod.active_entities sel = mod.selection txt = ent.grep(Sketchup;;Text) sel.add ent.to_a txt.each{|t|sel.remove t} until sel.empty? cde = sel.first.all_connected bb = Geom;;BoundingBox.new();name=nil cde.each{|e| bb.add e.bounds;sel.remove e} txt.each{|t| (name=t.text;break) if bb.contains?(t.point)} if name grp = ent.add_group cde;grp.name=name cmp = grp.to_component;cmp.name=cmp.definition.name=name end end
-
@sdmitch said:
As you can see from my previous post, I assumed that I would be working with a pre TIG.selected_connected_into_components.
So I copied the parts to a new model and exploded them before remaking the components with this simple method
mod = Sketchup.active_model > ent = mod.active_entities > sel = mod.selection > txt = ent.grep(Sketchup;;Text) > sel.add ent.to_a > txt.each{|t|sel.remove t} > until sel.empty? > cde = sel.first.all_connected > bb = Geom;;BoundingBox.new();name=nil > cde.each{|e| bb.add e.bounds;sel.remove e} > txt.each{|t| (name=t.text;break) if bb.contains?(t.point)} > if name > grp = ent.add_group cde;grp.name=name > cmp = grp.to_component;cmp.name=cmp.definition.name=name > end > end >
Looks like that worked. Did it base the coding off the attached text? Also, may I have the executable in the console for it? I do not know how to ruby Did it flow well for you? Thank you very much for your help so far!
-
Yes it only creates a component if there is "attached" text.
I will put the code into a plugin and send it to you by Personal Message.
-
@sdmitch said:
Yes it only creates a component if there is "attached" text.
I will put the code into a plugin and send it to you by Personal Message.
Wonderful thank you very much This is my first time asking for help on here and I appreciate every bit of return given!
Advertisement