• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Release anchored objects that have paragraph and/or Object style

Enthusiast ,
Jul 24, 2020 Jul 24, 2020

Copy link to clipboard

Copied

Dear Pros,

I Want to release anchored objects that have specific paragraph and/or Object style in all document? 

can this is be done? or shall i have script? do you know script doing this?

Best Regards

Mohammad

Best
Mohammad Hasanin
TOPICS
How to , Scripting

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Jul 24, 2020 Jul 24, 2020

It can be done through script using the releaseAnchoredObject method from an object's anchoredObjectSettings. 

Some pseudocode: 

if (pageItem.condition is met) {

    pageItem.anchoredObjectSettings.releaseAnchoredObject();

}

Votes

Translate

Translate
Community Expert , Jul 25, 2020 Jul 25, 2020

Sorry it should be if foundObjects[i].appliedObjectStyle.name == "ObjStyle"

 

Or, 

if (foundObjects [i].appliedObjectStyle == myDoc.objectStyles.itemByName("ObjStyle")

Votes

Translate

Translate
Community Expert ,
Jul 24, 2020 Jul 24, 2020

Copy link to clipboard

Copied

Yes, it sounds like it would need to be scripted (it's not a built-in feature). No, not being a scripter, nor ever needing this feature, I don't know if anyone has developed it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 25, 2020 Jul 25, 2020

Copy link to clipboard

Copied

Thank you very much

Best
Mohammad Hasanin

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 24, 2020 Jul 24, 2020

Copy link to clipboard

Copied

It can be done through script using the releaseAnchoredObject method from an object's anchoredObjectSettings. 

Some pseudocode: 

if (pageItem.condition is met) {

    pageItem.anchoredObjectSettings.releaseAnchoredObject();

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 25, 2020 Jul 25, 2020

Copy link to clipboard

Copied

Actually i have some experience in scripting, i wrote this script in the begining of the year to release all the anchored objects in the documents but i have a little experience in how to connecting the Styles with variables, here is the code if you can help to modify it to match object style - i will be thankful :

//Unanchored all Anchored Objects at Once
//Developed By : Mohammad Ibrahim
// 11-2-2020

//Check if a Document is Open
if (app.documents.length == 0) {
alert (“No document is open.”, “Caution”);
exit();
}

//Working in the Current Active Document
var myDoc = app.activeDocument;

// to use to process entire document
var myItems = myDoc.allPageItems;
// to use to process just current page
//var myItems = app.activeWindow.activePage.allPageItems;

//Creating Founded Objects Array
var foundObjects = Array();
for(var i = 0; i < myItems.length; i++){
if(myItems[i].parent instanceof Character){foundObjects.push(myItems[i]);}
}

//Check if Anchored Objects not Found
if ( myItems.length == 0 )
{
alert(“No Anchored items found in this document!.”, “Stop” );
exit();
}

//UnAnchored Process Started at Array Created
if(foundObjects.length > 0){
for(var i = 0; i < foundObjects.length; i++){
foundObjects[i].anchoredObjectSettings.anchoredPosition = AnchorPosition.anchored;
var AnchoredObject = foundObjects[i].anchoredObjectSettings.releaseAnchoredObject();
}
}

//Check if the Program is Done
if (AnchoredObject < 0) {
alert (“all Objects Done.”, “Stop”);
exit();
}
Best
Mohammad Hasanin

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 25, 2020 Jul 25, 2020

Copy link to clipboard

Copied

Thank you a lot

Best
Mohammad Hasanin

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 25, 2020 Jul 25, 2020

Copy link to clipboard

Copied

Add: 

 

if (foundObjects[i].appliedObjectStyle == "Style to Find") 

 

in the last for loop as a check before you release it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 25, 2020 Jul 25, 2020

Copy link to clipboard

Copied

Thank you very much for your reply, i tried it and no errors but not working!

//Unanchored all Anchored Objects at Once
//Check if a Document is Open
if (app.documents.length == 0) {
	alert ("No document is open.", "Caution");
	exit();
}

//Working in the Current Active Document
var myDoc = app.activeDocument;  
  
// to use to process entire document  
var myItems = myDoc.allPageItems;  

//Creating Founded Objects Array
var foundObjects = Array();  
  for(var i = 0; i < myItems.length; i++){  
  if(myItems[i].parent instanceof Character){foundObjects.push(myItems[i]);}  
}  

//Check if Anchored Objects not Found
	if ( myItems.length == 0 )
	{
		alert("No Anchored items found in this document!.", "Stop" );
		exit();
	}

//UnAnchored Process Started at Array Created
if(foundObjects.length > 0){  
   for(var i = 0; i < foundObjects.length; i++){  
    if (foundObjects[i].appliedObjectStyle == "ObjStyle") {  
    foundObjects[i].anchoredObjectSettings.anchoredPosition = AnchorPosition.anchored;
    var AnchoredObject = foundObjects[i].anchoredObjectSettings.releaseAnchoredObject();
  }  
}
}

//Check if the Program is Done
if (AnchoredObject < 0) {
	alert ("all Objects Done.", "Stop");
	exit();
}
Best
Mohammad Hasanin

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 25, 2020 Jul 25, 2020

Copy link to clipboard

Copied

Sorry it should be if foundObjects[i].appliedObjectStyle.name == "ObjStyle"

 

Or, 

if (foundObjects [i].appliedObjectStyle == myDoc.objectStyles.itemByName("ObjStyle")

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 26, 2020 Jul 26, 2020

Copy link to clipboard

Copied

LATEST

Thank you a lot

Best
Mohammad Hasanin

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines