change work plane of family instance

change work plane of family instance

m.walterN99B3
Contributor Contributor
249 Views
2 Replies
Message 1 of 3

change work plane of family instance

m.walterN99B3
Contributor
Contributor

I insert a generic model into a window family and rotate and move it to the right place. Moreover I create a reference line, that can be rotated by an angle parameter. Now I like to set the work plane of the generic model instance to the reference line, in order the generic model can be rotated by the angle parameter, like the reference line is already rotated. In GUI I reach this by selecting the generic model instance and "Edit Workplane" and selecting the reference plane. How can I do this with the API?

 

!forum question.png

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

Charles.Piro
Advisor
Advisor
Accepted solution

Hi,

 

Currently, with the Revit API's, you can't modify the workplane of a FamilyInstance. You have to create a new FamilyInstance.
Here are the steps to follow:
  - Save the parameter values
  - Insert new FamilyInstance at the right place
  - Set the saved parameters
  - Delete the original FamilyInstance

😉



PIRO Charles
Developer

PIRO CIE
Linkedin


0 Likes
Message 3 of 3

m.walterN99B3
Contributor
Contributor

Thank you for your reply!

So in my case the solution could be to create the family instance directly on the right sketch plane.

But I cannot get it working using the following code:

 

ModelLine modelLine = docFamily.FamilyCreate.NewModelCurve(curve, sketchPlane) as ModelLine;
modelLine.ChangeToReferenceLine();
...
SketchPlane sketchPlane = modelLine.SketchPlane;
Curve curve = modelLine.GeometryCurve;
XYZ location = curve.GetEndPoint(0);
FamilyInstance familyInstance = docFamily.FamilyCreate.NewFamilyInstance(location, familySymbol, sketchPlane, StructuralType.NonStructural);

 

The family instance is inserted correctly. But it does not move or rotate with the model line, which is driven by an angle parameter.

The generic model is work plane-based, but "Always vertical" is unchecked.

!generic model.png

What I am missing here?

0 Likes