本文整理汇总了C#中Autodesk.ToRevitType方法的典型用法代码示例。如果您正苦于以下问题:C# Autodesk.ToRevitType方法的具体用法?C# Autodesk.ToRevitType怎么用?C# Autodesk.ToRevitType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Autodesk
的用法示例。
在下文中一共展示了Autodesk.ToRevitType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ByLine
/// <summary>
/// Create a Revit Grid Element in a Project along a Line.
/// </summary>
/// <param name="line"></param>
/// <returns></returns>
public static Grid ByLine(Autodesk.DesignScript.Geometry.Line line)
{
if (Document.IsFamilyDocument)
{
throw new Exception("A Grid Element can only be created in a Revit Project");
}
if (line == null)
{
throw new ArgumentNullException("line");
}
return new Grid( (Autodesk.Revit.DB.Line) line.ToRevitType());
}
示例2: ByArc
/// <summary>
/// Create a Revit Grid Element in a project along an Arc
/// </summary>
/// <param name="arc"></param>
/// <returns></returns>
public static Grid ByArc(Autodesk.DesignScript.Geometry.Arc arc)
{
if (Document.IsFamilyDocument)
{
throw new Exception("A Grid Element can only be created in a Revit Project");
}
if (arc == null)
{
throw new ArgumentNullException("arc");
}
return new Grid( (Autodesk.Revit.DB.Arc) arc.ToRevitType() );
}
示例3: BraceByCurve
/// <summary>
/// Create a brace.
/// </summary>
/// <param name="curve">The cruve which defines the center line of the brace.</param>
/// <param name="level">The level with which you'd like the brace to be associated.</param>
/// <param name="structuralFramingType">The structural framing type representing the brace.</param>
/// <returns></returns>
public static StructuralFraming BraceByCurve(Autodesk.DesignScript.Geometry.Curve curve, Revit.Elements.Level level, Revit.Elements.FamilySymbol structuralFramingType)
{
if (curve == null)
{
throw new System.ArgumentNullException("curve");
}
if (level == null)
{
throw new System.ArgumentNullException("level");
}
if (structuralFramingType == null)
{
throw new System.ArgumentNullException("structuralFramingType");
}
return new StructuralFraming(curve.ToRevitType(), level.InternalLevel, Autodesk.Revit.DB.Structure.StructuralType.Brace, structuralFramingType.InternalFamilySymbol);
}
示例4: ColumnByCurve
/// <summary>
/// Create a column.
/// </summary>
/// <param name="curve">The curve which defines the center line of the column.</param>
/// <param name="level">The level with which you'd like the column to be associated.</param>
/// <param name="structuralColumnType">The structural column type representing the column.</param>
/// <returns></returns>
public static StructuralFraming ColumnByCurve(
Autodesk.DesignScript.Geometry.Curve curve, Revit.Elements.Level level, Revit.Elements.FamilySymbol structuralColumnType)
{
if (curve == null)
{
throw new System.ArgumentNullException("curve");
}
if (level == null)
{
throw new System.ArgumentNullException("level");
}
if (structuralColumnType == null)
{
throw new System.ArgumentNullException("structuralColumnType");
}
var start = curve.PointAtParameter(0);
var end = curve.PointAtParameter(1);
// Revit will throw an exception if you attempt to create a column whose
// base is above its top.
if (end.Z <= start.Z)
{
throw new Exception("The end of the curve for creating a column should be above the start of the curve.");
}
return new StructuralFraming(curve.ToRevitType(), level.InternalLevel, Autodesk.Revit.DB.Structure.StructuralType.Column, structuralColumnType.InternalFamilySymbol);
}
示例5: ByEyePointTargetAndBoundingBox
/// <summary>
/// Create a Revit Perspective View from an Eye position and target position and Bounding Box
/// </summary>
/// <param name="eyePoint">Eye point in meters</param>
/// <param name="target">Target of view in meters</param>
/// <param name="boundingBox">Bounding box represented in meters</param>
/// <param name="name"></param>
/// <param name="isolateElement"></param>
/// <returns></returns>
public static PerspectiveView ByEyePointTargetAndBoundingBox(Autodesk.DesignScript.Geometry.Point eyePoint, Autodesk.DesignScript.Geometry.Point target, Autodesk.DesignScript.Geometry.BoundingBox boundingBox, string name, bool isolateElement)
{
if (boundingBox == null)
{
throw new ArgumentNullException("boundingBox");
}
if (eyePoint == null)
{
throw new ArgumentNullException("eyePoint");
}
if (target == null)
{
throw new ArgumentNullException("target");
}
if (name == null)
{
throw new ArgumentNullException("name");
}
return new PerspectiveView(eyePoint.ToXyz(), target.ToXyz(), boundingBox.ToRevitType(), name, isolateElement);
}
示例6: ByCurveLevelUpVectorAndType
/// <summary>
/// Create a Revit Structural Member - a special FamilyInstance
/// </summary>
/// <param name="curve">The curve path for the structural member</param>
/// <param name="upVector">The up vector for the element - this is required to determine the orientation of the element</param>
/// <param name="level">The level on which the member should appear</param>
/// <param name="structuralType">The type of the structural element - a beam, column, etc</param>
/// <param name="structuralFramingType">The structural framing type representing the structural type</param>
/// <returns></returns>
public static StructuralFraming ByCurveLevelUpVectorAndType(Autodesk.DesignScript.Geometry.Curve curve, Level level,
Autodesk.DesignScript.Geometry.Vector upVector, StructuralType structuralType, FamilySymbol structuralFramingType)
{
if (curve == null)
{
throw new System.ArgumentNullException("curve");
}
if (level == null)
{
throw new System.ArgumentNullException("level");
}
if (upVector == null)
{
throw new System.ArgumentNullException("upVector");
}
if (structuralFramingType == null)
{
throw new System.ArgumentNullException("structuralFramingType");
}
return new StructuralFraming(curve.ToRevitType(), upVector.ToXyz(), level.InternalLevel,
structuralType.ToRevitType(), structuralFramingType.InternalFamilySymbol);
}
示例7: ByCurve
/// <summary>
/// Create Rebar by Curves
/// </summary>
/// <param name="curves">Input Curves</param>
/// <param name="hostElementId">Host Element Id</param>
/// <param name="rebarStyle">Rebar Style</param>
/// <param name="rebarBarType">Bar Type</param>
/// <param name="startHookOrientation">Hokk orientation at the start</param>
/// <param name="endHookOrientation">Hook orientation at the end</param>
/// <param name="startHookType">Hook type at the start</param>
/// <param name="startHookType">Hook type at the start</param>
/// <param name="endHookType">Hook type at the end</param>
/// <param name="vector">Normal Vectors</param>
/// <returns></returns>
public static Rebar ByCurve(
Autodesk.DesignScript.Geometry.Curve curve,
int hostElementId,
string rebarStyle,
Revit.Elements.Element rebarBarType,
string startHookOrientation,
string endHookOrientation,
Revit.Elements.Element startHookType,
Revit.Elements.Element endHookType,
Autodesk.DesignScript.Geometry.Vector vector
)
{
if (curve == null) throw new ArgumentNullException("Input Curve missing");
if (hostElementId == null) throw new ArgumentNullException("Host ElementId missing");
if (rebarStyle == null) throw new ArgumentNullException("Rebar Style missing");
if (rebarBarType == null) throw new ArgumentNullException("Rebar Bar Type missing");
if (startHookOrientation == null) throw new ArgumentNullException("Start Hook Orientation missing");
if (endHookOrientation == null) throw new ArgumentNullException("End Hook Orientation missing");
//if (startHookType == null) throw new ArgumentNullException("Start Hook Type missing");
//if (endHookType == null) throw new ArgumentNullException("End Hook Type missing");
if (vector == null) throw new ArgumentNullException("Normal Vector missing");
ElementId elementId = new ElementId(hostElementId);
if (elementId == ElementId.InvalidElementId) throw new ArgumentNullException("Host ElementId error");
Autodesk.Revit.DB.Element host = DocumentManager.Instance.CurrentDBDocument.GetElement(elementId);
Autodesk.Revit.DB.Structure.RebarStyle barStyle = Autodesk.Revit.DB.Structure.RebarStyle.StirrupTie;
Enum.TryParse<Autodesk.Revit.DB.Structure.RebarStyle>(rebarStyle, out barStyle);
Autodesk.Revit.DB.Structure.RebarHookOrientation startOrientation = Autodesk.Revit.DB.Structure.RebarHookOrientation.Left;
Enum.TryParse<Autodesk.Revit.DB.Structure.RebarHookOrientation>(startHookOrientation, out startOrientation);
Autodesk.Revit.DB.Structure.RebarHookOrientation endOrientation = Autodesk.Revit.DB.Structure.RebarHookOrientation.Left;
Enum.TryParse<Autodesk.Revit.DB.Structure.RebarHookOrientation>(endHookOrientation, out endOrientation);
Autodesk.Revit.DB.Structure.RebarHookType startHookT = (startHookType == null) ? null : (Autodesk.Revit.DB.Structure.RebarHookType)startHookType.InternalElement;
Autodesk.Revit.DB.Structure.RebarHookType endHookT = (endHookType == null) ? null : (Autodesk.Revit.DB.Structure.RebarHookType)endHookType.InternalElement;
return new Rebar(curve.Approximate(), (Autodesk.Revit.DB.Structure.RebarBarType)rebarBarType.InternalElement, barStyle, host, startHookT, endHookT
, startOrientation, endOrientation, vector.ToRevitType(), true, true);
}
示例8: ReferenceCurveByCurve
// <summary>
/// Construct a Revit ModelCurve element from a Curve
/// </summary>
/// <param name="curve"></param>
/// <returns></returns>
public static ModelCurve ReferenceCurveByCurve(Autodesk.DesignScript.Geometry.Curve curve)
{
if (curve == null)
{
throw new ArgumentNullException("curve");
}
return new ModelCurve(curve.ToRevitType(), true);
}
示例9: ByCurveAndHeight
/// <summary>
/// Create a Revit Wall from a guiding Curve, height, Level, and WallType
/// </summary>
/// <param name="curve"></param>
/// <param name="height"></param>
/// <param name="level"></param>
/// <param name="wallType"></param>
/// <returns></returns>
public static Wall ByCurveAndHeight(Autodesk.DesignScript.Geometry.Curve curve, double height, Level level, WallType wallType)
{
if (curve == null)
{
throw new ArgumentNullException("curve");
}
if (level == null)
{
throw new ArgumentNullException("level");
}
if (wallType == null)
{
throw new ArgumentNullException("wallType");
}
height = height*UnitConverter.DynamoToHostFactor;
if (height < 1e-6 || height > 30000)
{
throw new ArgumentException(
"The height must be greater than 0 and less that 30000 ft. You provided a height of "
+ height + " ft.");
}
return new Wall(curve.ToRevitType(), wallType.InternalWallType, level.InternalLevel, height, 0.0, false, false);
}
示例10: ByElement
/// <summary>
/// Create an element based Tag
/// </summary>
/// <param name="view">View to Tag</param>
/// <param name="element">Element to tag</param>
/// <param name="horizontal">Horizontal alignment</param>
/// <param name="addLeader">Add a leader</param>
/// <param name="offset">Offset Vector or Tag Location</param>
/// <param name="isOffset">Specifies if the point is being used as an offset vector or if it specifies the tags location</param>
/// <param name="horizontalAlignment">Horizontal Alignment</param>
/// <param name="verticalAlignment">Vertical Alignment</param>
/// <returns></returns>
public static Tag ByElement(Revit.Elements.Views.View view, Element element, bool horizontal, bool addLeader, Autodesk.DesignScript.Geometry.Point offset = null, bool isOffset = true, string horizontalAlignment = "Center", string verticalAlignment = "Middle")
{
if (offset == null) offset = Autodesk.DesignScript.Geometry.Point.ByCoordinates(0, 0, 0);
Autodesk.Revit.DB.HorizontalAlignmentStyle alignHorizontal = Autodesk.Revit.DB.HorizontalAlignmentStyle.Center;
Enum.TryParse<Autodesk.Revit.DB.HorizontalAlignmentStyle>(horizontalAlignment, out alignHorizontal);
Autodesk.Revit.DB.VerticalAlignmentStyle alignVertical = Autodesk.Revit.DB.VerticalAlignmentStyle.Middle;
Enum.TryParse<Autodesk.Revit.DB.VerticalAlignmentStyle>(verticalAlignment, out alignVertical);
//Autodesk.Revit.DB.Document document = DocumentManager.Instance.CurrentDBDocument;
Autodesk.Revit.DB.View revitView = (Autodesk.Revit.DB.View)view.InternalElement;
Autodesk.Revit.DB.XYZ point = offset.ToRevitType(true);
Autodesk.Revit.DB.TagMode tagMode = TagMode.TM_ADDBY_CATEGORY;
Autodesk.Revit.DB.TagOrientation orientation = (horizontal) ? TagOrientation.Horizontal : TagOrientation.Vertical;
if (revitView.ViewType != ViewType.FloorPlan &&
revitView.ViewType != ViewType.EngineeringPlan &&
revitView.ViewType != ViewType.Detail &&
revitView.ViewType != ViewType.Section &&
revitView.ViewType != ViewType.Elevation &&
revitView.ViewType != ViewType.CeilingPlan)
throw new ArgumentException("Cannot place a Tag on active View");
if (isOffset)
{
BoundingBoxXYZ box = element.InternalElement.get_BoundingBox(revitView);
if (box == null) box = element.InternalElement.get_BoundingBox(null);
if (box != null)
{
double Y, X = 0;
switch (alignVertical)
{
case VerticalAlignmentStyle.Bottom: Y = box.Min.Y; break;
case VerticalAlignmentStyle.Top: Y = box.Max.Y; break;
default: Y = box.Min.Y + ((box.Max.Y - box.Min.Y) / 2); break;
}
switch (alignHorizontal)
{
case HorizontalAlignmentStyle.Left: X = box.Min.X; break;
case HorizontalAlignmentStyle.Right: X = box.Max.X; break;
default: X = box.Min.X + ((box.Max.X - box.Min.X) / 2); break;
}
point = new XYZ(X + point.X, Y + point.Y, 0 + point.Z);
}
else
{
if (element.InternalElement.Location != null)
{
if (element.InternalElement.Location.GetType() == typeof(LocationCurve))
{
LocationCurve lc = (LocationCurve)element.InternalElement.Location;
XYZ midpoint = lc.Curve.Evaluate(0.5,true);
point = new XYZ(midpoint.X + point.X, midpoint.Y + point.Y, 0 + point.Z);
}
else if (element.InternalElement.Location.GetType() == typeof(LocationPoint))
{
LocationPoint lp = (LocationPoint)element.InternalElement.Location;
point = new XYZ(lp.Point.X + point.X, lp.Point.Y + point.Y, 0 + point.Z);
}
else
throw new ArgumentNullException("Cannot determine location");
}
else
throw new ArgumentNullException("Cannot determine location");
}
}
return new Tag(revitView, element.InternalElement, orientation, tagMode, addLeader, point);
}
示例11: ByBoundingBox
/// <summary>
/// Create a Revit ViewSection by a bounding box
/// </summary>
/// <param name="box"></param>
/// <returns></returns>
public static SectionView ByBoundingBox(Autodesk.DesignScript.Geometry.BoundingBox box)
{
if (box == null)
{
throw new ArgumentNullException("box");
}
return new SectionView(box.ToRevitType());
}
示例12: Intersect
public Dictionary<string, object> Intersect(Autodesk.DesignScript.Geometry.Curve curve)
{
if (curve == null)
{
throw new System.ArgumentNullException("curve");
}
var revitFace = this.InternalFace;
Autodesk.Revit.DB.IntersectionResultArray xsects = null;
var result = revitFace.Intersect(curve.ToRevitType(), out xsects);
var pts = new List<Autodesk.DesignScript.Geometry.Point>();
var uvs = new List<Autodesk.DesignScript.Geometry.UV>();
var parms = new List<double>();
var edges = new List<Edge>();
var edgeParms = new List<double>();
if (xsects != null)
{
foreach (IntersectionResult ir in xsects)
{
try
{
edgeParms.Add(ir.EdgeParameter);
}
catch
{
edgeParms.Add(0);
}
edges.Add(ir.EdgeObject != null ? Edge.FromExisting(ir.EdgeObject) : null);
parms.Add(ir.Parameter);
uvs.Add(Autodesk.DesignScript.Geometry.UV.ByCoordinates(ir.UVPoint.U, ir.UVPoint.V));
pts.Add(ir.XYZPoint.ToPoint());
}
}
return new Dictionary<string, object>()
{
{"point", pts.ToArray() },
{"uv", uvs.ToArray() },
{"parm", parms.ToArray() },
{"edge", edges.ToArray() },
{"edgeParm", edgeParms.ToArray() }
};
}
示例13: BySweptBlend
/// <summary>
/// Create geometry by blending profiles along a path.
/// </summary>
/// <param name="profiles"></param>
/// <param name="spine"></param>
/// <returns></returns>
public static Solid BySweptBlend(List<PolyCurve> profiles, Autodesk.DesignScript.Geometry.Curve spine, List<double> attachmentParameters)
{
if (profiles == null)
{
throw new ArgumentException("profiles");
}
if (profiles.Count < 1)
{
throw new Exception("You must have more than one profile to create a swept blend.");
}
if (profiles.Count != attachmentParameters.Count)
{
throw new Exception("You must have the same number of profiles as attachment parameters.");
}
var loops = profiles.Select(x => x.ToRevitType() ).ToList();
return new Solid(loops, spine.ToRevitType(), attachmentParameters);
}
示例14: ByRevolve
/// <summary>
/// Create geometry by revolving a closed curve around an axis.
/// </summary>
/// <param name="profile">The profile to revolve.</param>
/// <param name="coordinateSystem">The coordinate system whose Z axis will be the axis of revolution.</param>
/// <param name="startAngle">The start angle in radians.</param>
/// <param name="endAngle">The end angle in radians.</param>
/// <returns></returns>
public static Solid ByRevolve(Autodesk.DesignScript.Geometry.PolyCurve profile, CoordinateSystem coordinateSystem, double startAngle, double endAngle )
{
if (profile == null)
{
throw new ArgumentException("profile");
}
if (coordinateSystem == null)
{
throw new ArgumentException("coordinate system");
}
var crvs = profile.ToRevitType();
return new Solid( crvs, coordinateSystem.ToTransform(), startAngle, endAngle);
}
示例15: ExtractLegalRevitCurve
private static Autodesk.Revit.DB.Curve ExtractLegalRevitCurve(Autodesk.DesignScript.Geometry.Curve curve)
{
// PB: PolyCurves may have discontinuities that prevent them from being turned into legal Revit ModelCurves.
// Moreover, a single ModelCurve may not be a composite or multiple curves.
// One could add a static method to ModelCurve that is an overload of ByCurve - ModelCurve[] ByCurve(PolyCurve).
// But, this adds an unnecessary high level of complexity to the Element rebinding code. Hence, we will go the
// more straightforward route of just providing an informative error message to the user.
if (curve is PolyCurve)
{
throw new Exception(
"Revit does not support turning PolyCurves into ModelCurves. "
+ "Try exploding your PolyCurve into multiple Curves.");
}
return curve.ToRevitType();
}