🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
22 messages
22 total messages Started by sanatkumar Mon, 30 Mar 2009 11:03
how to group some objects and duplicate it and then enlarge the same group using javascript ??
#95
Author: sanatkumar
Date: Mon, 30 Mar 2009 11:03
6 lines
1003 bytes
Hi everyone,

I need to write a javascript which will group some object on running the script and then duplcate the same group.After duplicating it will enlarge the same group upto some extend.The object will be generally inside the textframes.We have to group them and then make a duplcate of the group on the same page.Please tell me the javascript code to do the same.

Thanks and regards,
Sanat
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#96
Author: jongware
Date: Mon, 30 Mar 2009 11:45
8 lines
1588 bytes
What version of InDesign? For CS3, you can start by looking at Class Group ("A group" is its description in the ESTK Help) and its collection Groups. Those contains a lot, if not all, of the features you request:

* Groups.Group add (groupItems: Array of PageItem[, layer:Layer][, at:LocationOptions=UNKNOWN][, reference:any][, withProperties:Object]) -- Creates a new Group
* PageItem Group.duplicate ([to:any][, by: Array of number]) -- Duplicates the Group at the specified location or offset
* void Group.move ([to:any][, by: Array of number]) -- Moves the Group to a new location.
* Group.absoluteHorizontalScale, Group.absoluteVerticalScale -- The horizontal and vertical scale of the Group relative to its containing object.

(All copied straight out of the CHM version <http://www.jongware.com/binaries/IdCs3Chm.zip> of the ESTK Help, created by me and put into CHM by ABC GREEN. HTML version somewhere at the same location.)
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#97
Author: sanatkumar
Date: Mon, 30 Mar 2009 11:54
2 lines
763 bytes
m using indesign cs3.. Could u please post the javascript code for the same.
Thanks in advance..
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#153
Author: Dave_Saunders
Date: Mon, 30 Mar 2009 12:43
28 lines
1522 bytes
Given your description of your goal, there's not enough information to do the job.

You say:

      which will group some object on running the script




Do you mean "some objects"? Hope so because you can't group a single item.

How does the script know which objects to work on? Are you requiring the user to select them in advance? If not, what technique should the script use to know which objects?

      it will enlarge the same group upto some extend




To which extent?

      The object will be generally inside the textframes




What does "inside" mean? Are you talking about anchored objects? Or is this a reference to their geometric positions on the page? If the latter, what does the text frames have to do with anything? If the former, then the job just got a whole lot harder because you can't group anchored objects.

Dave
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#162
Author: jongware
Date: Mon, 30 Mar 2009 21:20
17 lines
1031 bytes
How does

      I need to write...




rhyme with

      post the code




? It's not as if it's a well-known or easy "trick" -- or as if you've given clear objectives (see Dave's list of questions).

Did you check the functions I summed up in the ESTK? These are the ones you will be using, or at least, that's what I'm guessing you should. What have you got so far?
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#169
Author: sanatkumar
Date: Tue, 31 Mar 2009 05:29
8 lines
1228 bytes
some objects means we have to combine several objects into a group so that they are treated as a single unit.The object are textframes(means text ).The user has to select the objects and then run the script.By running the script,the script will group the selected object and then make a duplicate of the same group by enlarging it.

The extent of enlargement will be fixed.We can specify the geometric position in the script itself.

I m a beginner to indesign javascript.Plz anyone help me in the code.

Regards,
Sanat
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#175
Author: sanatkumar
Date: Tue, 31 Mar 2009 10:29
20 lines
1238 bytes
The code that i m using is like this..fist i m selecting and then grouping them using array.But this one is not working perfectly..Its showing error at var myObjectList = new Array(myPageItem);
Could anyone tell me the solution...

main();

function main(){
	if (app.documents.length != 0){
		if (app.selection.length > 0){
			for(myCounter = 0; myCounter<app.selection.length; myCounter++){ 				myPageItem = app.selection[myCounter];

					var myObjectList = new Array(myPageItem);

var myGroup =myDocument.groups.add(myObjectList);
				}
			}
		}



	}
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#7
Author: jongware
Date: Tue, 31 Mar 2009 22:15
24 lines
1228 bytes
Hmm. I *think* you got the order wrong:

loop
  create array of one page item only; add to group

Try this:

var myObjectList = new Array; 
for (i=0; i<app.selection.length; i++)

	myObjectList.push (app.selection[i]);

alert ("length of myObjectList is "+myObjectList.length);

-- an alternative way of creating a valid array of selected items. I can't get

      var myObjectList = new Array(app.selection)




to work (it certainly sounds as if it should work ...).

The resulting array object then can be fed into the group creating line.
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#18
Author: sanatkumar
Date: Wed, 01 Apr 2009 11:55
28 lines
1418 bytes
Thanks a lot jongware..now its selecting the objects correctly but i m struck with adding to the group and duplicating the group.
I tried the follwing code but it didnot work.

main();

function main(){
	if (app.documents.length != 0){
		if (app.selection.length > 0){

			var myObjectList = new Array;
for (i=0; i<app.selection.length; i++)

	myObjectList.push (app.selection[i]);

alert ("length of myObjectList is "+myObjectList.length);

var myGroup =app.documents.groups.add(myObjectList);

var myGroup1=app.documents.groups.duplicate(myObjectList1,myObjectList1);

				}
			}
		}

I know i m asking silly questions but i m a begginer to this scripting and want to learn more.Please guide me with the proper code to do so.

Thanks,
Sanat
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#19
Author: jongware
Date: Wed, 01 Apr 2009 14:06
3 lines
1259 bytes
Perhaps you should start with a simpler script -- set your target a bit lower. Go step by step and don't complain if it doesn't happen overnight. I have been programming JS for a handful of years and it's really just in the last year I can program exactly (more or less) what I intend to achieve.

It doesn't help you keep asking for useful snips (or entire scripts) of things that are difficult because I have to tell you what they do, where to insert them, and how to change. I might as well send a complete and totally custom script; and then you learned nothing at all (you'd learn my bank account number).
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#20
Author: sanatkumar
Date: Wed, 01 Apr 2009 14:29
4 lines
857 bytes
thanx jongware for ur valuable suggestion.I understand the same and i m planing to do so.But this requirement is bit urgent.So please help me in this script for which i shall b grateful to u.

Thanks,
Sanat
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#25
Author: Peter Kahrel
Date: Wed, 01 Apr 2009 15:55
5 lines
735 bytes
Sanat,

Make jongware an offer he can't refuse.

Peter
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#45
Author: sanatkumar
Date: Thu, 02 Apr 2009 04:44
3 lines
962 bytes
The main problem i am facing during learning this script is that there not enough resources available like tutorial,book,demo examples for practice.I m trying to get as much as information possible from the this forum.

Again i am seeking help from u guys for solving this script.Waiting 4 ur positive response.
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#106
Author: jongware
Date: Thu, 02 Apr 2009 10:17
24 lines
1511 bytes
Well, I'm at a loss.

Dave Saunders, in his JS blog <http://jsid.blogspot.com/2006_04_01_archive.html>, simply uses

      myParent.groups.add(gpArray)




-- then again, he was using CS2 there.

I tried numerous variations for about three consecutive hours (my boss doesn't read this forum), but the best I got was finding out

      var myGroup = app.activeDocument.groups.add(app.selection,null,LocationOptions.AT_BEGINNING,app.activeWindow.activePage);	//
      NOT app.documents!




complains about 'no parent'. The location is optional; yet, if you omit it, you get another error.

I found Dave's page with some google-fu: Google groups site:jsid.blogspot.com <http://www.google.com/search?q=groups+site%3Ajsid.blogspot.com> has a few more hits. I didn't read them all, but I think you should.

Or make Dave an offer he can't refuse.
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#114
Author: Dave_Saunders
Date: Thu, 02 Apr 2009 12:33
3 lines
818 bytes
It would have to be a very large offer. I'm no longer available for freelance work (at least, for the foreseeable future).

Dave
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#116
Author: jongware
Date: Thu, 02 Apr 2009 12:53
3 lines
801 bytes
Haven't you heard how much he's gonna offer? :-D

See some comparable problems <http://www.claymath.org/millennium/> and how much they make when solved.
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#119
Author: sanatkumar
Date: Thu, 02 Apr 2009 13:27
28 lines
1434 bytes
Surely i m gonna offer.
jongware,I tried the following code.But i m getting error like this:

Error String:Cant create page item.No valid parent found.
How to fix it again!!

main();

function main(){
	if (app.documents.length != 0){
		if (app.selection.length > 0){
			//myDocument = app.documents.add();
			var myObjectList = new Array;
            var myObjectList1 = new Array;
for (i=0; i<app.selection.length; i++)

myObjectList.push (app.selection[i]);

alert ("length of myObjectList is "+myObjectList.length);

var myGroup = app.activeDocument.groups.add(app.selection,null,LocationOptions.AT_BEGINNING,app.activeWindow.activePage);

				}
			}
		}

thanks,
Sanat
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#122
Author: Peter Kahrel
Date: Thu, 02 Apr 2009 14:05
6 lines
1026 bytes
It's the same in CS3 and CS4: feed an array to groups.add(). Suppose you have a page with several (ungrouped) items. Then these two lines create a group of all page items on that page:

myArray = myPage.pageItems.everyItem().getElements();
myPage.groups.add (myArray)

Peter
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#141
Author: Olav_Kvern
Date: Thu, 02 Apr 2009 20:20
7 lines
797 bytes
Hi Sanat,

You might take a look at the documentation script Group.jsx--it's in the archive on the InDesign scripting home page.

Thanks,

Ole
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#206
Author: sanatkumar
Date: Fri, 03 Apr 2009 14:34
30 lines
1502 bytes
hi everyone,finally i got my solution.Thanks everyone for ur great support.I wont hesitate to post the code so that other people can learn.If there is anything worng,then please let me know..thanks again..

Code :

main();

function main(){
	if (app.documents.length != 0){
		if (app.selection.length > 0){
			//myDocument = app.documents.add();
			var myObjectList = new Array;
            var myObjectList1 = new Array;
for (i=0; i<app.selection.length; i++)

myObjectList.push (app.selection[i]);

//alert ("length of myObjectList is "+myObjectList.length);

var myGroup = app.activeDocument.groups.add(myObjectList);

var myGroup1=myGroup.duplicate(myGroup1,[22,2]);
myGroup1.absoluteHorizontalScale=150;
myGroup1.absoluteVerticalScale=150;

				}
			}
		}

thanks and regards,
Sanat
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#209
Author: jongware
Date: Fri, 03 Apr 2009 15:56
10 lines
894 bytes
Congratulations are in order :-)

I still haven't found out why

      app.activeDocument.groups.add(myObjectList);




keeps on failing on my system ... I'll try your script (after the weekend :-)), perhaps it was just a typo on my side.
Re: how to group some objects and duplicate it and then enlarge the same group using javascript ??
#210
Author: Dave_Saunders
Date: Fri, 03 Apr 2009 16:39
3 lines
849 bytes
Are the objects in your object list on the first spread of the document? If not, that's why it's failing. You should add groups to the page's or spread's groups collection.

Dave
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads