Len X remains incorrect after using the push pull tool inside the component and then doing a redraw. It should update on redraw I am pretty sure but for some reason it won’t. Any help appreciated.
2x lumber.skp (445.5 KB)
Len X remains incorrect after using the push pull tool inside the component and then doing a redraw. It should update on redraw I am pretty sure but for some reason it won’t. Any help appreciated.
Not if actually change the definition’s geometry that way. Try instead scaling the instance.
Usually I do scale, sometimes I need to get inside and tweak it. It has something to do with the material scaler.
Whilst inside, I think you altered the length (lenx) so it became out of sync, used tape inside the DC measured and entered correct length then allowed resize, so should be okay now
2x lumber.skp (457.2 KB)
I consider it a bug, and an old one at that, but if you delete the _lenx_nominal
attribute from the Definition, the value should be right after a redraw.
@pcmoor is correct that it’s best not to scale a DC from within.
Save a copy of your model if you try this - no one can be certain what the results will be. That said, I’ve not had any troubles deleting any of the *_nominal
attributes.
Sketchup.active_model.selection[0].definition.delete_attribute("dynamic_attributes", "_lenx_nominal")
This worked like a charm! Thanks Jim. Does this bit of Ruby affect the entire model or just the selected component? And if I wanted to delete y&z as well, just add two lines and adjust the letter? Much appreciated.
It affects only the selected component.
Technically and using the SketchUp API terminology, it removes the _lenx_nominal
attribute from the AttributeDictionary
named “dynamic_attributes
” from the ComponentDefinition
of the selected ComponentInstance
.
Yes, you can replace x
with y
and z
. But the attribute is actually recreated during the redraw only with the actual X dimension of the component. I don’t know the purpose of these nominal attributes but deleting them does fix this particular problem.
There are a couple attribute inspector extensions in the extension warehouse that will let you see all the attributes created in a DC - there is a lot more going on than it appears at first glance.
Hey @DanRathbun, is it possible to write a ruby script that would purge nominal xyz from all selected dc’s and redraw all ( like in this thread - Redraw all dynamic components? - #10 by DanRathbun ) all in one fell swoop? Would be super cool and very helpful.
Most likely with current versions. However, Trimble is getting more “picky” about code accessing or changing proprietary attribute dictionaries. (I don’t know if going forward we will be able to “fix” the DC extension with our little “hacks”.)
Jim showed the way in a post above.
Here is context menu item that just does the nominal reset …
UI.add_context_menu_handler do |menu|
ss = Sketchup.active_model.selection
if !ss.empty?
insts = ss.grep(Sketchup::ComponentInstance)
if !insts.empty? &&
insts.any? {|obj|
obj.definition.attribute_dictionary("dynamic_attributes",false)
}
menu.add_item("Reset Nominal XYZ") {
insts.each do |inst|
cdef = inst.definition
next unless cdef.attribute_dictionary("dynamic_attributes",false)
cdef.delete_attribute("dynamic_attributes", "_lenx_nominal")
cdef.delete_attribute("dynamic_attributes", "_leny_nominal")
cdef.delete_attribute("dynamic_attributes", "_lenz_nominal")
end
}
end
end
end
Works like a charm. You are skilled at your craft sir. Thanks!
Umm, how would this look if I wanted it assigned to a button with toolbar editor?
Something like …
reset_nominal_cmd = UI::Command.new("Reset Nominal XYZ") {
ss = Sketchup.active_model.selection
insts = ss.grep(Sketchup::ComponentInstance)
insts.each do |inst|
cdef = inst.definition
next unless cdef.attribute_dictionary("dynamic_attributes",false)
cdef.delete_attribute("dynamic_attributes", "_lenx_nominal")
cdef.delete_attribute("dynamic_attributes", "_leny_nominal")
cdef.delete_attribute("dynamic_attributes", "_lenz_nominal")
end
}.set_validation_proc {
Sketchup.active_model.selection.empty? ? MF_GRAYED|MF_DISABLED : MF_ENABLED
}
toolbar.add_item(reset_nominal_cmd)
The full validation for the context menu item is too “expensive” (timewise as it checks for component instances and if any are DCs) to implement as a validation proc to gray out the button for toolbars, so the button will always be enabled if the selection is non-empty, but just do nothing if the selection contains no instances and will skip non-DC component definitions.
For menu items speed is not such an issue because validation procs only run when the menu is displayed (after a right-click or choosing a submenu from the overhead menus,) … but toolbar button validation procs run all the time just about each time the mouse moves, so they need to have the bare minimum of code.
P.S. - I did not show the statements for assigning tooltips, status bar text nor button icon paths.
Refer to the docs for this …
UI::Command
classThanks Dan, much appreciated.
Solution here.