change sheet orientation via "EventDrop" cell?

Started by perry59, February 11, 2022, 04:28:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

perry59

I have a stencil with various title blocks on it. In the shapesheet of each title block, in the EventDrop cell I have the following formula:

SETF(GetRef(PinX),0)+SETF(GetRef(PinY),0)+SETF(GetRef(LocPinX),0)+SETF(GetRef(LocPinY),0)

what this does is snap the titleblock into position regardless of where on the sheet it is dropped, works pretty good. I'd like to take it a step further and have it also change the page orientation depending on the orientation of the title block. For example, if my empty sheet is in landscape mode but I drag a portrait title block onto it then change the orientation of the sheet to match the title block. I'm thinking this probably can't be done in a simple shapesheet cell formula and I'll have to trap that event in my addin and handle it there. Am I correct in my assumption or is there some magic available in the shapesheet functions?

Thanks
what, me worry?

Croc

If the page dimensions are known, then it is enough to set 3 cells. For example, so
=SETF(GetRef(ThePage!PageWidth),297 mm)+SETF(GetRef(ThePage!PageHeight),210 mm)+SETF(GetRef(ThePage!PrintPageOrientation),2)
If the dimensions are unknown, then the task is more complicated - you need to swap ThePage!PageWidth and ThePage!PageHeight. Since the source is the same as the target, one formula will not be enough. It is necessary to separate the process of reading and writing data in time, and for this you will have to apply "magic". I think that after serious efforts it will be possible to do it.

Croc

For example, here is a shape that will reverse the page orientation for each EventDrop.
At the first step, the PageHeight, PageWidth values are stored in the Prompt cells.
At the second step, they are returned to the PageHeight, PageWidth cells in reverse order.

perry59

Quote from: Croc on February 11, 2022, 05:53:42 PM
If the page dimensions are known, then it is enough to set 3 cells. For example, so
=SETF(GetRef(ThePage!PageWidth),297 mm)+SETF(GetRef(ThePage!PageHeight),210 mm)+SETF(GetRef(ThePage!PrintPageOrientation),2)
If the dimensions are unknown, then the task is more complicated - you need to swap ThePage!PageWidth and ThePage!PageHeight. Since the source is the same as the target, one formula will not be enough. It is necessary to separate the process of reading and writing data in time, and for this you will have to apply "magic". I think that after serious efforts it will be possible to do it.

I did something almost exactly like that, sans the orientation, and it just had the effect of squishing or stretching my title block. So I ended up just adding a few lines of code to my addin. when a titleblock is dropped on the page it resets the width/height/orientation based on which titleblock was dropped. Works fine
what, me worry?

perry59

Quote from: Croc on February 11, 2022, 06:26:45 PM
For example, here is a shape that will reverse the page orientation for each EventDrop.
At the first step, the PageHeight, PageWidth values are stored in the Prompt cells.
At the second step, they are returned to the PageHeight, PageWidth cells in reverse order.

That is an interesting solution!
I will play with that a little and maybe ax the code in my addin.
Thanks!
what, me worry?

Croc

Do you have addin?
If you don't have software restrictions, I think it's better to use an add-in than complex shapesheet based solutions. Addin is a simpler and therefore more reliable tool. At least in cases like this.