Jump to content
Developer Wiki and Function Reference Links ×

Flipping symbols or PIOs


Recommended Posts

Wezel

There's been a few times when I've wanted HThis or HThat when there's only things available that work based on selection.

One way of getting around this kind of problem is to load an array with the handles of all the selected objects, deselect everything, traverse the array applying a procedure to each object handle, and then traverse again to reselect the set of objects. One of the first calls in that procedure is SetSelect(h), and one of the last will be SetDSelect, if you see what I mean.

I don't know if this constitutes messing with the selection set...maybe it does. When the script's done you still have all the same objects selected.

Charles

Edited by ccroft
Link to comment

Hi Ray

I guess I must really be attracted to arrays for some reason. I think this is the second or third time on this list that I've suggested something that involves arrays, and somebody else has a different way.

When you do it your way, and you put the object in a group, how do you typically edit the group? I ask because I'm constantly working inside groups that already exist, and this is in fact what led me to my solution. To add an object to a group I've been using DoMenuText to edit, and that requires selection. Is there a better way?

My way looks like this:

PROCEDURE EG;

VAR

index :INTEGER;

hBin :ARRAY[1..100] of HANDLE;

FUNCTION loadBin(h:HANDLE): BOOLEAN;

Begin

index:=index+1;

IF GetType(h)=11 THEN hbin[index]:=h;

End;

PROCEDURE DrawInGroup(hGroup:HANDLE);

Begin

SetSelect(hGroup);

DoMenuTextByName('Group Navigation Chunk',1);

{work inside the group}

DoMenuTextByName('Group Navigation Chunk',2);

SetDSelect(hGroup);

End;

BEGIN

index:=0;

ForEachObjectInLayer(loadBin,2,0,2);

DSelectAll;

index:=1;

WHILE hBin[index]<>NIL DO

Begin

DrawInGroup(hBin[index]);

index:=index+1;

End;

index:=1;

WHILE hBin[index]<>NIL DO

Begin

SetSelect(hBin[index]);

index:=index+1;

End;

END;

RUN(EG);

Thanks for any suggestions.

Charles

(Edit) Just looked at SetParent for the first time in my life.....I think I see the light. Discussion forums are good.

Edited by ccroft
Link to comment

Hi Charles,

I think this is the second or third time on this list that I've suggested something that involves arrays, and somebody else has a different way.

There's always another way. It's not necessarily better, just different.

When you do it your way, and you put the object in a group, how do you typically edit the group?

In this case, I'd opt for a temporary layer and do my flipping there, using SetParent to move it back and forth. I only mentioned working in a group or a symbol to show possibility, not preference. If stacking order is an issue (as it often is) I also remember where it is in the stack and push it back when done, which can be done by remembering an adjacent handle.

To work inside groups I use FIn3D (FInGroup also works) to get a handle to an object inside, then navigate from there. The list inside the group is self-contained, so it's no different from working on any layer with handles. I don't typically enter a group with DoMenuTextByName (aka DMTBN), but if I want to display the contents of the group, I think using DMTBN then RedrawAll is the only way.

Raymond

Link to comment

Glad it helped. Posting here provided a nice reward for me as well.

For the benefit of any onlookers or future searchers I thought I'd quickly explain my journey. I have a number of menu commands for editing existing components of existing groups. Nested While loops and FEOIL works fine for this.

I ran into trouble when I wanted to add some new components. FEIOL set to go into groups left the new objects outside the group. The only thing I could find was DMTBN(edit). That worked on one selected group, but like FEOIL didn't put the new object in the group if more than one group was selected. I said good enuf...I'll only select one at a time and set the properties accordingly. A few years go by and I decide I need to solve this...too much wasted time. Hence the somewhat complicated bit posted above.

More time goes by. Raymond mentions groups and SetParent. "Is that the way it's supposed to be?" Now the above looks something like this:

FUNCTION addToGroup(hGroup:HANDLE):BOOLEAN;

Begin

{draw what needs to be added}

boo:=SetParent(LNewObj,hGroup));

End;

Begin

ForEachObjectinLayer(addToGroup,2,1,2);

End;

Not only is it easier to manage, it visibly runs better on larger numbers of groups.

So once again, thanks to the forum and thank-you Raymond.

Raymond: I'm pretty familiar with FInGroup: "How the fsk am I supposed to get this f'n rectangle inside this F'NGroup anyway?"

later

c

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...