Fix command generated when document is created
Don't create a command when the unit of the document is changed.
BUG: 387997 BUG: 388318 (cherry picked from commit f91fa3c18a0cc8d72f3dab8285fc32993c6f6b7d)