FillPatternElementCreate Method |
Creates a new FillPatternElement.
Namespace: Autodesk.Revit.DBAssembly: RevitAPI (in RevitAPI.dll) Version: 27.0.4.0 (27.0.4.0)
Syntaxpublic static FillPatternElement Create(
Document document,
FillPattern fillPattern
)
Public Shared Function Create (
document As Document,
fillPattern As FillPattern
) As FillPatternElement
public:
static FillPatternElement^ Create(
Document^ document,
FillPattern^ fillPattern
)
static member Create :
document : Document *
fillPattern : FillPattern -> FillPatternElement Parameters
- document Document
-
The document in which to create the FillPatternElement.
- fillPattern FillPattern
-
The FillPattern associated to the newly created FillPatternElement.
Return Value
FillPatternElement
The newly created FillPatternElement.
Exceptions| Exception | Condition |
|---|
| ArgumentException |
fillPattern does not have a valid Target.
-or-
fillPattern does not have a valid Name.
-or-
fillPattern is a solid fill pattern.
-or-
fillPattern contains FillGrids with a zero Offset.
-or-
The name of the fillPattern already exists.
|
| ArgumentNullException |
A non-optional argument was null
|
Example
public void CreateComplexFillPattern(Document doc)
{
FillPattern fillPattern = new FillPattern("API-created", FillPatternTarget.Model,
FillPatternHostOrientation.ToHost);
List<FillGrid> grids = new List<FillGrid>();
grids.Add(CreateGrid(new UV(0, 0.1), 0.5, 0, 0.55, 1.0, 0.1));
grids.Add(CreateGrid(new UV(0, 0.5), 0.5, 0, 0.55, 1.0, 0.1));
grids.Add(CreateGrid(new UV(0, 0.1), 0.55, Math.PI / 2, 0.5, 0.4, 0.6));
grids.Add(CreateGrid(new UV(1.0, 0.1), 0.55, Math.PI / 2, 0.5, 0.4, 0.6));
fillPattern.SetFillGrids(grids);
using (Transaction t = new Transaction(doc, "Create fill pattern"))
{
t.Start();
FillPatternElement patternElement = FillPatternElement.Create(doc, fillPattern);
t.Commit();
}
}
private FillGrid CreateGrid(UV origin, double offset, double angle,
double shift, params double[] segments)
{
FillGrid fillGrid = new FillGrid();
fillGrid.Origin = origin;
fillGrid.Offset = offset;
fillGrid.Angle = angle;
fillGrid.Shift = shift;
List<double> segmentsList = new List<double>();
foreach (double d in segments)
{
segmentsList.Add(d);
}
fillGrid.SetSegments(segmentsList);
return fillGrid;
}
See Also