According to the Shulchan Oruch quoted in the question, measuring when done for another person looks like Mekach uMemkar (buying and selling) since that person looks like a "buyer" and if using accurate measuring utensils onlookers will think there is a transaction (thus permitting such an action on Shabbos) and might come to make their own transactions and inadvertently write down the amount of money owed by the buyer.
See Mishna Brura OC 323,1 3 who says anything that clearly does not look like buying and selling between 2 people is permitted even in a measuring utensil, for example pouring for a guest, and how much more so pouring for oneself to eat!
שאין זה דרך מקח וממכר וגם לא מחזי כעובדין דחול שאף המשקה את חבירו בדרך מתנה דרכו ג"כ לפעמים להשקות בכלי המיוחד למדה:
So using a mechanical sugar dispenser for direct consumption for oneself or a guest is permitted on Shabbos.