Highlighted

Release anchored objects that have paragraph and/or Object style

Engaged ,
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

Adobe Community Professional
Correct answer by brianp311 | Adobe Community Professional

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

 

Or, 

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

TOPICS
How to, Scripting

Views

123

Likes

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

Release anchored objects that have paragraph and/or Object style

Engaged ,
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

Adobe Community Professional
Correct answer by brianp311 | Adobe Community Professional

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

 

Or, 

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

TOPICS
How to, Scripting

Views

124

Likes

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
Jul 24, 2020 0
Adobe Community Professional ,
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.

Likes

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
Reply
Loading...
Jul 24, 2020 1
Engaged ,
Jul 25, 2020

Copy link to clipboard

Copied

Thank you very much

Likes

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
Reply
Loading...
Jul 25, 2020 0
Adobe Community Professional ,
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();

}

Likes

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
Reply
Loading...
Jul 24, 2020 1
Engaged ,
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();
}

Likes

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
Reply
Loading...
Jul 25, 2020 0
Engaged ,
Jul 25, 2020

Copy link to clipboard

Copied

Thank you a lot

Likes

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
Reply
Loading...
Jul 25, 2020 0
Adobe Community Professional ,
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.

Likes

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
Reply
Loading...
Jul 25, 2020 0
Engaged ,
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();
}

Likes

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
Reply
Loading...
Jul 25, 2020 0
Adobe Community Professional ,
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")

Likes

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
Reply
Loading...
Jul 25, 2020 1
medos20 LATEST
Engaged ,
Jul 26, 2020

Copy link to clipboard

Copied

Thank you a lot

Likes

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
Reply
Loading...
Jul 26, 2020 0