Thursday, January 29, 2015

Dynamo - Custom Plot Stamp

Here is an example of using Dynamo to do digit things that you cannot do natively in Revit®: modify digit accumulation identify to additional (in this example, converting integers to strings) and concatenating binary section into digit string. The rousing for creating this Dynamo enter was this thread in the Autodesk Revit Architecture Discussion Group. The request was a wish for the knowledge to created a bespoken fellow stamp, display meet a denotive fellow in yyyymmdd format, with threesome "random" numerals in front and in back, to "disguise" the actual determine of the string, patch allowing those who undergo to wager when the strategy was made. The comparability was to what you crapper do with comic in AutoCAD®. While the Dynamo file, by its rattling nature, cannot provide the automatic update that AutoCAD comic provide, it crapper standardize the formatting of the bespoken fellow stamp, and attain manual updates easier than editing the continuance in the Project Properties dialog.

NOTE: If you impact in a "shared" environment, please consult with your BIM Manager and/or co-workers before modifying an office- or project-standard mutual parameters file, send template or denomination country family.

The first stage is to ordered things up in Revit. This is finished the aforementioned artefact that you would do it to ordered up a manually updated denomination country parameter. A hurried summary of that follows:
  1. Create a mutual constant to be used to stop the bespoken strategy walk text, if you do not already hit one. On the Manage slip tab, on the Settings panel, superior the Shared Parameters tool. Set the pertinent mutual parameters enter current, superior the pertinent constant assemble and create the parameter. Set the constant identify to Text and add a tooltip description (2015 promulgation or later), so that others module undergo the determine of the mutual parameter.
  2. Add a Project Parameter to your send (for an existing project) or your send template(s) (for future projects). Choose the Shared parameter radio fix and then opt the Select fix to opt the mutual constant created in Step 1. Select a assemble low which the constant module be placed, if the initial "Text" assemble is not to your liking. Choose the Instance radio fix and ordered the Category to Project Information.
  3. Edit your denomination country kinsfolk or families. In apiece one, add a Label to display the continuance of the mutual constant created in Step 1. On the Create tab, on the Text panel, opt the Label tool. In the Edit Label dialog, superior the Add Parameter agency in the modify left, and add the mutual constant created in Step 1. Select the new additional Shared Parameter in the Category Parameters itemize incase and superior the Add parameter(s) to label agency (green mark icon). Change the Sample Value for the parameter, if desired, then superior OK. Fine ordered the positioning and orientation of the adjudge in your denomination country family, then spend or spend as the family, if desired, and load the denomination country kinsfolk into your send and/or send template file.
At this point we hit a Project Parameter that crapper be ordered in digit place for the whole project, and which module display in the adjudge additional to the denomination country family(ies).
You could unstoppered the Project Properties talking (Manage slip tab, Settings panel, Project Information tool) and manually enter a continuance (or superior an instance of the denomination country and utter on "?" for the adjudge you additional and identify the continuance in there. While that is a dead legal workflow, by using Dynamo, you crapper update the continuance in a consistent manner. The image beneath shows the coverall Dynamo graph, followed by an account of the parts.
  1. Three stages of nodes create the pieces of the denotive fellow in yyyymmdd format. The DateTime.Now convexity (Library line = Core > DateTime > Now) generates the underway grouping instance and date. In the image below, every of the nodes hit a "watch toggle" and they are toggled on, so that the continuance of the convexity is displayed beneath the node. We exclusive need the year, period and day, so the continuance of that convexity is passed to the DateTime.Components convexity (Core > DateTime > Actions > Components), which generates separate denotive values for the traded components. The ordinal stage consists of digit ToString convexity (Core > Builtin Functions > ToString), which converts the denotive assemblage production from the DateTime.Components convexity to a progress (text), and digit bespoken nodes titled Integer To String - 2 Char Zero Padding, which modify the period and period production from integers to section patch also assuring a two-character termination by adding a "0" at the front of any single-character strings. These bespoken nodes were created from a sort of out-of-the-box nodes; I module discuss the creation of bespoken nodes and exhibit the intrinsic workings of these nodes in a future article.
  2. The haphazard three-digit prefix and ending are generated by digit kindred sets of nodes. In each, digit Number nodes (Core > Input > Number) establish the arrange of double-precision actual sort values that the Math.Random convexity (Core > Math > Actions > Random(value1:double, value2:double)) uses when generating a double-precision haphazard number. I chose 100 and 999 as the boundaries to verify I would intend a three-digit (whole sort part) result. Note that I had chosen threesome quantitative place display for drawing in Dynamo at the instance these concealment captures were take, so every denotive values, modify integers, display with threesome quantitative places (Settings pulldown menu > Number Format > 0.000). The production of the Math.Random convexity is passed through the Math.Floor convexity (Core > Math > Actions > Floor), to modify the threefold to an number (rounding downbound to the incoming number value, effectively truncating any fractional amount), preceding to using additional ToString convexity to modify the number to a book string.
  3. We now hit every of the section we need to create the book continuance for the strategy stamp. A String.Concat convexity (Core > String > Actions > Concat) takes the fivesome section (random prefix, year, month, period and haphazard suffix) and combines them into digit string. The String.Concat convexity starts discover with digit input, string0; you crapper ingest the + fix to add more inputs and the - fix to vanish inputs as required by your application.
  4. Now that we hit the nodes required to create the progress we poverty for the strategy stamp, we need to intend that continuance discover of Dynamo and into the DateCode constant in Revit. To do that, we first need to intend the ProjectInfo element, which holds the Project Information parameters. Two nodes module do that for us. First, the Categories convexity (Revit > Selection > Categories) allows you to superior from a itemize of every of the built-in Revit categories, digit of which is ProjectInformation. Passing that collection to the All Elements of Category convexity (Revit > Selection > All Elements of Category) selects the ProjectInfo surroundings for the underway project. These digit nodes do not hit a "watch toggle", so I included a Watch convexity (Core > View > Watch) in the coverall interpret (not shown in the image below) to analyse the termination of the All Elements of Category node. This is not needed for the Dynamo function to work.
  5. The Element.SetParameterByName convexity (Revit > Elements > Element > Actions > SetParameterByName) is where our continuance gets pushed into the Revit project. It takes threesome inputs, the surroundings we acquired in Step 7, a progress from a String convexity (Core > Input > String) into which the study of the constant to be ordered has been entered (case sensitive, enter the study just as it appears in Revit), and the continuance to be set, which is the concatenated progress from Step 6.
With every of the elements in place, and the interpret saved to a Dynamo enter (DYN extension), it is exclusive a concern of imperative the Run fix to make the program. Dynamo module create the prefix and ending numbers, foregather up the year, period and period numbers, modify them every to section and combine them into digit string. The Project Information surroundings module be accessed and the progress continuance module be used to ordered the continuance of the DateCode parameter.

This haw seem like a aggregation of work, compared to typing cardinal drawing in a talking box, and if you exclusive ever ingest it digit time, it is. But you crapper spend the Dynamo enter and every instance you are most to plot, exclusive move Dynamo, unstoppered the enter and superior the Run button.

In this admittedly ultimate example, you crapper wager how cushy it is to indite a information in Dynamo and hit that information interact with Revit. Dynamo takes tending of every of the hard impact of interfacing with the API; every you need to do is enter the nodes.

People who read this post also read :

No comments :

Post a Comment