Highlighted

Script for swapping geometry of objects

Adobe Community Professional ,
Jul 13, 2020

Copy link to clipboard

Copied

I am looking for a script that will work similar to Zamena script (for Illustrator). I need to swap the geometry of a bunch of objects that I've created in InDesign. After I made many, many copies of the object in question, I took a closer look at the bezier curves and they are not as clean as I would like. So I want to swap their geometry with a newer cleaner version. 

 

Does such a script exist? I'm not a scripter, and I don't know any coding languages, so this is not something I can write for myself.

 

Screen Shot 2020-07-13 at 7.10.14 AM.png

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

To illustrate what my script is doing.

 

Before running the script on that selection:

 

Apply-EntirePath-from-Master-to-Selected-Objects-1.PNG

 

After running the script:

 

Apply-EntirePath-from-Master-to-Selected-Objects-2.PNG

 

Path and position of the master is applied to all selected objects.

All other properties like stroke weight, stroke color, fill color are not transferred.

 

Regards,
Uwe Laubender

( ACP )

Topics

Scripting

Views

87

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

Script for swapping geometry of objects

Adobe Community Professional ,
Jul 13, 2020

Copy link to clipboard

Copied

I am looking for a script that will work similar to Zamena script (for Illustrator). I need to swap the geometry of a bunch of objects that I've created in InDesign. After I made many, many copies of the object in question, I took a closer look at the bezier curves and they are not as clean as I would like. So I want to swap their geometry with a newer cleaner version. 

 

Does such a script exist? I'm not a scripter, and I don't know any coding languages, so this is not something I can write for myself.

 

Screen Shot 2020-07-13 at 7.10.14 AM.png

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

To illustrate what my script is doing.

 

Before running the script on that selection:

 

Apply-EntirePath-from-Master-to-Selected-Objects-1.PNG

 

After running the script:

 

Apply-EntirePath-from-Master-to-Selected-Objects-2.PNG

 

Path and position of the master is applied to all selected objects.

All other properties like stroke weight, stroke color, fill color are not transferred.

 

Regards,
Uwe Laubender

( ACP )

Topics

Scripting

Views

88

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
Adobe Community Professional ,
Jul 15, 2020

Copy link to clipboard

Copied

Hi Kelly,

is this still an issue for you?

Looked a bit around but couldn't find a script for that purpose with InDesign.

 

How would you like to handle this if a script is possible?

Selecting the new object first, then adding all other objects to the selection that should be substituted?

 

Best,
Uwe Laubender

( ACP )

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

Copy link to clipboard

Copied

Hi Uwe,

I don't have any preference for how it should be handled. But your suggestion sounds good to me. The obejcts would just need to keep their same X-Y coordinates. Also, if it is possible, to just select the objects that have the same fill color as the first object.

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

Copy link to clipboard

Copied

Hi Kelly,

the only script I found that is very close to your task is Marc Autret's Equalizer script where one of the many features is to swap two selected objects:

 

Equalizer PRO 3.0 released!
Marc Autret, October 11, 2016

https://www.indiscripts.com/post/2016/10/equalizer-pro-3-0-released

 

Do all of your objects you want to exchange have the same size compared to the new master object?

If not how would you like to swap the master to the old objects? From the center of the object?

 

Thanks,
Uwe Laubender

( ACP )

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

Copy link to clipboard

Copied

Thanks Uwe! I'll give Equalizer a try.

The old and new objects are the exact same size.

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

Copy link to clipboard

Copied

Then an ad-hoc script from my side could do the trick!

 

[1] Select your new master object first

[2] Then add all other objects you want to change to the selection.

[3] Run that script code on your selection:

 

 

var s = app.selection ;
var m = s[0] ;
var mp = m.paths[0].entirePath ;


for( var n=1; n<s.length; n++ )
{
	var xy = [ s[n].geometricBounds[1] , s[n].geometricBounds[0] ];
	
	s[n].paths[0].entirePath = mp ;
	
	s[n].move( xy );
};

 

 

It should work if the objects are no compound ones and have only one path each.

It's not working as expected on objects that are flipped. If there are any objects like that, I could expand the code.

 

Regards,
Uwe Laubender

( ACP )

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

Copy link to clipboard

Copied

To illustrate what my script is doing.

 

Before running the script on that selection:

 

Apply-EntirePath-from-Master-to-Selected-Objects-1.PNG

 

After running the script:

 

Apply-EntirePath-from-Master-to-Selected-Objects-2.PNG

 

Path and position of the master is applied to all selected objects.

All other properties like stroke weight, stroke color, fill color are not transferred.

 

Regards,
Uwe Laubender

( ACP )

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

Copy link to clipboard

Copied

Wow, Uwe, thant's great! Your script works wonderfully! Thank you so 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...