
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey Revit API Forum,
I am fairly new to the Revit API and I am struggling with a problem for which I cannot find a solution looking in the SDK, Forum etc.
I am trying to create a Pipe Fitting Family for elbows with varying angles programmatically. I had a look at the generic families and I want to set up a similar structure. I can create Reference Lines, parameterized Dimensions, Extrusions and their Alignments but I cannot associate the Sketch Plane of the Extrusion to a Reference Line which seems to be crucial to constrain the Extrusion to follow the rotating Reference Line (see attached Screenshot). This is possible using the UI and setting the Extrusion's Work/ Sketch Plane. But I could not find a way using the API. Do you guys have any recommendation how to change the Family's constraints or to set this property?
private Extrusion CreateExtrusion(XYZ origin, XYZ direction, double radius, ModelLine pinLine)
{
// create sketch plane at pin line
var app = _document.Application.Create;
var plane = Plane.CreateByNormalAndOrigin(direction.Negate(), origin);
var sketchPlane = SketchPlane.Create(_document, plane);
// create the profile
var profile = app.NewCurveArrArray();
var curves = app.NewCurveArray();
curves.Append(Arc.Create(plane, radius, 0, Math.PI * 2));
profile.Append(curves);
// create the extrusion
var extrusion = _document.FamilyCreate.NewExtrusion(false, profile, sketchPlane,
UnitUtils.ConvertToInternalUnits(10, UnitTypeId.Millimeters));
// refer work plane of extrusion
// TODO
return extrusion;
}
Thanks a lot!
Cheers,
Jan
Solved! Go to Solution.