Kill dynamic components?
-
How do I make a dynamic component non dynamic. Sometimes I want to make some changes in the dynamic component, but the "settings" of the groups make the components unmovable. For example move the legs of a table to another position. I want to keep the groups of the object that the dynamic component exists of, but clear all settings.
Thanks in advance.
-
This one-liner copy+paste+<enter> in the Ruby Console will stop a selected DC from being dynamic
Sketchup.active_model.selection[0].definition.attribute_dictionaries.delete('dynamic_attributes')
use wisely...
-
I have a plugin that can "strip DC attributes", optionally delete sub-components which are hidden, and reset the scale mask. I wrote it for a business that uses DC's internally but wanted to protect their IP and reduce file size before making their models public. I have been meaning to get it posted.
-
How about exploding and immediately creating a new component?
Another way is to insert the DC in a new model, save it and import that. The DC attributes won't be usable until you explode the component once. Exploiting a common error with DCs.
Anssi
-
@jim said:
I have a plugin that can "strip DC attributes", optionally delete sub-components which are hidden, and reset the scale mask. I wrote it for a business that uses DC's internally but wanted to protect their IP and reduce file size before making their models public. I have been meaning to get it posted.
I'm very interested, could you send it to me in some way?
-
@tig said:
This one-liner copy+paste+<enter> in the Ruby Console will stop a selected DC from being dynamic
Sketchup.active_model.selection[0].definition.attribute_dictionaries.delete('dynamic_attributes')
use wisely...
Hm, yes it worked. But I want to keep the groups in the component. Now I get the same problem as when exploding the component as many times as possible and then making a new component.
Thanks anyway -
You asked to "kill dynamic components" - thats what his one line script does.
So what do you REALLY want to do?
-
@chris fullmer said:
You asked to "kill dynamic components" - thats what his one line script does.
So what do you REALLY want to do?
In my first post I wrote: "I want to keep the groups of the object that the dynamic component exists of, but clear all settings."
I just want the component attributes to be cleared. But I want to keep the groups in the component.
-
Sketchup.active_model.selection[0].definition.attribute_dictionaries.delete('dynamic_attributes')
just stops the selected DC from being a DC!
If you have nested DC's within a DC you'll need to run the tool recursively like thisdef dck(c);c.definition.attribute_dictionaries.delete('dynamic_attributes');c.entities.each{|e|dck(e)if e.class==Sketchup;;ComponentInstance};end;dck(Sketchup.active_model.selection[0])if e.class==Sketchup;;ComponentInstance
where the method 'dck' is the 'dc_killer' applied to a selected component AND all of its nested DCs down to any depth... use with care
-
@jim said:
I have a plugin that can "strip DC attributes", optionally delete sub-components which are hidden, and reset the scale mask. I wrote it for a business that uses DC's internally but wanted to protect their IP and reduce file size before making their models public. I have been meaning to get it posted.
Hi, I know this was a while ago - but any chance I could snag the plugin you reference? Thanks.
s.
-
@tig said:
Sketchup.active_model.selection[0].definition.attribute_dictionaries.delete('dynamic_attributes')
just stops the selected DC from being a DC!
If you have nested DC's within a DC you'll need to run the tool recursively like this
def dck(c);c.definition.attribute_dictionaries.delete('dynamic_attributes');c.entities.each{|e|dck(e)if e.class==Sketchup;;ComponentInstance};end;dck(Sketchup.active_model.selection[0])if e.class==Sketchup;;ComponentInstance
where the method 'dck' is the 'dc_killer' applied to a selected component AND all of its nested DCs down to any depth... use with care
I tried pasting this into the ruby editor - but it didn't work
"Error: #<NameError: undefined local variable or method `e' for main:Object>"
I'm in SU15. The single line top-level version did work....but I'm really trying to zap the tree.
s.
-
@skavan said:
I tried pasting this into the ruby editor - but it didn't work
"Error: #<NameError: undefined local variable or method `e' for main:Object>"
I'm in SU15. The single line top-level version did work....but I'm really trying to zap the tree.
s.
I'm getting the same error. Ideas?
-
@halroach said:
@skavan said:
I tried pasting this into the ruby editor - but it didn't work
"Error: #<NameError: undefined local variable or method `e' for main:Object>"
I'm in SU15. The single line top-level version did work....but I'm really trying to zap the tree.
s.
I'm getting the same error. Ideas?
Try
def dck(c);c.definition.attribute_dictionaries.delete('dynamic_attributes');c.definition.entities.each{|e|dck(e)if e.class==Sketchup;;ComponentInstance};end;dck(Sketchup.active_model.selection[0])
after selecting the dynamic component.
-
I'm not sure what other aspects of sketchup may be lost?...But saving as sketchup version 6 or below removes dynamic attributes, retaining the component and sub components.
Advertisement