Graphics

 View Only
  • 1.  Center 4 Text Objects Visual Logic

    Posted 05-23-2019 06:33
     
    I would like to centre a group of objects so that if the text is changed the whole group aligns centre to the whole scene. - This time I need to do it with 4 pieces of text (Different Font Weights) and can't seem to figure out how it's done in Visual Logic.
     
    Thank you everyone again
     
    See attached


  • 2.  RE: Center 4 Text Objects Visual Logic

    Posted 05-23-2019 16:27

    What I do is combine the text into a 5th text group (that is unpublished) using visual logic.  In this manner, you can also manage the Auto Squeeze width of a single text line regardless of how long the names are.  You can even build in functionality to change the delimiter if you only needed one name...

    The String value blocks take the font - font name enclosed in curly brackets.

    You can combine as many as you need into a single concatenate block - and set the delimiter as needed (ie: spaces, etc)

    The concatenate block on the right in my example contains the & sign and some spaces.

    Don't forget to hide your "source" text fields when you're done.


    #XPression


  • 3.  RE: Center 4 Text Objects Visual Logic

    Posted 05-24-2019 08:25

    Hi Brian,

     

    Thanks for your message.

    It works but for some reason it does not like Font tags above 6 -- Since the fonts I need to use are {Font20} and {Font21} it won't pick them up.

    Any idea how I can get them working?

     

    Thanks

     

    Paul

     

     


    #XPression


  • 4.  RE: Center 4 Text Objects Visual Logic

    Posted 05-24-2019 14:33

    Paul,

      Looks like you're only using 2 fonts, right?  One for first name and one for last name?  You can reuse those blocks in Visual logic - connect them to as many of the concatenate blocks you need.  Otherwise, the only thing I can think of is to make sure you have spelled the font name correctly - XPression is usually forgiving with CAPS, but check that as well.  You can even name the fonts if you wish (ie: FName, Last, etc).

     

    Hope this helps,

    Brian


    #XPression


  • 5.  RE: Center 4 Text Objects Visual Logic

    Posted 05-28-2019 00:45

    Thanks for your help Brian -

    Unfortunately still having issues with pointing at fonts.

    I think the method will work if I reduced my project to just two fonts rather than the 20 I require.

     

    Thanks again

     


    #XPression


  • 6.  RE: Center 4 Text Objects Visual Logic

    Posted 05-28-2019 08:06

    Oooooohhhh!!!
    Now that's nifty Brian!

    I think you've got an error instead somewhere Paul C. I just tested this, as I was not aware of the {font} usage in the Visual Logic string, and just for fun, I tried to replicate the issue you have. However I am now on {Font68} and it still works just fine... Can confirm that is is not case-sensitive when it comes to the "f" in "font".

    I'm using Xpression v8.0 build 4106 at the moment (designer).

    I do have another sollution for you if you really really need those 20 fonts, and I did it earlier when someone asked this before. However I find this sollution to be far more elegant and smooth.

     


    #XPression


  • 7.  RE: Center 4 Text Objects Visual Logic

    Posted 05-29-2019 00:31

    Hey Aleksander,

    If you have another solution that would be great!

    I'm finding a few bugs in xpression at the moment so it might be that. (text boxes not changing etc - even without visual logic or coding)

    I'm on Xpression 8.5 b 4570

    Thanks


    #XPression


  • 8.  RE: Center 4 Text Objects Visual Logic

    Posted 05-29-2019 03:49

    Paul - I tried my simple example on 8.5 b 4571 (one step newer than yours) and it seems to be working.  There is an alternate method that uses scripting, but the same principle.  It's what I used to do before Visual Logic became available.

    As you can see below, it's doing the same basic thing - getting the font(s) and assigning them as needed.  You start with a clean "result" and append the pieces you need.  You add the "CurrentFont" line each time you need to change the font style and "AppendToLine" each piece of your text.

    '======= sample script ======='

    dim awayName, awayRank, awayResult, homeName, homeRank, homeResult as xpTextObject
    dim rankFont, nameFont as xpFont

    engine.GetFontByName("mb-ranks", rankFont)
    engine.GetFontByName("mb-teams", nameFont)

    self.GetObjectByName("Away Team Rank", awayRank)
    self.GetObjectByName("Away Team Name", awayName)
    self.GetObjectByName("Away Team Result", awayResult)

    self.GetObjectByName("Home Team Rank", homeRank)
    self.GetObjectByName("Home Team Name", homeName)
    self.GetObjectByName("Home Team Result", homeResult)

    awayResult.Text = ""
    awayResult.CurrentFont = rankFont
    awayResult.AppendToLine(0, awayRank.text & " ")
    awayResult.CurrentFont = nameFont
    awayResult.AppendToLine(0, awayName.text)

    homeResult.Text = ""
    homeResult.CurrentFont = rankFont
    homeResult.AppendToLine(0, homeRank.text & " ")
    homeResult.CurrentFont = nameFont
    homeResult.AppendToLine(0, homeName.text)


    #XPression


  • 9.  RE: Center 4 Text Objects Visual Logic

    Posted 05-29-2019 07:45

    Thanks Brian - I'll give this a go.

     

    Thank you!


    #XPression


  • 10.  RE: Center 4 Text Objects Visual Logic

    Posted 05-29-2019 07:54

    Well, my sollution is entirely based on Visual Logic, but without using the {font} sollution.

    1. Create the following text elements.
      - First name 1
      - Last name 1
      - Delimeter
      - First name 2
      - Last name 2

    2. Place the pivot of all text elements on the left using visual logic.
      (object width.scaled / -2) = pivot y

    3. Lock all text elements to the same Y-position as the first element.

    4. Position the text elements following eachother by the X-position based on the X-position on the word in front + the width-scaled on the word in front (+ a spacer value if you want that). That should eventually put them in-line.

    5. Put all the text elements into the same group (that set the X-value to the center of the graphic by default group position).

    6. Position the FIRST NAME 1 on the X-axis by taking the total width of all 5 elements and divide by -2. This will move the text over to be centered.

    #XPression


Global message icon