View Align Script Needs To Be Run Twice

Hi All,

I have a script which is

a) Applying a scope box to views placed on a specific set of sheets. Cropping these Views. Turning the Crop Regions off on these views.
b) Assigning a viewport type to these views (to remove view titles).
c) Aligning the viewports on these sheets using a Template Sheet as a reference. The node I’m using for this function is the “Tool.AlignViewsFromTemplateSheet” from the SteamNodes package.

The script is (almost) working perfectly…

Before running the script my project looks like this (the top left sheet “A1.003 - GROUND FLOOR PLAN” is the 'Template Sheet with the viewport placed in the desired location):

After running the script once the viewports on the other sheets move, but not to the desired location:

The only way I can get these viewports in the desired location is by running the script once more:

I’ve tried various combinations of sequencing the various parts of the script (Passthrough node, Clockwork Package) to see if it was due to an error of this nature but no luck.

I also tried duplicating the Tool.AlignViewsFromTemplateSheet node to essentially have it run twice in the hope this would automatically run this part of the script twice - but again, no luck.

I know it’s not critical as the script is still working but can anybody shed any light on why this is happening, or what the cause may be?

Thanks.

1 Like

Hey,

There’s a vertical structure to your graph, I would try and set things up to be as linear as possible…

A result of your vertical structure, is that your ‘Crop’ node is on one branch, whereas your ‘Align’ node is on a separate branch…

I would guess that when you Crop, it then correctly defines the Centre point which is used for Align…

The lack of connection between these gives you the wrong alignment (I’m guessing! I might be wrong :slight_smile: )

When you run a second time, the Centre point is correct and they Align.

Hope that is useful,

Mark

1 Like

Hi @Mark.Ackerley

I had a similar thought, and tried to structure the script in a more linear path as you suggest (that’s what I meant by the below, sorry if that wasn’t clear):

I will try again though just in case I didn’t do it correctly the first time. I’ll let you know how I go.

Thanks for the suggestion Mark.

1 Like

I think you need to try and use Transaction.Start and Transaction.End to make sure the sheets and views are modified properly and cropped before trying to move them around.

3 Likes

Hi Sean,

Are the Transaction.Start & Transaction.End nodes you suggest different to the Passthrough node from the Clockwork package in the function they perform?

Thanks.

Yes, they force the start and stop of the transaction in Revit which is modifying the viewport type and crop / scope box settings. It is what commits these changes before continuing on and should resolve your issues

Ok understood. I’ve been trying to do this using the passthrough node. Is there a reason you suggest the transaction nodes instead? Just trying to get a better understanding of all this…

Thanks.

Revit does all of it’s actions using Transaction in the behind the scenes code, and a Dynamo session typically only uses ONE Transaction per run. This means that sometimes grpahs like yours that rely on things being done in an order don’t always work UNLESS you force Dynamo to use Commit (Tansaction.End) and Start (Transaction.Start) a new one. You may also still need the Passthrough to wait on the elements to give the nodes, but they won’t do it on thier own.

3 Likes

Thanks for the clear and concise explanation Sean. Much appreciated.

I think this should resolve the issue once I figure out how to use these nodes.

I was relying solely on the passthrough nodes to achieve this but now realise that alone is not enough…

Cheers

It worked! Thanks Sean!

1 Like