How to show property value in HTML Description
-
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
LenYand 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?
-
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? -
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
-
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.
-
@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.
-
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! -
@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! -
(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
Advertisement