Rhinoscript-ing orienting a plane on a surface

I’m doing a script where I want to orient a block relative to a surface according to the following parameters:

-There is a plane slicing through the target surface in which the block must stay oriented
-The block has a ‘base’ reference surface that is supposed to ‘mate’ to the target surface…inasmuch as is possible given the slice plane, if the slice plane is not perpendicular to the target surface then whichever EDGE of the block touches it first has to be aligned with the target surface as best as it can.
-There is a line defining a starting position for the block to orient that we want to stay as close to as possible. If a straight extension of that line would have the block ‘fall off’ the target surface, it needs to fully rest on it.

So I could imagine doing this(and have done similar tasks) by just brute-force moving and rotating the block along the plane until it “just touches” the target surface. The problem is I would need to do this whole iterative operation possibly 500 times per script run, and that would take forever and use up too much memory. In general terms how might I try to do this while minimizing the undo stack that gets generated?

Hi Jim,

I’m sorry but I cannot picture what you are trying to do. Sample geometry might be helpful.

Sounds complicated…

HI Jim,

I think you may be looking for XformRotation and TransformObjects - if you rotate around the point intersection of the line that should constrain it.

Will