How do i change length attributes in ruby
-
How do i change the length attributes lenx, leny, lenz to a value without using a formula.
if i use the set_attribute('dynamic_attributes', '_lenx_formula', number)
the component will not be scalable anymore -
This looks like it is a DC question - there is a specialist forum for those...
-
I don't see that it's specially related to dc
I think its more a developer issue that you are not able to change x, y, z position and length of an object dynamic or not
you are able change everything else as layer, material an so on.I hope that somebody can give me a solution or maybe I need to send an change request to the developer team of sketchup.
-
But this is a DC question???
'Attributes' relate to DCs [or to attribute-dictionaries assigned to objects in a SKP].
DC stuff and Ruby stuff have only a tenuous interface...
If you want to change an objects properties in Ruby you can do so in code, so
group.material='Red'
etc... BUT you can also change this using transformations - these move, rotate and scale objects.
If you wish to affect the DC's attribute within Ruby code you need to ensure you are changing the correct attributes and force a redraw afterwards...
Your example seems to replace a formula with a value rather than reset some dimensions and then recalculate using the formula...
Perhaps a little more explanation and some more code would help us help you... -
Agenor, changing the length on a DC can be tricky. See this discussion:
https://groups.google.com/forum/#!topic/sketchupruby/630uerkDhJI/discussion -
Read the link carefully...
You haveset_attribute('dynamic_attributes', '_lenx_formula', number)
which breaks the '_lenx_formula' as it's become a fixed 'number' NOT a formula, but if you change the values of the attributes that are actually used in the 'formula' instead and do the 'redraw' etc it should regenerate BUT still leave the original formula to work again... -
Thanks for the answers tig and blruuska!
Yes it's tricky to change these parameters.
specially when ther are no documentation.
I have tried to use _lenx_formula and ended up with unscalable components because
lenx is stored as '=value' and not value.
If i manually put in a value and not a formula it is stored back without "=" inthe formula field.
so there should be a way to do this in ruby.For other attributes i created myself, i managed to go from formula back to just a value
but for default attributes like lenx this method is unusable.I have now spend days trying to turn every stone on the web.
And found out that there are many developers stuck with the same result.Maybe i cold use transformation and scale for the length.
but i would still not end up with an exact value.
Because scale is % of length and values are internally
stored in inch and not metric the result is that i end up with a lot of decimals. -
If 'lenx' is '=value' can't you change the contents of the 'value' attribute itself [or if that is itself set in some complex way then change the attribute[s] that it is using etc...], which on a redraw then changes the contents of the DC.
Advertisement