<div dir="ltr">So I moved that above metatool assignment and wrapped a print around AssignTextExpressionDef. Still no metatool assignment but it *does* return true...</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 8, 2015 at 7:55 AM, Jan Angermüller <span dir="ltr"><<a href="mailto:jan@angermueller.com" target="_blank">jan@angermueller.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    I haven't tested it, but maybe call <span style="white-space:pre-wrap"></span>ted:SaveNew()
    <b>before </b>assigning the metatool ?<br>
    I am not sure, but the text expression might need "to be registered
    in the system" before assigning the metatool.<br>
    Does <a href="http://www.finaletips.nu/frameworkref/class_f_c_metatool_assignment.html#ab9c22e27b1d9d30357d5a8d63b775acb" target="_blank">AssignTextExpressionDef</a>
    return true ?<div><div class="h5"><br>
    <br>
    <br>
    <div>Am 08.11.2015 um 14:39 schrieb Joseph
      Weidinger:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">Thanks.  However, I did all of those things and it
        still does assign the metakey. Here is the updated part + the
        rest of the relevant code in case maybe it is part of a larger
        problem (?).
        <div><br>
        </div>
        <div>
          <div>function makeBoldAbove(expressionText)</div>
          <div><span style="white-space:pre-wrap">        </span>local ted
            = finale.FCTextExpressionDef()</div>
          <div><br>
          </div>
          <div><span style="white-space:pre-wrap">        </span>-- actual
            text</div>
          <div><span style="white-space:pre-wrap">        </span>stringObject
            = finale.FCString()</div>
          <div><span style="white-space:pre-wrap">        </span>stringObject.LuaString
            = "^fontTxt(Times New Roman,4096)^size(14)^nfx(1)" ..
            expressionText</div>
          <div><span style="white-space:pre-wrap">        </span>ted:SaveNewTextBlock(stringObject)</div>
          <div><br>
          </div>
          <div><span style="white-space:pre-wrap">        </span>--
            description</div>
          <div><span style="white-space:pre-wrap">        </span>local
            descriptionstr = finale.FCString()</div>
          <div><span style="white-space:pre-wrap">        </span>descriptionstr.LuaString
            = expressionText -- get it from userinput also, why not</div>
          <div><span style="white-space:pre-wrap">        </span>ted:SetDescription(descriptionstr)</div>
          <div><br>
          </div>
          <div><span style="white-space:pre-wrap">        </span>-- put
            into which category?</div>
          <div><span style="white-space:pre-wrap">        </span>catdef =
            finale.FCCategoryDef()</div>
          <div><span style="white-space:pre-wrap">        </span>catdef:Load(4)
            -- 4 is expressions</div>
          <div><span style="white-space:pre-wrap">        </span>ted:AssignToCategory(catdef)</div>
          <div><br>
          </div>
          <div><span style="white-space:pre-wrap">        </span>-- we will
            not use standard positioning</div>
          <div><span style="white-space:pre-wrap">        </span>ted:SetUseCategoryPos(false)</div>
          <div><br>
          </div>
          <div><span style="white-space:pre-wrap">        </span>-- here is
            the positioning data</div>
          <div><span style="white-space:pre-wrap">        </span>ted:SetVerticalAlignmentPoint(finale.ALIGNVERT_ABOVE_STAFF_BASELINE_OR_ENTRY)</div>
          <div><span style="white-space:pre-wrap">        </span>ted:SetVerticalBaselineOffset(-26)</div>
          <div><span style="white-space:pre-wrap">        </span>ted:SetVerticalEntryOffset(36)</div>
          <div><span style="white-space:pre-wrap">        </span>ted:SetHorizontalJustification(finale.EXPRJUSTIFY_LEFT)</div>
          <div><span style="white-space:pre-wrap">        </span>ted:SetHorizontalAlignmentPoint(finale.ALIGNHORIZ_CLICKPOS)</div>
          <div><span style="white-space:pre-wrap">        </span>ted:SetHorizontalOffset(0)</div>
          <div><span style="white-space:pre-wrap">        </span>ted:SetBreakMMRest(false)</div>
          <div><br>
          </div>
          <div><br>
          </div>
          <div><span style="white-space:pre-wrap">        </span>local ma =
            finale.FCMetatoolAssignment()</div>
          <div><span style="white-space:pre-wrap">        </span>ma:SetMode(finale.MTOOLMODE_EXPRESSION)</div>
          <div><span style="white-space:pre-wrap">        </span>ma:AssignTextExpressionDef(ted)</div>
          <div><span style="white-space:pre-wrap">        </span>ma:SaveAsKeystroke(65)</div>
          <div><br>
          </div>
          <div><span style="white-space:pre-wrap">        </span>ted:SaveNew()</div>
          <div><br>
          </div>
          <div><span style="white-space:pre-wrap">        </span>return
            ted:GetItemNo()</div>
          <div>end</div>
          <div><br>
          </div>
          <div>local expressionID = makeBoldAbove("test") -- create it
            and get its new ID</div>
        </div>
        <div><br>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Sun, Nov 8, 2015 at 5:47 AM, Jari
          Williamsson <span dir="ltr"><<a href="mailto:jari.williamsson@mailbox.swipnet.se" target="_blank">jari.williamsson@mailbox.swipnet.se</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Joseph,<br>
            <br>
            In addition to what Jan said:<br>
            * Remove the call to SaveNew(), since it isn't needed.
            SaveNew() should only be used for classes that can save a
            list of objects to the same location. SaveAsKeyStroke() is
            the SaveAs method to use for metatool assignments.<br>
            <br>
            * Put the AssignTextExpressionDef before the save, otherwise
            the connection to the text expression def will not be saved
            to Finale.<br>
            <br>
            <br>
            Best regards,<br>
            <br>
            Jari Williamsson<span><br>
              <br>
              On 2015-11-08 11:07, Jan Angermüller wrote:<br>
            </span>
            <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>
                As the online documentation says for
                AssignTextExpressionDef:<br>
              </span>
              "The mode for the object must be set to
              MTOOLMODE_EXPRESSION *in advance*. "
              <div>
                <div><br>
                  So you need a SetMode before.<br>
                  <br>
                  Jan<br>
                  <br>
                  Am 08.11.2015 um 09:04 schrieb Joseph Weidinger:<br>
                  <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                    I am creating a new text expression definition (ted)
                    and that part<br>
                    works. However it won't assign the metakey "a"
                    (which is 65 apparently)<br>
                    <br>
                    I try to do this:<br>
                    ~ ted defined and working great<br>
                    <br>
                    local ma = finale.FCMetatoolAssignment()<br>
                    ma:SaveAsKeystroke(65)<br>
                    ma:SaveNew()<br>
                    ma:AssignTextExpressionDef(ted)<br>
                    <br>
                    ted:SaveNew()<br>
                    <br>
                    Maybe it has something to do with set mode? I
                    coculdn't get anything<br>
                    to work. Help appreciated! Thanks.<br>
                    <br>
                    <br>
                    <br>
                    <br>
                    _______________________________________________<br>
                    JWLua mailing list<br>
                    <a href="mailto:JWLua@jwmusic.nu" target="_blank">JWLua@jwmusic.nu</a><br>
                    <a href="http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu" rel="noreferrer" target="_blank">http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu</a><br>
                  </blockquote>
                  <br>
                  <br>
                  <br>
                  _______________________________________________<br>
                  JWLua mailing list<br>
                  <a href="mailto:JWLua@jwmusic.nu" target="_blank">JWLua@jwmusic.nu</a><br>
                  <a href="http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu" rel="noreferrer" target="_blank">http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu</a><br>
                  <br>
                </div>
              </div>
            </blockquote>
            <div>
              <div>
                <br>
                <br>
                <br>
                _______________________________________________<br>
                JWLua mailing list<br>
                <a href="mailto:JWLua@jwmusic.nu" target="_blank">JWLua@jwmusic.nu</a><br>
                <a href="http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu" rel="noreferrer" target="_blank">http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu</a><br>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
JWLua mailing list
<a href="mailto:JWLua@jwmusic.nu" target="_blank">JWLua@jwmusic.nu</a>
<a href="http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu" target="_blank">http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu</a>
</pre>
    </blockquote>
    <br>
  </div></div></div>

<br>_______________________________________________<br>
JWLua mailing list<br>
<a href="mailto:JWLua@jwmusic.nu">JWLua@jwmusic.nu</a><br>
<a href="http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu" rel="noreferrer" target="_blank">http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu</a><br>
<br></blockquote></div><br></div>