I've moved your post to the scripting forum...
problem is not related to the script
linked object is changed
If you do FRAME_TO_CONTENT
Aligned does not stop
but if you give a space before the connection object
sitting on the line
I'm pretty sure this is still the right forum since you are using a script to place the frame. I don't understand the question, and most users in the general forum won't understand it either, but I bet there are people here who do.
@hamdifem – I hope I do understand what you are asking. I'm not sure at all, because I cannot see that the code you are giving will add a text frame at the position that your screenshot is suggesting. Your code attempts to add a text frame at the last insertion point of the text frame (your selection), not to the second one (assumption when looking at your screenshot).
Some other things: What is the meassurement system in your example for horizontal and vertical direction?
What is the point size for your regular text in your example? Is the text frame where you added the new text frame in itself anchored?*
Can you do two screenshots of:
A. Situation before
B. Situation after: That means the result you want to achieve by writing a script (but just do it by means of the "normal" user interface of InDesign) together with some measurement values plus the used measurement systems for all objects and texts that are depicted
Note: Your code does not control the text frame options, your code does not control all anchored objects settings, just the y-position. Your code is telling nothing about the settings of your basic object style settings. So other app preferences may/will fill in this gap.
*Best publish an IDML file via Dropbox or a similar service and somebody could have a look at the real situation in your document showing the situation A and B.
For a start, explain in plain English what you want to achieve like:
1. I want to insert a text frame at the first/second/last (?) insertion point of the text frame.
2. Its anchor should be inline/above line/anchored (??)
3. Its offset from the baseline should be 0.15 point/inch/mm/??
4. Its contents should be "A"
And: What is the real purpose of all this?
First of all, you are not getting the solution what Laubendar explained. See, You may have Indesign CS5.5, CS 6, CC. But Please keep in mind, All the versions doesn't setted with the same Settings like metrics in your PC / Laptop. So while assigning values for anchor object you should be very clear. And Control whichever properties you needed. Only Y Offset wont fulfil all.
I suggest you to go through Laubendar's comments.