<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://kfdani-001-site10.gtempurl.com/index.php?action=history&amp;feed=atom&amp;title=OpenSite%2FGuides%2FNative_property_formulas</id>
	<title>OpenSite/Guides/Native property formulas - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://kfdani-001-site10.gtempurl.com/index.php?action=history&amp;feed=atom&amp;title=OpenSite%2FGuides%2FNative_property_formulas"/>
	<link rel="alternate" type="text/html" href="https://kfdani-001-site10.gtempurl.com/index.php?title=OpenSite/Guides/Native_property_formulas&amp;action=history"/>
	<updated>2026-10-30T02:02:03Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.2</generator>
	<entry>
		<id>https://kfdani-001-site10.gtempurl.com/index.php?title=OpenSite/Guides/Native_property_formulas&amp;diff=863&amp;oldid=prev</id>
		<title>BathAfrica: Add rewritten practical lesson with steps, code and expected results</title>
		<link rel="alternate" type="text/html" href="https://kfdani-001-site10.gtempurl.com/index.php?title=OpenSite/Guides/Native_property_formulas&amp;diff=863&amp;oldid=prev"/>
		<updated>2026-10-29T21:01:01Z</updated>

		<summary type="html">&lt;p&gt;Add rewritten practical lesson with steps, code and expected results&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__NOTOC__&lt;br /&gt;
{{OpenSite scope}}&lt;br /&gt;
{{OpenSite lesson&lt;br /&gt;
|id=opensite.help.native-property-formulas&lt;br /&gt;
|summary=Make one property depend on another with OpenSite’s restricted formula language.&lt;br /&gt;
|prerequisites=Embedded Python with the development host for the rectangular-section fixture. No Python-expression consent is needed for a native formula.&lt;br /&gt;
|steps==== Create the fixture ===&lt;br /&gt;
Start with a width of 250 mm and height of 500 mm.&lt;br /&gt;
&lt;br /&gt;
=== Store a formula instead of a literal ===&lt;br /&gt;
Set height to &amp;lt;code&amp;gt;object(id).width * 2&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;language=&amp;quot;formula&amp;quot;&amp;lt;/code&amp;gt;. The object ID must be the actual ID returned by this document.&lt;br /&gt;
&lt;br /&gt;
=== Change the source value ===&lt;br /&gt;
Set width to 300 mm. The native dependency system recomputes height as 600 mm.&lt;br /&gt;
&lt;br /&gt;
=== Inspect the stored source ===&lt;br /&gt;
Read &amp;lt;code&amp;gt;doc.expression(id, &amp;quot;height&amp;quot;)&amp;lt;/code&amp;gt;. A label is a display name; use the document’s stable references rather than inventing an ID.&lt;br /&gt;
&lt;br /&gt;
|result=Height changes from 0.50 m to 0.60 m after editing width. The formula source remains stored on height.&lt;br /&gt;
|limitations=The formula language is not arbitrary Python. A dimension mismatch or dependency cycle is rejected. Writing a literal to an expression-bound property replaces that expression.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Complete example ==&lt;br /&gt;
{{Code|lang=python|code=&amp;lt;nowiki&amp;gt;import opensite&lt;br /&gt;
&lt;br /&gt;
created = opensite.execute(&amp;quot;document.create_section&amp;quot;, {&lt;br /&gt;
    &amp;quot;label&amp;quot;: &amp;quot;FormulaBeam&amp;quot;,&lt;br /&gt;
    &amp;quot;width&amp;quot;: opensite.QuantityArgument(opensite.Q(&amp;quot;250 mm&amp;quot;), &amp;quot;mm&amp;quot;),&lt;br /&gt;
    &amp;quot;height&amp;quot;: opensite.QuantityArgument(opensite.Q(&amp;quot;500 mm&amp;quot;), &amp;quot;mm&amp;quot;),&lt;br /&gt;
})&lt;br /&gt;
doc, object_id = created[&amp;quot;document&amp;quot;], created[&amp;quot;object&amp;quot;]&lt;br /&gt;
opensite.execute(&amp;quot;document.set_expression&amp;quot;, {&lt;br /&gt;
    &amp;quot;document&amp;quot;: doc, &amp;quot;object&amp;quot;: object_id, &amp;quot;property&amp;quot;: &amp;quot;height&amp;quot;,&lt;br /&gt;
    &amp;quot;expression&amp;quot;: f&amp;quot;object({object_id}).width * 2&amp;quot;, &amp;quot;language&amp;quot;: &amp;quot;formula&amp;quot;,&lt;br /&gt;
})&lt;br /&gt;
beam = doc.get_object(object_id)&lt;br /&gt;
assert abs(beam.height.si_value - 0.50) &amp;lt; 1e-12&lt;br /&gt;
beam.set_property(&amp;quot;width&amp;quot;, opensite.Q(&amp;quot;300 mm&amp;quot;))&lt;br /&gt;
assert abs(beam.height.si_value - 0.60) &amp;lt; 1e-12&lt;br /&gt;
print(&amp;quot;Formula:&amp;quot;, doc.expression(object_id, &amp;quot;height&amp;quot;))&lt;br /&gt;
print(&amp;quot;Height:&amp;quot;, beam.height.value_in(&amp;quot;mm&amp;quot;), &amp;quot;mm&amp;quot;)&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;os-page-nav&amp;quot;&amp;gt;{{Docnav|OpenSite/Guides/Exchange materials|OpenSite/Guides/Python property expressions|OpenSite/Guides|All guides}}&amp;lt;/div&amp;gt;&lt;br /&gt;
[[Category:OpenSite documentation]]&lt;/div&gt;</summary>
		<author><name>BathAfrica</name></author>
	</entry>
</feed>