Wednesday, March 28, 2012

Sample #8 of the new Vasari SDK samples is PlaceFamilesByXyzFromFile. The SDK sample contains code in both VB.NET and C#.

This sample places a family instance at the location specified in an external file. The file is a tab delimited text file with containing a row for each family instance to be placed in the model. A chess board setup is the topic of this one.

Monday, March 26, 2012

Sample #7 of the new Vasari SDK samples is ExportElementXYZtoTextFile. The SDK sample contains code in both VB.NET and C#.

This is a simple sample that can export XYZ coordinates for a selected category. Another sweet feature within this sample is the ability to also filter by Design Option. Filtering by Design Option can be tricky of you've never had to do it before. This sample can be run on any ol file you want.

The codes used to filter b category and design option is quite simple. An option in the API exists for you to filter by ContainedInDesignOption as shown below in a short snippet.

' Filter by the Category Selected - by Category NameDim m_col AsNew FilteredElementCollector(_doc)
m_col.OfCategory(_doc.Settings.Categories.Item(Me.ComboBoxCategory.SelectedItem.ToString).Id.IntegerValue)
m_col.WhereElementIsNotElementType()
' Get the selected item as an objectDim m_desOpt As clsDesignOption = Me.ComboBoxDesignOption.SelectedItem
' Do we have a Design Option Filter?IfNot m_desOpt.DesignOption IsNothingThen' Apply the Option Set ID to the Filter
m_col.ContainedInDesignOption(m_desOpt.DesignOption.Id)
EndIf

The element processing to get the element XYZ is fairly simple as well. This is a very basic implementation that doesn't take into account any corrections for offsets or hosting.

Friday, March 23, 2012

Sample #6 of the new Vasari SDK samples is ExtrudeRoomsToMass. The SDK sample contains code in both VB.NET and C#.

This is a sample that demonstrates how to read the boundaries of a room element and extrude a form using these coordinates. Each room results in a new family creation that gets loaded into the model with a material generated for the department name. The material color is completely randomized.

A sample model containing a few room contained only by a series of room separation lines named "ExtrudeRoomsToMass.rvt" is provided along with the sample.

If you want to see the code samples for this one, you'll just have to get the Vasari SDK from
matt dot jezyk at autodesk dot com!

Wednesday, March 21, 2012

Sample #5 of the new Vasari SDK samples is FormulaDrivenCurves. The SDK sample contains code in both VB.NET and C#.

This might be my favorite sample out of the Vasari SDK. This sample needs to be run from inside a fresh conceptual mass family. It takes a while to run, but it basically reads through a set of formulas describing a somewhat complex shape and lofts a series of surfaces to generate what looks a lot like a piece of pasta!

The formula steps through a series of i (cnTi) and j (cnTj) ranges to generate the reference points that are then used to generate a series of curves. The curves then get lofted around the object. The equation is shown here.

Tuesday, March 20, 2012

Sample #4 of the new Vasari SDK samples is MassColorGrossFloorArea. The SDK sample contains code in both VB.NET and C#.

This is a rather interesting sample that implements IUpdater. This sample requires no command execution to update the materialism on a set of masses based on their relative closeness to a target Gross Floor Area (GFA). As the mass dimensions or applied mass floors are adjusting resulting in an updated GFA, the colors aromatically adjust to yellow if their GFA is under the allowable value for "Max Underage Gross Floor Area", red if over the "Max Overage Gross Floor Area", and green if within the allowable tolerance of the "Target Gross Floor Area" parameter. each of these parameters are type parameters within the mass family.

Here is a snapshot of the masses before they have been adjusted to be all within the GFA target.

Here is the masses all green after their dimensions have been adjusted to target their "Target Gross Floor Area" values.

This sample helps construct a series of copied families all while incrementally filling in a numerical value within a specified integer parameter in the family. So basically you can take a series of families with formulas using this incremental value from this:

Friday, March 16, 2012

Sample #2 of the new Vasari SDK samples is DividedSurfacePanelRandomizer. The SDK sample contains code in both VB.NET and C#.

This is another short and sweet sample demonstrating how to randomize panels instantiated within a Divided Surface pattern. This sample needs to be run from within a family (rfa) file for an element who's face(s) have a Divided Surface and are populated with a panel based pattern family. A family file named "DividedSurfacePanelRandomizer.rfa" has been provided with the SDK to use for this sample.

This sample is provided with a modeless user form that prompts you to select a panel element from within a Divided Surface. Once you've selected a panel, the form loads all pattern families within the family that are of the same form pattern shape. These types are what will be randomized across the Divided Surface.

The code that handles the randomization is fairly straightforward. The .NET class "Random" used to generate a random number between 1 and the total qualifying panel families based on your original selection and uses that integer to identify the corresponding panel family symbol to apply in that instance.

Thursday, March 15, 2012

Sample #1 of the new Vasari SDK samples is DividedSurfacePanelNumbering. The SDK sample contains code in both VB.NET and C#.

This is a short and sweet sample demonstrating how to read the column and row numbers for panels instantiated within a Divided Surface pattern. This sample needs to be run from within a family (rfa) file for an element who's face(s) have a Divided Surface and are populated with a panel based pattern family. A family file named "DividedSurfacePanelNumbering.rfa" has been provided with the SDK to use for this sample.

The first task at hand is to get the document object and attain the list of Divided Surface elements in the family. This is also a good place to initiate the required transaction.

After we have the list of divided surface elements, we can iterate them and iterate through each of their U and V sets to get all the way down to the panel instance family. Once we have the family instance, we'll set the parameters to their grid values.

Some people don't know this, but Vasari 2.5 (just released today) has an SDK and it was put together by your friends at Case. The SDK has not been posted for download just yet, but Matt Jezyk said it was OK to have you guys contact him directly if you want to get an early copy of it.

Matt can be reached at: matt dot jezyk at autodesk dot com

Once you've managed to get a copy of the SDK and look inside, you may notice a lot of similarities between this Vasari SDK and the one that ships with Revit. The main difference between the Revit SDK and this new Vasari SDK is the 8 new Vasari oriented samples found in the "Vasari (NEW)" folder.

All 8 of the new Vasari samples are available in both VB.NET and C# for your programming pleasures.

DividedSurfacePanelNumbering

DividedSurfacePanelRandomizer

ExportElementXYZtoTextFile

ExtrudeRoomsToMass

FormulaDrivenCurves

Incrementer

MassColorGrossFloorArea

PlaceFamilesByXyzFromFile

Stay tuned for a daily post outlining each one of these samples and how to use them!