sketchucation logo sketchucation
    • Login
    πŸ’‘ LightUp 7.1 | SketchUp's only real-time renderer that uses object-based rendering Download Trial

    How do i change length attributes in ruby

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 3 Posters 728 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      agenor
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • TIGT
        TIG Moderator
        last edited by

        This looks like it is a DC question - there is a specialist forum for those...

        TIG

        1 Reply Last reply Reply Quote 0
        • A
          agenor
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • TIGT
            TIG Moderator
            last edited by

            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...

            TIG

            1 Reply Last reply Reply Quote 0
            • blruuskaB
              blruuska
              last edited by

              Agenor, changing the length on a DC can be tricky. See this discussion:
              https://groups.google.com/forum/#!topic/sketchupruby/630uerkDhJI/discussion

              1 Reply Last reply Reply Quote 0
              • TIGT
                TIG Moderator
                last edited by

                Read the link carefully...
                You have set_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...

                TIG

                1 Reply Last reply Reply Quote 0
                • A
                  agenor
                  last edited by

                  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.

                  1 Reply Last reply Reply Quote 0
                  • TIGT
                    TIG Moderator
                    last edited by

                    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. πŸ˜•

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post
                    Buy SketchPlus
                    Buy SUbD
                    Buy WrapR
                    Buy eBook
                    Buy Modelur
                    Buy Vertex Tools
                    Buy SketchCuisine
                    Buy FormFonts

                    Advertisement