Jump to content

Grouping Objects?


Recommended Posts

I have just read a post by Petri who says...

Groups are put in class 'None' regardless of the class(es) of their elements or your active class.

Well, not to worry: the matter was discussed over a year ago and yours truly offered a solution in the form of a script:

- the group is placed in the current active class unless

- all its members are in the same class in which case the group inherits that class.

If you have groups with over 1000 members, you will need to change the array limit from [1..1000] to, say, [1..10000]. Old habit from the time when MiniPascal did not release memory used by arrays: I have as small arrays as possible.

Don't ditch the normal Group command if you handle very large groups: this script may be a tad slow, because it needs to do a lot more work.

Hope it works!

Copy between the {----------} lines,

say 'Create Plug-In',

click 'New',

type a name (eg Super Grouper);

choose 'Command',

click 'Script',

say 'Paste',

click 'OK',

click 'Done'.

Then use the Workspace editor to install the command (it is in category Menu commands/Miscellaneous) and possibly a keyboard shortcut.

{------------------------}

PROCEDURE SuperGrouper; { ? Petri Sakkinen 2002-2004 }

{ -- This is freeware but you may not remove the ? notice. Use at your own risk.-- }

VAR

i, n : INTEGER;

theClass, currentClass, prevClass : STRING;

objClass : ARRAY[1..1000] OF STRING;

obHd, gHd : HANDLE;

allTheSame : BOOLEAN;

PROCEDURE StoreObjectClass;

BEGIN

i := i+1;

currentClass := GETCLASS(obHd);

objClass := currentClass;

IF NOT(prevClass = currentClass) THEN allTheSame := FALSE;

prevClass := currentClass;

END;

PROCEDURE RestoreObjectClass;

BEGIN

SETCLASS(gHd, theClass);

obHd := FINGROUP(gHd);

WHILE obHd <> NIL DO BEGIN

i := i+1;

SETCLASS(obHd, objClass);

obHd := NEXTOBJ(obHd);

END;

END;

BEGIN

i := 0;

allTheSame := TRUE;

theClass := ACTIVECLASS;

obHd := FSACTLAYER;

prevClass := GETCLASS(obHd);

WHILE obHd <> NIL DO BEGIN

StoreObjectClass;

obHd := NEXTSOBJ(obHd);

END;

GROUP;

i := 0;

gHd := LSACTLAYER;

IF allTheSame THEN SETCLASS(gHd, currentClass) ELSE RestoreObjectClass;

END;

RUN(SuperGrouper);

{-------------------------------}

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...