sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    How to show property value in HTML Description

    Scheduled Pinned Locked Moved Dynamic Components
    sketchup
    8 Posts 4 Posters 1.6k Views 4 Watching
    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.
    • N Offline
      Nick60
      last edited by

      Is it possible to reference a property value in the HTML Description of the dinamic component?

      Suppose I have a component with two properties visible and editable with two textbox:

      LenX
      LenY

      and a third property, not visible:

      AreaXY = LenX * LenY

      I'd like to have the description property written as (some sort of):

      
      Description = "This is the fabulous Rectangle component<p>You can set LenX and LenY<p>The calculated area, based on your input is ${AreaXY}"
      
      

      Is it possible?

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        I think he was talking within the context of DC capabilities. Using a ruby script to do so requires all users of the DC to also use that ruby script, which limits the DC's usability.

        I don't know if that can be done with the current DC implementation though.
        But isn't it enough to have the area as a read only property? Instead of integrated into the description?

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • J Offline
          Jim
          last edited by

          I think you can just use it in-line. For example, if you had a custom name based on the LenX:

          name: ="K98-"&LenX&"-0"

          The & (ampersand) performs a concatenation.

          A little bit of info here:

          http://sketchup.google.com/support/bin/answer.py?hl=en&answer=114553

          Hi

          1 Reply Last reply Reply Quote 0
          • N Offline
            Nick60
            last edited by

            Thanks everybody for the replies.

            @thomthom: Yes, you're right, I'd like to embed a property value inside the HTML of the description, within the context of DC capabilities. So both Dan and Jim proposed solution are not viable.
            To answer your question, I can compute a validation error message like (for example):

            UserParamCheck = IF(OR(Foo < 10, Foo > 300), 1, 0)
            ErrorMessage = IF(UserParamCheck,"","Hi, the value of Foo must be between 10 and 300")

            and (if possible) insert the error message in the HTML.

            That way the user will see it only if there is an error, without cluttering the User Interface with a read only property in the input area.

            1 Reply Last reply Reply Quote 0
            • J Offline
              Jim
              last edited by

              @nick60 said:

              So both Dan and Jim proposed solution are not viable.

              What I mentioned will work in the Description of a DC. Just substitute your ErrorMessage with my LenX in the Description.

              Hi

              1 Reply Last reply Reply Quote 0
              • N Offline
                Nick60
                last edited by

                WOW!
                Soo easy I coudnt imagine. Description IS a property, so I can use the equal sign and all the formulas to calculate the value.
                Many thanks Jim!

                1 Reply Last reply Reply Quote 0
                • Dan RathbunD Offline
                  Dan Rathbun
                  last edited by

                  @nick60 said:

                  So ... Dan ... proposed solution ... not viable.

                  Woops.. sorry, I saw HTML and thot you were asking about webdialogs. (I guess it is the DC Properties Dialog you meant.)
                  ... my bad! 😳

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • Dan RathbunD Offline
                    Dan Rathbun
                    last edited by

                    (edit) **Disregard - Off Topic**
                    HTML

                    
                    <HTML>
                    <HEAD>
                    </HEAD>
                    <BODY onload="GetXYfromRuby()">
                    
                    <INPUT TYPE=text VALUE="" NAME="LenX">
                    <INPUT TYPE=text VALUE="" NAME="LenY" onchange="CalcArea()">
                    
                    <!-- put this description DIV anywhere you want -->
                    <DIV ID="Description">This is the fabulous Rectangle component<p>You can set LenX and LenY<p>The calculated area, based on your input is <SPAN ID="Span_AreaXY"></SPAN></DIV>
                    
                    <!-- at the bottom of your webDialog HTML -->
                    <SCRIPT Language="Javascript">
                    function ShowAreaXY(AreaXY) {
                      Span_AreaXY.innerText=AreaXY.toString();
                    }
                    function CalcArea() {
                      var AreaXY;
                      AreaXY=LenX.value*LenY.value;
                      ShowAreaXY(AreaXY);
                    }
                    GetXYfromRuby() {
                    window.location.href = 'skp;get_data@queryforXY';
                    // your ruby callback will do two commands;
                    // js_command = 'LenX.value=componentLenX;'
                    // js_command = 'LenY.value=componentLenY;'
                    // when LenY INPUT control gets value the onchange event fires
                    //  calling CalcArea() which then calls ShowAreaXY
                    }
                    </SCRIPT>
                    </BODY>
                    </HTML>
                    
                    

                    Havenot tested this, so you'll need to wring out the bugs.
                    For example of the ruby callback, See:
                    http://sketchupapi.blogspot.com/2008/02/sharing-data-between-sketchup-ruby-and.html

                    I'm not here much anymore.

                    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