Dynamic Component Error - Can anyone confirm

I’ve actually posted a similar topic but this time I’ll be a little more specific…
LenZ values break in Dynamic Component ONLY if it includes a sub-component with
references to the Parent component’s Len Values and then ONLY if the Parent Component’s
size is changed on more the one occasion. Not by scaling (although I haven’t tried this) but by changing the geometry
within the Parent component (which should change the Len values but does not)…

I’d love to see if anyone else can reproduce this - this time I’ve included a link to the file.

HERE’S THE FILE

DC’s have been that way since the beginning. Here’s basically the same question asked six years ago: Are DC's Completely Broken? • sketchUcation • 1

If you open the instance and scale the internal, loose geometry, then the
actual size gets out of sync with the size reported in the Dialog.

Similarly, if you scale the internal, loose geometry to match the size reported in
the Dialog, you can get the actual and reported length back in sync.

Bug or not just remember to resize components using the Scale tool from outside their editing context instead of PushPulling (or scaling) the faces from within their editing context.

Edit: Just remembered also that if you scale a DC then type a value in the Measurements box, you need to Redraw the DC manually because entering values after the scaling does not trigger a redraw.

Thanks Jim, it does sound like the last thread from 6 years ago - I swear I tried searching for the answer to my question dozens of times…

Just a quick question, the last post talked about “the lengths being out of sync”. Do you think it would be possible to have a Ruby script force the Len values to Re-Calculate based off the internal geometry to fix this??? - so the Len values once again equals the size of all internal geometry.

The reason this is important to me is as follows.

I have a WALL component which determines stud length.
I can add a window component inside the WALL which can calc jam studs (at the same height as the WALL by referencing parent!)
The window can cut face seeing its in the same frame of reference as the WALL’s un-grouped geometry.
I can also use a material on the WALL’s un-grouped geometry & because it is not scaled, the cladding texture can line up with other walls.

This is my problem with scaling the sub-components or the parent component. If I can find a solution to that then I have no need to use un-grouped geometry and everything can just be scaled…

Cheers

Yeah I’ve learned that one the hard way LOL.

Even if I could just select all the walls and windows in one group and change the “wall_height” attribute for all of the different components at the one time. That would help.

I also noticed in the past thread…

Re: Are DC’s Completely Broken?
Postby Chris Fullmer » Tue May 11, 2010 4:30 pm
oh that’s interesting. That sounds like a bug should be reported on that one. It should re-check the size of internals every so often I would think…

I have been experimenting with this. Yes, it appears to be possible although I do not know exactly how or why it works.

It seems if you delete the _len[x|y|z]_nominal attributes then do a redraw, the DC uses its actual dimensions again.

The following code adds a right-click menu named “DC Actual Size” to components when right-clicked on.

UI.add_context_menu_handler do |menu|
   ins = Sketchup.active_model.selection[0]
   if ins && ins.class == Sketchup::ComponentInstance && ins.definition.attribute_dictionary("dynamic_attributes")
      menu.add_item("DC Actual Size") do 
         %w(x y z).each {|a|
            ins.definition.delete_attribute("dynamic_attributes", "_len#{a}_nominal")
         }
         $dc_observers.get_latest_class.redraw_with_undo(ins)
      end
   end

end

Link to: Developers > Ruby API: Ruby Errors in Dynamic Components

You are a legend Jim. Absolute legend… I really appreciate it… I’ve swapped this function for Redraw (I had assigned to Shift+R) so I just substituted it & include it in my normal workflow - (ie I needed to redraw my components anyway so they properly calculate areas etc, so there really is no extra step involved) brilliant!

I actually started getting back into learning Ruby scripting last night after this problem occurred (I gave up earlier because I just couldn’t find the time) but I knew there had to be a solution & you’ve inspired me to keep learning… Now I can do what I need to do and can move forward with my project. Where do I send your beer…