Script Blockly Free

Example in Blockly

Example in Blockly picture
Author
bitbybit
Created
Mar 19, 2021, 9:53:56 AM
Last edit
Dec 5, 2023, 6:12:00 PM

Edit scriptPreview

Project

Curve to GCode

Demonstrates how simple curve is converted to CNC GCode. Script runs and offers to save the file to disk. If dialog gets closed user can analyse the 3D model and tagged points.

View full project
<xml xmlns="https://developers.google.com/blockly/xml">
 <variables>
  <variable id="EDdstU5a4:F:MO/DusTU">curveForGCode</variable>
  <variable id="~jaGB$/e_AOm}0{d07Vh">curvePoints</variable>
  <variable id="X4emyG!!4%6F]aCC[w{D">gCodeText</variable>
  <variable id="2h{JzTj7$Vv-@|+#sJrC">gCodeTags</variable>
  <variable id="iV+ep`-Z@{jW93KFYaCM">curvePoint</variable>
  <variable id="B@]p$gPGuy/Z8imGULVR">xLine</variable>
  <variable id="3x.Wy/)nrrKh-Q_ZN8},">lineText</variable>
 </variables>
 <block type="bitbybit.draw.drawGridMeshNoReturn" id="/W/#[TX.f(q7h0]!{P6p" x="-133" y="-472">
  <value name="Width">
   <block type="math_number" id="CLkIJ^BluHH!wJrBed!h">
    <field name="NUM">400</field>
   </block>
  </value>
  <value name="Height">
   <block type="math_number" id="1}HXorX..1:MCtJD2U^]">
    <field name="NUM">400</field>
   </block>
  </value>
  <value name="Subdivisions">
   <block type="math_number" id="OK!occ6!z2P+D$;m@Jzq">
    <field name="NUM">10</field>
   </block>
  </value>
  <value name="MajorUnitFrequency">
   <block type="math_number" id="Q}c4%SEUaJ#f.NHB{LoY">
    <field name="NUM">10</field>
   </block>
  </value>
  <value name="MinorUnitVisibility">
   <block type="math_number" id="b-^Mb}yaFAJAGX+hFJ):">
    <field name="NUM">0.45</field>
   </block>
  </value>
  <value name="GridRatio">
   <block type="math_number" id="9!Yzqe|y`@RWp^-Uv68E">
    <field name="NUM">0.5</field>
   </block>
  </value>
  <value name="Opacity">
   <block type="math_number" id="{Gdpp2zg8WuY#UYJ/`%0">
    <field name="NUM">0.5</field>
   </block>
  </value>
  <value name="BackFaceCulling">
   <block type="logic_boolean" id="*9IgGxCkCmXT]Y7e=L5F">
    <field name="BOOL">FALSE</field>
   </block>
  </value>
  <value name="MainColor">
   <block type="colour_picker" id=")EBTHod][R#|exI9vH6W">
    <field name="COLOUR">#ffffff</field>
   </block>
  </value>
  <value name="SecondaryColor">
   <block type="colour_picker" id="hW*=8_oyDlHDJbt~$cvA">
    <field name="COLOUR">#ffffff</field>
   </block>
  </value>
  <next>
   <block type="variables_set" id="ZZI0LctXcyVpJyj10ycb">
    <field name="VAR" id="EDdstU5a4:F:MO/DusTU">curveForGCode</field>
    <value name="VALUE">
     <block type="bitbybit.verb.curve.createCurveByPoints" id="}cED{E|$(`}lB+i-`8g_">
      <value name="Degree">
       <block type="math_number" id="}_QKjgI=QGw.o$DOGArO">
        <field name="NUM">3</field>
       </block>
      </value>
      <value name="Points">
       <block type="lists_create_with" id="l!@%~M[.Wlu8W[}E+kKj">
        <mutation items="5">
        </mutation>
        <value name="ADD0">
         <block type="bitbybit.point.pointXYZ" id="wvW+[SwyxoQE4SlrEGh1">
          <value name="X">
           <block type="math_number" id="va{_OUCp:O;jHnerEsV*">
            <field name="NUM">0</field>
           </block>
          </value>
          <value name="Y">
           <block type="math_number" id=";Ak;j*M#$sKw$OsJ~ftk">
            <field name="NUM">0</field>
           </block>
          </value>
          <value name="Z">
           <block type="math_number" id="@#IiG/dR4?N};$B%X}A9">
            <field name="NUM">0</field>
           </block>
          </value>
         </block>
        </value>
        <value name="ADD1">
         <block type="bitbybit.point.pointXYZ" id="AW~%c-,jVk*rM4RooZed">
          <value name="X">
           <block type="math_number" id="aH/Y^n*9sChktular8}1">
            <field name="NUM">0</field>
           </block>
          </value>
          <value name="Y">
           <block type="math_number" id="y6G!VizklKx4^me@jWG^">
            <field name="NUM">0.3</field>
           </block>
          </value>
          <value name="Z">
           <block type="math_number" id="a4U4HG/tXl@6KC_{to.a">
            <field name="NUM">2</field>
           </block>
          </value>
         </block>
        </value>
        <value name="ADD2">
         <block type="bitbybit.point.pointXYZ" id="is.*$(=V2qszKrHiPU^X">
          <value name="X">
           <block type="math_number" id="x*ob1D[H^uYW}*sm;(Me">
            <field name="NUM">1</field>
           </block>
          </value>
          <value name="Y">
           <block type="math_number" id="I*fc]g9#k?yYyRSB+]bO">
            <field name="NUM">0</field>
           </block>
          </value>
          <value name="Z">
           <block type="math_number" id="~E^asc4|Oj@m[#FkiZr6">
            <field name="NUM">0</field>
           </block>
          </value>
         </block>
        </value>
        <value name="ADD3">
         <block type="bitbybit.point.pointXYZ" id="An$ED6rPzTDbcRMdenbL">
          <value name="X">
           <block type="math_number" id="Xr3)8D.2Yg7_hWs;7$=x">
            <field name="NUM">3</field>
           </block>
          </value>
          <value name="Y">
           <block type="math_number" id="yF8jIr]nU0KcLkCNs$6r">
            <field name="NUM">0</field>
           </block>
          </value>
          <value name="Z">
           <block type="math_number" id="AcJ-Tm{]`![CJwFM|F7n">
            <field name="NUM">-1</field>
           </block>
          </value>
         </block>
        </value>
        <value name="ADD4">
         <block type="bitbybit.point.pointXYZ" id="jNO+RB#(KE2QunUC_:DH">
          <value name="X">
           <block type="math_number" id="BNbt?P5m;NR=J[9IzXXO">
            <field name="NUM">-1</field>
           </block>
          </value>
          <value name="Y">
           <block type="math_number" id="ssE:1mM#/QS8w5cM+Y$k">
            <field name="NUM">0.3</field>
           </block>
          </value>
          <value name="Z">
           <block type="math_number" id="+s*8?[YbCkXF,Zn/mdrr">
            <field name="NUM">1</field>
           </block>
          </value>
         </block>
        </value>
       </block>
      </value>
     </block>
    </value>
    <next>
     <block type="variables_set" id="cND!,m:.r`BdIB{0i:8=">
      <field name="VAR" id="~jaGB$/e_AOm}0{d07Vh">curvePoints</field>
      <value name="VALUE">
       <block type="bitbybit.verb.curve.tessellate" id="9HG5xqsuAWb5]B?U6Ffm">
        <value name="Curve">
         <block type="variables_get" id="azi;O:UVZQ6N%p#tKAoB">
          <field name="VAR" id="EDdstU5a4:F:MO/DusTU">curveForGCode</field>
         </block>
        </value>
        <value name="Tolerance">
         <block type="math_number" id="eIa:+w3a@)WSvTbH`35x">
          <field name="NUM">0.000001</field>
         </block>
        </value>
       </block>
      </value>
      <next>
       <block type="variables_set" id=";wsBF$q]LJViEpD.@4{,">
        <field name="VAR" id="X4emyG!!4%6F]aCC[w{D">gCodeText</field>
        <value name="VALUE">
         <block type="lists_create_with" id="2hLHvy=M9FDf-Ts)GEfx">
          <mutation items="0">
          </mutation>
         </block>
        </value>
        <next>
         <block type="variables_set" id="F(?2%3Pw$]78duKOY=$Y">
          <field name="VAR" id="2h{JzTj7$Vv-@|+#sJrC">gCodeTags</field>
          <value name="VALUE">
           <block type="lists_create_with" id="f^%V_DK*QgR^JjwK7zaF">
            <mutation items="0">
            </mutation>
           </block>
          </value>
          <next>
           <block type="lists_setIndex" id="Pk=75pfPeEH$I1l?w@%,">
            <mutation at="false">
            </mutation>
            <field name="MODE">INSERT</field>
            <field name="WHERE">LAST</field>
            <value name="LIST">
             <block type="variables_get" id="+lD**xP4@wMqDn;EI$t2">
              <field name="VAR" id="X4emyG!!4%6F]aCC[w{D">gCodeText</field>
             </block>
            </value>
            <value name="TO">
             <block type="text" id="yX9SX:IKAi/J9n`U5zmE">
              <field name="TEXT">// Generated with bitbybit.dev</field>
             </block>
            </value>
            <next>
             <block type="controls_forEach" id="TF1Q+(Oybsd*YEfSNa;o">
              <field name="VAR" id="iV+ep`-Z@{jW93KFYaCM">curvePoint</field>
              <value name="LIST">
               <block type="variables_get" id="b]1Nbjn`jje`q#8}+5Tt">
                <field name="VAR" id="~jaGB$/e_AOm}0{d07Vh">curvePoints</field>
               </block>
              </value>
              <statement name="DO">
               <block type="variables_set" id="Mkhj8T5?13@H^WEsPgxl">
                <field name="VAR" id="B@]p$gPGuy/Z8imGULVR">xLine</field>
                <value name="VALUE">
                 <block type="text" id="jtKo=Nr==A2Jf5]a:X[R">
                  <field name="TEXT">G1 X</field>
                 </block>
                </value>
                <next>
                 <block type="controls_if" id="`7UK}^mhpKBKDwsx5_aT">
                  <value name="IF0">
                   <block type="logic_compare" id="yIIiAe^/xD0q-]Jy3t|!">
                    <field name="OP">NEQ</field>
                    <value name="A">
                     <block type="variables_get" id=",7zPo7z0PQ~B?PcBIp!Z">
                      <field name="VAR" id="iV+ep`-Z@{jW93KFYaCM">curvePoint</field>
                     </block>
                    </value>
                    <value name="B">
                     <block type="lists_getIndex" id="42_HucCl#sDy}6TgF#%H">
                      <mutation statement="false" at="false">
                      </mutation>
                      <field name="MODE">GET</field>
                      <field name="WHERE">FIRST</field>
                      <value name="VALUE">
                       <block type="variables_get" id="BX9m$=p{gJB;uPi(urpa">
                        <field name="VAR" id="~jaGB$/e_AOm}0{d07Vh">curvePoints</field>
                       </block>
                      </value>
                     </block>
                    </value>
                   </block>
                  </value>
                  <statement name="DO0">
                   <block type="variables_set" id="$Lbm,x1a.h;rD$t3yf-D">
                    <field name="VAR" id="B@]p$gPGuy/Z8imGULVR">xLine</field>
                    <value name="VALUE">
                     <block type="text" id="0{*xG/2,3Fa[k-}s#4UK">
                      <field name="TEXT">X</field>
                     </block>
                    </value>
                   </block>
                  </statement>
                  <next>
                   <block type="variables_set" id="ZmrMF:EuWhcwEjC?m0I]">
                    <field name="VAR" id="3x.Wy/)nrrKh-Q_ZN8},">lineText</field>
                    <value name="VALUE">
                     <block type="text_join" id="jCZe2w%Z)=}_r[0OyTzu">
                      <mutation items="6">
                      </mutation>
                      <value name="ADD0">
                       <block type="variables_get" id="QyNjenh1Rc0Xoj*=Vt1D">
                        <field name="VAR" id="B@]p$gPGuy/Z8imGULVR">xLine</field>
                       </block>
                      </value>
                      <value name="ADD1">
                       <block type="bitbybit.math.roundToDecimals" id="q%]BA/Fim/#bo7TXtHd:">
                        <value name="Number">
                         <block type="bitbybit.point.getX" id="x#CMQOg_{yUR0)l[(%og">
                          <value name="Point">
                           <block type="variables_get" id="Dk%;glAm._K:Kcf@%h4V">
                            <field name="VAR" id="iV+ep`-Z@{jW93KFYaCM">curvePoint</field>
                           </block>
                          </value>
                         </block>
                        </value>
                        <value name="DecimalPlaces">
                         <block type="math_number" id="r5?4:nj-cw20R5v.I}$=">
                          <field name="NUM">3</field>
                         </block>
                        </value>
                       </block>
                      </value>
                      <value name="ADD2">
                       <block type="text" id="7+5kIfE}12e5s:FP~M`t">
                        <field name="TEXT"> Y</field>
                       </block>
                      </value>
                      <value name="ADD3">
                       <block type="bitbybit.math.roundToDecimals" id="Ah[BtAMP.hv^nt0M3))(">
                        <value name="Number">
                         <block type="bitbybit.point.getZ" id=":rr3^rQQjw_jSWXQL}J$">
                          <value name="Point">
                           <block type="variables_get" id="O~w}5Qiz|Y)N)AC(1zNv">
                            <field name="VAR" id="iV+ep`-Z@{jW93KFYaCM">curvePoint</field>
                           </block>
                          </value>
                         </block>
                        </value>
                        <value name="DecimalPlaces">
                         <block type="math_number" id="+Pxrd]dwbqJEIiLw[p2Z">
                          <field name="NUM">3</field>
                         </block>
                        </value>
                       </block>
                      </value>
                      <value name="ADD4">
                       <block type="text" id="|cwLJBRl$w1lSyA3f:Ty">
                        <field name="TEXT"> Z</field>
                       </block>
                      </value>
                      <value name="ADD5">
                       <block type="bitbybit.math.roundToDecimals" id="@sDOkkIX.}4#B;nkB0!|">
                        <value name="Number">
                         <block type="bitbybit.point.getY" id="e/Z,/L5@MP}]P@:t#cPg">
                          <value name="Point">
                           <block type="variables_get" id="6PQ?_.8gBJ4Xs2/K@4Ef">
                            <field name="VAR" id="iV+ep`-Z@{jW93KFYaCM">curvePoint</field>
                           </block>
                          </value>
                         </block>
                        </value>
                        <value name="DecimalPlaces">
                         <block type="math_number" id="|c7lB=/!DAq(B|C[`FZB">
                          <field name="NUM">3</field>
                         </block>
                        </value>
                       </block>
                      </value>
                     </block>
                    </value>
                    <next>
                     <block type="lists_setIndex" id="w0@!;RqMb^3(K$!c$W{h">
                      <mutation at="false">
                      </mutation>
                      <field name="MODE">INSERT</field>
                      <field name="WHERE">LAST</field>
                      <value name="LIST">
                       <block type="variables_get" id="Qp-iE79#QJ8.EOhNRBW_">
                        <field name="VAR" id="2h{JzTj7$Vv-@|+#sJrC">gCodeTags</field>
                       </block>
                      </value>
                      <value name="TO">
                       <block type="bitbybit.tag.create" id="F}(.-D}N5*.9zl?R-6l}">
                        <value name="Text">
                         <block type="variables_get" id="Zi9_Q/KCYYEMvb0CtOvx">
                          <field name="VAR" id="3x.Wy/)nrrKh-Q_ZN8},">lineText</field>
                         </block>
                        </value>
                        <value name="Position">
                         <block type="bitbybit.point.pointXYZ" id="$P$,anc}b`j=8?0O6bWP">
                          <value name="X">
                           <block type="bitbybit.point.getX" id="n2B4zw`fimAL-k=LMc;S">
                            <value name="Point">
                             <block type="variables_get" id="!gJ}wij:xRLVfcVi)`?Z">
                              <field name="VAR" id="iV+ep`-Z@{jW93KFYaCM">curvePoint</field>
                             </block>
                            </value>
                           </block>
                          </value>
                          <value name="Y">
                           <block type="math_arithmetic" id="wC.iQ*I~]@Rw5L.+;011">
                            <field name="OP">ADD</field>
                            <value name="A">
                             <block type="bitbybit.point.getY" id="ykVe[SR9#K[5]]E^p#36">
                              <value name="Point">
                               <block type="variables_get" id="nxhdkEnc4`8N-qxT4]D#">
                                <field name="VAR" id="iV+ep`-Z@{jW93KFYaCM">curvePoint</field>
                               </block>
                              </value>
                             </block>
                            </value>
                            <value name="B">
                             <block type="math_number" id="JZS,smHcr];(HX$7gEO4">
                              <field name="NUM">0.1</field>
                             </block>
                            </value>
                           </block>
                          </value>
                          <value name="Z">
                           <block type="math_arithmetic" id="~,P?dsSoq/)PeuL88v6P">
                            <field name="OP">MINUS</field>
                            <value name="A">
                             <block type="bitbybit.point.getZ" id="1h*uGFjvn+4P97si4]sJ">
                              <value name="Point">
                               <block type="variables_get" id="r%~tIUjy,i~#t$B+L|*f">
                                <field name="VAR" id="iV+ep`-Z@{jW93KFYaCM">curvePoint</field>
                               </block>
                              </value>
                             </block>
                            </value>
                            <value name="B">
                             <block type="math_number" id="(/@!wKOkx#GGX[y$~z~z">
                              <field name="NUM">0.1</field>
                             </block>
                            </value>
                           </block>
                          </value>
                         </block>
                        </value>
                        <value name="Size">
                         <block type="math_number" id="K]NP=P|UV`nq*uCR=|A!">
                          <field name="NUM">8</field>
                         </block>
                        </value>
                        <value name="AdaptDepth">
                         <block type="logic_boolean" id="$h3*3g,B3j6A(mZGa:vd">
                          <field name="BOOL">TRUE</field>
                         </block>
                        </value>
                       </block>
                      </value>
                      <next>
                       <block type="lists_setIndex" id="tl[a^9#)fL72IxA3j)`Z">
                        <mutation at="false">
                        </mutation>
                        <field name="MODE">INSERT</field>
                        <field name="WHERE">LAST</field>
                        <value name="LIST">
                         <block type="variables_get" id="/ENyCSG}@x#DyFxtQ*^,">
                          <field name="VAR" id="X4emyG!!4%6F]aCC[w{D">gCodeText</field>
                         </block>
                        </value>
                        <value name="TO">
                         <block type="variables_get" id="mm|B1Hzpm=[,:_4]c]]k">
                          <field name="VAR" id="3x.Wy/)nrrKh-Q_ZN8},">lineText</field>
                         </block>
                        </value>
                       </block>
                      </next>
                     </block>
                    </next>
                   </block>
                  </next>
                 </block>
                </next>
               </block>
              </statement>
              <next>
               <block type="base_io_print_save" id="[I0]J,t%jNhNp#~x(s;@">
                <value name="Text">
                 <block type="variables_get" id="@/^{M.{1].1,U@#4+Z)f">
                  <field name="VAR" id="X4emyG!!4%6F]aCC[w{D">gCodeText</field>
                 </block>
                </value>
                <next>
                 <block type="bitbybit.draw.drawAnyAsyncNoReturn" id="~j~7pMYO)uGORf+uq/%*">
                  <value name="Entity">
                   <block type="variables_get" id="o[r)|Ysm{uJ2mttHfIW]">
                    <field name="VAR" id="2h{JzTj7$Vv-@|+#sJrC">gCodeTags</field>
                   </block>
                  </value>
                  <next>
                   <block type="bitbybit.draw.drawAnyAsyncNoReturn" id="He~%}TnX=7bEo9e=H[ZV">
                    <value name="Entity">
                     <block type="variables_get" id="awVI=Z/(M@v6r?/f_qyW">
                      <field name="VAR" id="~jaGB$/e_AOm}0{d07Vh">curvePoints</field>
                     </block>
                    </value>
                    <value name="Options">
                     <block type="bitbybit.draw.optionsSimple" id="Y3A$T7DEr_o.GO{YHI?%">
                      <value name="Colours">
                       <block type="colour_picker" id="20gU`dov3rX+n2(XtS?|">
                        <field name="COLOUR">#0000ff</field>
                       </block>
                      </value>
                      <value name="Size">
                       <block type="math_number" id="AuI6U|zcDqQ}Wx01f49y">
                        <field name="NUM">0.05</field>
                       </block>
                      </value>
                      <value name="Opacity">
                       <block type="math_number" id="eG#ybljs96rnkEKPw0S^">
                        <field name="NUM">1</field>
                       </block>
                      </value>
                      <value name="Updatable">
                       <block type="logic_boolean" id="K!VwAyp8GY[-ezj{O[EF">
                        <field name="BOOL">FALSE</field>
                       </block>
                      </value>
                      <value name="Hidden">
                       <block type="logic_boolean" id="t8^i:|zf,o-F]U(ScB.D">
                        <field name="BOOL">FALSE</field>
                       </block>
                      </value>
                     </block>
                    </value>
                    <next>
                     <block type="bitbybit.draw.drawAnyAsyncNoReturn" id="}:[@[_R@@EEyioqyME=j">
                      <value name="Entity">
                       <block type="variables_get" id="{BV3nz%Z@4ki*);Ug5K@">
                        <field name="VAR" id="EDdstU5a4:F:MO/DusTU">curveForGCode</field>
                       </block>
                      </value>
                     </block>
                    </next>
                   </block>
                  </next>
                 </block>
                </next>
               </block>
              </next>
             </block>
            </next>
           </block>
          </next>
         </block>
        </next>
       </block>
      </next>
     </block>
    </next>
   </block>
  </next>
 </block>
</xml>

Plans and pricing

Choose your plan

Editor plans for 3D development, API keys for server-side CAD algorithms

EnterpriseB2BCustompricing

Custom software development, dedicated servers and CAD automation at scale.

Learn moreContact us

CAD automation and software
  • Custom software development
  • Cloud CAD automation pipelines
  • 3D configurators (STEP & GLTF)
  • Batch export jobs
  • Custom algorithms & deployment
Infrastructure and support
  • Custom compute allocation
  • Dedicated / VPS server tenants
  • Long-running computation jobs
  • Custom upload limits & overage
  • SLA & premium support

All prices exclude applicable taxesView all plan details

Contact

Talk to us

Tell us what you are building or what is blocking you, through whichever channel suits you.