Force Dynamic Components to Redraw

Hi all,

I’m actually writing a wall tool that wrap a dynamic component placement, orientation and scaling. Everything works fine except that I’m unable to force the dynamic component to be refreshed/redrawn correctly

I found @DanRathbun post regarding the way to force a dynamic component to be redrawn.

That works perfectly for a single usage but doesn’t for subsequent use. When I add an another instance of my dynamic component that use the ScaleTool behaviour with my drawing tool I get the dynamic component instance redrawn using both previous and current scale factors.

Any idea of what append cause I’m unable to understand that code snippet and there’s no documentation regarding the dynamic components
:
$dc_observers.get_latest_class.redraw_with_undo(inst)

Thanks all for your help as usual :wink:

Ok my mistake, I didn’t well understood how the dynamic component worked. I was using them like standard component, ie :

  1. First iteration
  • Sourcing the component definitions in the model
  • Inserting a instance with its transform (with scale implying the definition to be updated).
  • Force a redraw.
  1. Second iteration
  • The component was already sourced into the model so I was directly inserting an instance into my model with its transform with again a scale factor applied on a modified definition and leads to a new definition generated.
  • Force a redraw update to something unwanted.

Manual exemple below :

https://forums.sketchup.com/uploads/short-url/b0RFTppYOV3cAqiWL4n1cFdaplN.mp4

Have a look at http://sdmitch.blogspot.com/ and the scale_align.rb

could be you have not allowed for the scale between the original component and the new length

guess this not the problem, all sorted!

Thanks @pcmoor but the problem was that the second time I was computing a scale factor based on a definition that have been modified at the first iteration (as I didn’t noticed that scaling a dynamic component leads to updating the definition), so I wasn’t computing the right scale factor.

I’m now reinserting my base dynamic component at each use unless the requested length already have been drawn (then reuse the existing one)

1 Like