Script: Example in Blockly

Example in Blockly picture
Type
Blockly logo indicatorblockly
Date Created
Mar 19, 2021, 2:06:46 PM
Last Edit Date
Dec 5, 2023, 8:06:29 PM

Project Information

This example demonstrates few boolean operations that can be done on solids to produce a vase. On top of the script users can change various parameters and adapt the model to their needs and choose to export this model to STL format.

View Full Project

Script Code

<xml xmlns="https://developers.google.com/blockly/xml">
 <variables>
  <variable id="XV?j1-KI*6ajtgjJ)Pg5">radiusOfVase</variable>
  <variable id="/JyE;24I28l]U4Eff7kr">heightOfVase</variable>
  <variable id="|X{69QJGmnWqN9Z-s^Q5">thicknessFraction</variable>
  <variable id="ZDD#5:Nv?HWjdY*}stH6">heightBottomOfVase</variable>
  <variable id="f1_I@Jq{f0VaYVAe-H)/">intersectHeight</variable>
  <variable id=",R)k2d=9z|P0Qxd,LJFC">downloadSTL</variable>
  <variable id="3qVWJ6m=nsUms{F,4Ep.">topPartOfVase</variable>
  <variable id="76iXtlG8gmh?B3Ivd-UT">bottomPartOfVase</variable>
  <variable id="rsQ@.,}Vzd}CRWsbB0}]">vase</variable>
 </variables>
 <block type="bitbybit.babylon.scene.drawPointLightNoReturn" id="R[5gX0/T3N-^|.,=8o0W" x="-4620" y="-737">
  <value name="Position">
   <block type="bitbybit.point.pointXYZ" id="drH-~}T4@xw,,vm,!m!m">
    <value name="X">
     <block type="math_number" id="tT[+]KQS|-j,bw7uqXC/">
      <field name="NUM">20</field>
     </block>
    </value>
    <value name="Y">
     <block type="math_number" id="+BuX=idt_64PI_GAeO!Y">
      <field name="NUM">-5</field>
     </block>
    </value>
    <value name="Z">
     <block type="math_number" id="eXt[pcc6)VZDFVQCl6oO">
      <field name="NUM">5</field>
     </block>
    </value>
   </block>
  </value>
  <value name="Intensity">
   <block type="math_number" id="N%3;X5P%n./er3l{=:|G">
    <field name="NUM">1000</field>
   </block>
  </value>
  <value name="Diffuse">
   <block type="colour_picker" id="|=`ZD~Z4$Exf{S=}bv{^">
    <field name="COLOUR">#ffffff</field>
   </block>
  </value>
  <value name="Specular">
   <block type="colour_picker" id="+))Kl*(IkzQgw;7afHzK">
    <field name="COLOUR">#ffffff</field>
   </block>
  </value>
  <value name="Radius">
   <block type="math_number" id="^b,!KG^gvGGmat93_?Jf">
    <field name="NUM">0</field>
   </block>
  </value>
  <value name="ShadowGeneratorMapSize">
   <block type="math_number" id="dU$[L}djjnZKv[bcsp@[">
    <field name="NUM">1024</field>
   </block>
  </value>
  <value name="EnableShadows">
   <block type="logic_boolean" id="qE|wfo4T#Ye#;V8Gq,vV">
    <field name="BOOL">TRUE</field>
   </block>
  </value>
  <value name="ShadowDarkness">
   <block type="math_number" id="D+yDRw$:.2a,`TKBwGM)">
    <field name="NUM">0</field>
   </block>
  </value>
  <next>
   <block type="variables_set" id="!ETE*,;6mCE}Bd$xAo(#">
    <field name="VAR" id="XV?j1-KI*6ajtgjJ)Pg5">radiusOfVase</field>
    <value name="VALUE">
     <block type="math_number" id="`H?V0z^Vv$]Qv~Ug~D*}">
      <field name="NUM">8</field>
     </block>
    </value>
    <next>
     <block type="variables_set" id="|0zVN@VyL]O7@WHibj)D">
      <field name="VAR" id="/JyE;24I28l]U4Eff7kr">heightOfVase</field>
      <value name="VALUE">
       <block type="math_number" id="`!MPx,OgKQux:c`e|xVN">
        <field name="NUM">7</field>
       </block>
      </value>
      <next>
       <block type="variables_set" id="4C;`8qUkHcW?rF^%tRwY">
        <field name="VAR" id="|X{69QJGmnWqN9Z-s^Q5">thicknessFraction</field>
        <value name="VALUE">
         <block type="math_number" id="|Q4dgJ3B|];ws,OEGqGU">
          <field name="NUM">0.9</field>
         </block>
        </value>
        <next>
         <block type="variables_set" id="t97VY0]5JxM]09k-@hF4">
          <field name="VAR" id="ZDD#5:Nv?HWjdY*}stH6">heightBottomOfVase</field>
          <value name="VALUE">
           <block type="math_arithmetic" id="]7@JY8lEirdP@yfUdy-z">
            <field name="OP">DIVIDE</field>
            <value name="A">
             <block type="variables_get" id="{!+G+Q8$.*F]u:I}?,{r">
              <field name="VAR" id="XV?j1-KI*6ajtgjJ)Pg5">radiusOfVase</field>
             </block>
            </value>
            <value name="B">
             <block type="math_number" id="8zWY|/.A}xi5njj513nD">
              <field name="NUM">6</field>
             </block>
            </value>
           </block>
          </value>
          <next>
           <block type="variables_set" id="ep^ZS/$7jFUGKT8*]WG`">
            <field name="VAR" id="f1_I@Jq{f0VaYVAe-H)/">intersectHeight</field>
            <value name="VALUE">
             <block type="math_arithmetic" id="o$~O)41zfB9gwEK@hvw:">
              <field name="OP">DIVIDE</field>
              <value name="A">
               <block type="variables_get" id="9-nSex`Z0;b1Jaya)utk">
                <field name="VAR" id="XV?j1-KI*6ajtgjJ)Pg5">radiusOfVase</field>
               </block>
              </value>
              <value name="B">
               <block type="math_number" id="_B|tN=Dq=c:VjyF*bMlo">
                <field name="NUM">12</field>
               </block>
              </value>
             </block>
            </value>
            <next>
             <block type="variables_set" id="@PKbCanhH;|6(K~Iz_ds">
              <field name="VAR" id=",R)k2d=9z|P0Qxd,LJFC">downloadSTL</field>
              <value name="VALUE">
               <block type="logic_boolean" id="xm@D3^]}y^{ouf(}8h$N">
                <field name="BOOL">FALSE</field>
               </block>
              </value>
              <next>
               <block type="variables_set" id="{;,4*tadjD9+1gq_hWzP">
                <field name="VAR" id="3qVWJ6m=nsUms{F,4Ep.">topPartOfVase</field>
                <value name="VALUE">
                 <block type="bitbybit.jscad.booleans.subtract" id="O+4%p7)x4%SG=%?ve(L#">
                  <value name="Meshes">
                   <block type="lists_create_with" id="tBOCr9QzA,iK[y5yQ!1h">
                    <mutation items="3">
                    </mutation>
                    <value name="ADD0">
                     <block type="bitbybit.jscad.shapes.geodesicSphere" id="Nr.8fGTm5~TZu|k,]^PP">
                      <value name="Center">
                       <block type="bitbybit.point.pointXYZ" id="OD1,pF-0GjO+Qw?jny/G">
                        <value name="X">
                         <block type="math_number" id="b6mOrHj{[ZujaRw22o2k">
                          <field name="NUM">0</field>
                         </block>
                        </value>
                        <value name="Y">
                         <block type="math_number" id=",7()+-2n#Y8;tepKLJNb">
                          <field name="NUM">0</field>
                         </block>
                        </value>
                        <value name="Z">
                         <block type="math_number" id="-lp8V*T3}_gGdnwkIwA*">
                          <field name="NUM">0</field>
                         </block>
                        </value>
                       </block>
                      </value>
                      <value name="Radius">
                       <block type="variables_get" id="|VFgWx4tU.i9ERQfxFBt">
                        <field name="VAR" id="XV?j1-KI*6ajtgjJ)Pg5">radiusOfVase</field>
                       </block>
                      </value>
                      <value name="Frequency">
                       <block type="math_number" id="n,s75pj*V|r.p?;u0LWL">
                        <field name="NUM">14</field>
                       </block>
                      </value>
                     </block>
                    </value>
                    <value name="ADD1">
                     <block type="bitbybit.jscad.shapes.geodesicSphere" id="WadtcOqfsQdn6n*+jZrd">
                      <value name="Center">
                       <block type="bitbybit.point.pointXYZ" id="$G^Sozo:lWs5%2*qEAg?">
                        <value name="X">
                         <block type="math_number" id=")|h]}${iuC5s;tss!Y#k">
                          <field name="NUM">0</field>
                         </block>
                        </value>
                        <value name="Y">
                         <block type="math_number" id="[AL0KdTuy!7.|B%9u+,r">
                          <field name="NUM">0</field>
                         </block>
                        </value>
                        <value name="Z">
                         <block type="math_number" id="P]{Vn|yobOQIZf+e?nyB">
                          <field name="NUM">0</field>
                         </block>
                        </value>
                       </block>
                      </value>
                      <value name="Radius">
                       <block type="math_arithmetic" id="xVIyD!9@7zD]YQKY0PLA">
                        <field name="OP">MULTIPLY</field>
                        <value name="A">
                         <block type="variables_get" id="vgt@ZpH/SRvjg]BWL0?p">
                          <field name="VAR" id="XV?j1-KI*6ajtgjJ)Pg5">radiusOfVase</field>
                         </block>
                        </value>
                        <value name="B">
                         <block type="variables_get" id="t6l:8NO4M`9Bw|`DoK`r">
                          <field name="VAR" id="|X{69QJGmnWqN9Z-s^Q5">thicknessFraction</field>
                         </block>
                        </value>
                       </block>
                      </value>
                      <value name="Frequency">
                       <block type="math_number" id="W,P5;@A=k;_%y!fc]Ow?">
                        <field name="NUM">12</field>
                       </block>
                      </value>
                     </block>
                    </value>
                    <value name="ADD2">
                     <block type="bitbybit.jscad.shapes.cube" id="3dye+$(+NRN227iMn|F|">
                      <value name="Center">
                       <block type="bitbybit.point.pointXYZ" id="c7xI6q-.B-48K}/AtR3P">
                        <value name="X">
                         <block type="math_number" id="_!:=spmj4_fx(;z$N1z(">
                          <field name="NUM">0</field>
                         </block>
                        </value>
                        <value name="Y">
                         <block type="variables_get" id="W/BaV2raLw?|A7!6+SHZ">
                          <field name="VAR" id="/JyE;24I28l]U4Eff7kr">heightOfVase</field>
                         </block>
                        </value>
                        <value name="Z">
                         <block type="math_number" id="Qe]%oc2z{(b:i)}qZ.gP">
                          <field name="NUM">0</field>
                         </block>
                        </value>
                       </block>
                      </value>
                      <value name="Size">
                       <block type="math_arithmetic" id="y`{uG)3IqhMgn-R{gz-B">
                        <field name="OP">MULTIPLY</field>
                        <value name="A">
                         <block type="variables_get" id="vb{;b*$O?!KpbDnUBTcv">
                          <field name="VAR" id="XV?j1-KI*6ajtgjJ)Pg5">radiusOfVase</field>
                         </block>
                        </value>
                        <value name="B">
                         <block type="math_number" id="^=5a-wGppKT|{]!3Re~e">
                          <field name="NUM">2</field>
                         </block>
                        </value>
                       </block>
                      </value>
                     </block>
                    </value>
                   </block>
                  </value>
                 </block>
                </value>
                <next>
                 <block type="variables_set" id="6C;jibz*%2Tw,VL7GJ8`">
                  <field name="VAR" id="76iXtlG8gmh?B3Ivd-UT">bottomPartOfVase</field>
                  <value name="VALUE">
                   <block type="bitbybit.jscad.transformSolid" id="c-z0F!@/*]vDjl!-tseI">
                    <value name="Mesh">
                     <block type="bitbybit.jscad.shapes.geodesicSphere" id="rNYLtZUmuV#9]Xmm*gP@">
                      <value name="Center">
                       <block type="bitbybit.point.pointXYZ" id="Zzn/5D1#v;}!Rb3!(H#S">
                        <value name="X">
                         <block type="math_number" id="aXXyQ,DOkH.@a?9OEv$)">
                          <field name="NUM">0</field>
                         </block>
                        </value>
                        <value name="Y">
                         <block type="math_arithmetic" id="Qu1QmeW8SE~(W2Z7@OIB">
                          <field name="OP">MINUS</field>
                          <value name="A">
                           <block type="math_single" id="mk#iQA(M-L$,Mzmo2Wk3">
                            <field name="OP">NEG</field>
                            <value name="NUM">
                             <block type="variables_get" id="TpyEAJ;q4=})o.X#:HfE">
                              <field name="VAR" id="XV?j1-KI*6ajtgjJ)Pg5">radiusOfVase</field>
                             </block>
                            </value>
                           </block>
                          </value>
                          <value name="B">
                           <block type="variables_get" id="$bPlC`sT.9u;ESBIq7cH">
                            <field name="VAR" id="f1_I@Jq{f0VaYVAe-H)/">intersectHeight</field>
                           </block>
                          </value>
                         </block>
                        </value>
                        <value name="Z">
                         <block type="math_number" id="7eBNPmd0_.2/o*n6?PcT">
                          <field name="NUM">0</field>
                         </block>
                        </value>
                       </block>
                      </value>
                      <value name="Radius">
                       <block type="variables_get" id="~w6^+OGLVItX*F3pt^#H">
                        <field name="VAR" id="ZDD#5:Nv?HWjdY*}stH6">heightBottomOfVase</field>
                       </block>
                      </value>
                      <value name="Frequency">
                       <block type="math_number" id="HHoqyb+?gfwCoGL+{ii]">
                        <field name="NUM">12</field>
                       </block>
                      </value>
                     </block>
                    </value>
                    <value name="Transformation">
                     <block type="bitbybit.babylon.transforms.scaleXYZ" id="BCQLr+Pp$|1^kl|o.?v8">
                      <value name="ScaleXyz">
                       <block type="bitbybit.vector.vectorXYZ" id="uK!yLDlwGvtILy7rA+f-">
                        <value name="X">
                         <block type="math_number" id="tEH9UipElV)1kW/3HpK7">
                          <field name="NUM">4</field>
                         </block>
                        </value>
                        <value name="Y">
                         <block type="math_number" id="[gj)A[mpZ9Ku3vNs,~|}">
                          <field name="NUM">1</field>
                         </block>
                        </value>
                        <value name="Z">
                         <block type="math_number" id="i100D84oKdBl]a3,?a]!">
                          <field name="NUM">4</field>
                         </block>
                        </value>
                       </block>
                      </value>
                     </block>
                    </value>
                   </block>
                  </value>
                  <next>
                   <block type="variables_set" id="6-SP2K1~/ysR4IF@iLyz">
                    <field name="VAR" id="rsQ@.,}Vzd}CRWsbB0}]">vase</field>
                    <value name="VALUE">
                     <block type="bitbybit.jscad.booleans.subtractTwo" id="mY*5pMYzmKnC}SkX)2I0">
                      <value name="First">
                       <block type="bitbybit.jscad.booleans.unionTwo" id="V`rJ[d0LrZVOBwTwIDLP">
                        <value name="First">
                         <block type="variables_get" id="XQ}OZC-~FR]YYJd2Q;/~">
                          <field name="VAR" id="3qVWJ6m=nsUms{F,4Ep.">topPartOfVase</field>
                         </block>
                        </value>
                        <value name="Second">
                         <block type="variables_get" id="`FKAlA]gO@iZB_VK6aW~">
                          <field name="VAR" id="76iXtlG8gmh?B3Ivd-UT">bottomPartOfVase</field>
                         </block>
                        </value>
                       </block>
                      </value>
                      <value name="Second">
                       <block type="bitbybit.jscad.shapes.cuboid" id="VHppk5JGPhZt_$/#T()S">
                        <value name="Center">
                         <block type="bitbybit.point.pointXYZ" id="/lTcvDn=9yH^yg}yt_1Y">
                          <value name="X">
                           <block type="math_number" id="}]-ego5#~EFKKbQcxIp5">
                            <field name="NUM">0</field>
                           </block>
                          </value>
                          <value name="Y">
                           <block type="math_arithmetic" id="Lrntl~u5^SBlJTOd[Kli">
                            <field name="OP">MINUS</field>
                            <value name="A">
                             <block type="math_arithmetic" id=".o0l]4V`V5${#/dv(!JH">
                              <field name="OP">MINUS</field>
                              <value name="A">
                               <block type="math_single" id="_WD9wV~-28Bx:7[F?@zi">
                                <field name="OP">NEG</field>
                                <value name="NUM">
                                 <block type="variables_get" id="of!a,%`v@bs=)MwLvkWN">
                                  <field name="VAR" id="XV?j1-KI*6ajtgjJ)Pg5">radiusOfVase</field>
                                 </block>
                                </value>
                               </block>
                              </value>
                              <value name="B">
                               <block type="variables_get" id="@A!8laJSE]vSXKjrlX/y">
                                <field name="VAR" id="f1_I@Jq{f0VaYVAe-H)/">intersectHeight</field>
                               </block>
                              </value>
                             </block>
                            </value>
                            <value name="B">
                             <block type="math_arithmetic" id="4~nrbA4$DDnpNj]8i2gA">
                              <field name="OP">DIVIDE</field>
                              <value name="A">
                               <block type="variables_get" id="J/I;{/urR`CCKzJ)p1I,">
                                <field name="VAR" id="ZDD#5:Nv?HWjdY*}stH6">heightBottomOfVase</field>
                               </block>
                              </value>
                              <value name="B">
                               <block type="math_number" id="LRMH]Yxq[lr6E~,q^lXp">
                                <field name="NUM">2</field>
                               </block>
                              </value>
                             </block>
                            </value>
                           </block>
                          </value>
                          <value name="Z">
                           <block type="math_number" id="xX3!VWIC{Mv+}ts5Z4BT">
                            <field name="NUM">0</field>
                           </block>
                          </value>
                         </block>
                        </value>
                        <value name="Width">
                         <block type="math_arithmetic" id="UgjKr;I3n1Wma(TJ-/I/">
                          <field name="OP">MULTIPLY</field>
                          <value name="A">
                           <block type="variables_get" id="zjNmU||V5bQW;_s84p)4">
                            <field name="VAR" id="XV?j1-KI*6ajtgjJ)Pg5">radiusOfVase</field>
                           </block>
                          </value>
                          <value name="B">
                           <block type="math_number" id=";mF;yi~@wf9RSgcV{_DE">
                            <field name="NUM">2</field>
                           </block>
                          </value>
                         </block>
                        </value>
                        <value name="Length">
                         <block type="math_arithmetic" id="X8mFLpWo?e*urq1VtV(M">
                          <field name="OP">MULTIPLY</field>
                          <value name="A">
                           <block type="variables_get" id="z,[}/Yw8:6{3eV-W/lw8">
                            <field name="VAR" id="XV?j1-KI*6ajtgjJ)Pg5">radiusOfVase</field>
                           </block>
                          </value>
                          <value name="B">
                           <block type="math_number" id="mDLc6B9q*NYV$N,tNMLJ">
                            <field name="NUM">2</field>
                           </block>
                          </value>
                         </block>
                        </value>
                        <value name="Height">
                         <block type="variables_get" id="bx@51fFZ*R!zp$dJnqu?">
                          <field name="VAR" id="ZDD#5:Nv?HWjdY*}stH6">heightBottomOfVase</field>
                         </block>
                        </value>
                       </block>
                      </value>
                     </block>
                    </value>
                    <next>
                     <block type="bitbybit.draw.drawAnyAsyncNoReturn" id="3$`iK#~gO6vl;M|.Fq=U">
                      <value name="Entity">
                       <block type="variables_get" id="~KVQmcD@*3nGk`_M.IxE">
                        <field name="VAR" id="rsQ@.,}Vzd}CRWsbB0}]">vase</field>
                       </block>
                      </value>
                      <value name="Options">
                       <block type="bitbybit.draw.optionsSimple" id="q6O8h=(q}?YTpjC@7ST)">
                        <value name="Colours">
                         <block type="colour_picker" id="b1u]=fqDfSy1TW-8iBf5">
                          <field name="COLOUR">#3366ff</field>
                         </block>
                        </value>
                        <value name="Size">
                         <block type="math_number" id="XDmvh-f(No`lHi4u/}4:">
                          <field name="NUM">3</field>
                         </block>
                        </value>
                        <value name="Opacity">
                         <block type="math_number" id="+KlI4$.XrmL6l?`p~r$c">
                          <field name="NUM">1</field>
                         </block>
                        </value>
                        <value name="Updatable">
                         <block type="logic_boolean" id="d!Kd{C$r=fkyP~R/izz!">
                          <field name="BOOL">FALSE</field>
                         </block>
                        </value>
                       </block>
                      </value>
                      <next>
                       <block type="controls_if" id="rANRX!RIx{P)nV[T+5zj">
                        <value name="IF0">
                         <block type="variables_get" id="sRd-PZ_{6l4vpF2.xO*[">
                          <field name="VAR" id=",R)k2d=9z|P0Qxd,LJFC">downloadSTL</field>
                         </block>
                        </value>
                        <statement name="DO0">
                         <block type="bitbybit.jscad.downloadSolidSTL" id="GI=wHxnLgNi@6(xja)fY">
                         </block>
                        </statement>
                       </block>
                      </next>
                     </block>
                    </next>
                   </block>
                  </next>
                 </block>
                </next>
               </block>
              </next>
             </block>
            </next>
           </block>
          </next>
         </block>
        </next>
       </block>
      </next>
     </block>
    </next>
   </block>
  </next>
 </block>
</xml>