Problem with Alignments creating a rotating element using the Family API

Problem with Alignments creating a rotating element using the Family API

Anonymous
Not applicable
391 Views
2 Replies
Message 1 of 3

Problem with Alignments creating a rotating element using the Family API

Anonymous
Not applicable

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?   

janfroehlichW3W65_0-1633013208674.png

 

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

 

 

 

0 Likes
Accepted solutions (1)
392 Views
2 Replies
Replies (2)
Message 2 of 3

RPTHOMAS108
Mentor
Mentor
Accepted solution

Not a very easy starting point for you, there is no inherent API support utility for this. You'll have to find the references by constructing them from strings similar to link. 

 

Solved: Create sketch plane based on reference line - Autodesk Community - Revit Products

 

Doing it in code with the API rather than using the family editor is like putting a puzzle together in a dark room using only your thumbs to move the pieces into place. I would rather just include the family with the add-in.

 

 

Message 3 of 3

Anonymous
Not applicable

Thanks Thomas for your ideas. I might go for the second proposal and start with the reference line structure right away in a family template.

0 Likes