Difference between run mel commands on maya file open vs run mel commands in scrupt editor

Hello, everyone!

What difference between mel commands, which runned in script editor
with mel commands, which run’s when reading .ma file?

Stuck with situation in which during parsing of .ma file and running this
parsed mel commands in script editor i have errors.
It look like mel commands run in different conditions during scene opening.
Is there any way to reproduce this conditions to run these mel data?

For example, i created basic scene with driven key, saved it as .ma file,
if i open .ma file, then i will see see lines:

> createNode animCurveUL -n "pSphere1_translateZ";
> 	rename -uid "CA76E85D-4B36-A79E-0B68-1E8B9C595CE9";
> 	setAttr ".tan" 18;
> 	setAttr -s 2 ".ktv[0:1]"  -2.7775394916534424 -3.0042875119705168 
> 		0 0;

anim curve being created, renamed and next tangent setted and keys setted.
If i will try to run these lines in mel scipt editor, then it will give errors:

// Error: line 3: setAttr: The attribute ‘pSphere1_translateZ.tangentType’ cannot be modified. //
// Error: line 2: setAttr: The attribute ‘pSphere1_translateZ.keyTimeValue[0]’ should be set with the keyframe or setKeyframe command. //

Although MA files are executable mel – that’s why they are a security nightmare! – they run in a slightly different context than regular maya designed for bulk operations. So there’s no guarantee that all of the setAttrs which work in an MA file will translate directly to listener commands in a regular running session. For anim curves and meshes, in particular, Maya wants you to go through the exposed commands to add points instead of just dropping them in as bulk sets.

I don’t think there’s a way around it, except perhaps to write out the bits you want to your own local ma file and then pull them in using a file import

Thank you for the reply!
I will try different aproach then, without parsing .ma=)