Copy link to clipboard
Copied
Hi All,
var myMenuAction = app.menuActions.item("$ID/Untag Frame");
After launching my indesign Application by default "Untag Frame" menu action is invalid. After I select a text frame and right click it manually this is menu action gets valid.
If any work around through script itself, please suggest me.
Thanks,
Green4ever
Copy link to clipboard
Copied
@Green4ever:
nothing special here. Menu actions work this way. If you have no object selected the menu action is greyed out in the UI. And therefore "Untag Frame" is not valid.
To use "Untag Frame" as menu action you have to:
myObject.select();
Uwe
Copy link to clipboard
Copied
Hi Laubender,
I tried that already. Do you think is there any other way to do it? In my script I used the below line of sequence
app.select(parentFrame);//This is a valid selection
var myMenuAction = app.menuActions.item("$ID/Untag Frame");
if(myMenuAction.isValid){
myMenuAction.invoke();
}
else{
alert("Menu action is invalid");
myDoc.close(SaveOptions.NO);
exit();
}
Thanks,
Green4ever
Copy link to clipboard
Copied
@Green4ever:
can you accomplish your task in the UI? I mean is your "parentFrame" a valid object for "Untag Frame"?
Is "Untag Frame" a menu action at all? I can see "Untag Text", "Untag Element", but not "Untag Frame" in the available list of menu actions.
"Tag Frame" is also available…
I'm using a german version of InDesign so I'm not 100% sure about that…
There is an option in my german InDesign Tags palette that reads "Entf." which means "Del.". It's ID is "78612". So possibly you can do:
app.menuActions.itemByID(78612).invoke();
Uwe
Copy link to clipboard
Copied
Hi,
I too got the same results while doing research and analysis but "Untag Frame" is a valid menu action. It is activated after you select any text frame and right cilck it. Just Try it...
Thanks,
Green4ever
Copy link to clipboard
Copied
Hi Green,
Can you please try this below js.
var mySel = app.selection[0];//This is a valid selection
var myMenuAction = app.menuActions.item("$ID/Untag Frame");
try{
myMenuAction.invoke();
}
catch(e){
alert("Menu action is invalid\n Please select the xml tag frame!");
myDoc.close(SaveOptions.NO);
exit();
}
thx
csm_phil
Copy link to clipboard
Copied
Hi csm_phil,
see the reply number 2 I have posted the similar thing. Also I have tried your suggestion menu action is invalid here too.
Thanks,
Green4ever
Copy link to clipboard
Copied
@Green4ever:
… but "Untag Frame" is a valid menu action. It is activated after you select any text frame and right cilck it. …
I can click it in the UI, but therefore it's not necessarily part of the menu actions.
Jongware's suggestion is working in my test case:
app.selection[0].associatedXMLElement.untag();
My suggestion for untagging is okay, if you want to use menu actions:
First select the object and then:
app.menuActions.itemByID(78612).invoke();
My test case consists of a single rectangle autotagged and selected.
If that is not working for you, I think we just need a test IDML for playing around…
Uwe
Copy link to clipboard
Copied
Hi Laubender,
app.select("myFrame")//This is a valid selection
var myAction = app.menuActions.itemByID(78612);
alert(myAction.name);
myAction.invoke();
alert(myAction.name);
Output I'm getting is unstable, ie:
Untag Text //For the first time
Untag Frame//For the second time
And if you run the above for the second time it gives Untag Frame both times.
Conclusion:
When "Untag Frame" menu action is valid "Untag Text" becomes invalid and vice versa....
app.menuActions.itemByID(78612); performs same action when it is Untag Text or Untag Frame.
Thanks,
Green4ever
Copy link to clipboard
Copied
@Green4ever:
app.menuActions.itemByID(78612); performs same action when it is Untag Text or Untag Frame.
Of course! There are no inconsitencies in that behaviour. The menu action with ID 78612 is the little "Untag" button in your screen shot.
It can untag all kind of objects that have tags.
Uwe
Copy link to clipboard
Copied
No need to invoke the menu command (and neither to use 'select'). A simple
app.selection[0].associatedXMLElement.untag();
is enough.
(I located this in the scripting reference by looking at the logical steps I had to make in InDesign itself. "Untag" is a native option of the XML Tags panel menu.)
Copy link to clipboard
Copied
Hi Jongware,
Yes you are right. But my associatedXMLElement is a root element. So
associatedXMLElement.untag() will not work.
Thanks,
Green4ever
Copy link to clipboard
Copied
But you cannot tag a text frame as a root element ...
Copy link to clipboard
Copied
Hi Jongware,
But you cannot tag a text frame as a root element ...
Yes you can, It is possible. See the screen shot. Just drag a text frame to your sturcture pane's root element and it is done.
Thanks,
Green4ever
Copy link to clipboard
Copied
That's something weird. I can't -- the default tag is "Root" and anything I drag into the pane gets added *below* that.
It's also logical, from an XML point of view. You cannot have a 'data' tag straight away, there has to be a level above it. Perhaps that's the root cause of your problems with untagging.
Copy link to clipboard
Copied
Hi,
I think it is not weird. Just drag the text frame over the "Root" tag, it is possible. In XML point of view only one root element is allowed, so in this context it is valid XML.
Thanks,
Green4ever
Copy link to clipboard
Copied
A-ha! Okay I didn't know that.
But in that case it makes sense you cannot "untag" the one single frame you have. Untagging a frame removes the tag from the Structure pane, and I get an error that clearly states
Error String: This element cannot be deleted.
You *must* have at least one single tag, or so it seems.
Copy link to clipboard
Copied
Yes of course!.. You cannot delete the root element. But you can break the association. To do this, select the associated text frame and invoke the menu action.
Thanks,
Green4ever
Copy link to clipboard
Copied
I know, this thread is an old one, but there is another solution to this problem (the element is tagged with "Root" and cannot be untagged) presented by Gregor Fellenz at:
http://www.hilfdirselbst.ch/gforum/gforum.cgi?post=506634#506634
You will find a test case here:
http://www.hilfdirselbst.ch/gforum/gforum.cgi?do=post_attachment;postatt_id=6654;
Uwe
Find more inspiration, events, and resources on the new Adobe Community
Explore Now