Set Reference Plane on Reference Line Problem

Set Reference Plane on Reference Line Problem

Anonymous
Not applicable
1,577 Views
2 Replies
Message 1 of 3

Set Reference Plane on Reference Line Problem

Anonymous
Not applicable

Hi, I am creating family in code. For that I am using family document created from template - Metric Generic Model. That document has only one reference line which I created previously by hand. In code I want to do selection of Work Plane, same as can be done by hand in Revit using option Pick a plane. Plane witch I target is one of Reference Plane at Reference Line. Do someone have idea how to accomplish it?

 

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

rosalesduquej
Alumni
Alumni
Accepted solution

Hi,

 

Ok I'm trying to understand what you are doing. Let's start from the beginning. You are creating a new Family document from the API based on a Template. using which method? are you using  application.NewFamilyDocument(templateFileName);

 

Ok let's assume you are. What you can do after is modify that family, have you tried that? There is a method called EditFamily in the Document class which will get you the document of a loaded family to edit. After that you could reload your family to the Document with the LoadFamily method. 

 

Have you used this before? 

 

In case not, I'm sharing a very useful link about Families in Revit API. http://help.autodesk.com/view/RVT/2016/ENU/?guid=GUID-DC143EB8-43CB-48AB-938E-7ADE3A9D2E63

 

Once that part is cleared out you can continue with the set of Reference Plane.

 

Cheers,

 



Jaime Rosales D.
Sr. Developer Consultant
Twitter | AEC ADN DevBlog
0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

Thank you Jaime,

 

I have found Reference Plane by filtering Sketch Planes in my Family Document and chose appropriate one by its name.

 

FilteredElementCollector collectorSP = new FilteredElementCollector(familyDocument).OfClass(typeof(SketchPlane));
SketchPlane skethPlane = null;
foreach (SketchPlane sp in collectorSP)
{
if (sp.Name == "Reference Lines")
{
skethPlane = sp;

break;
}
}
if (skethPlane == null) return;

 

Now I have another problem - I want to place new family instance on that plane. To explain, I am now creating family witch has inside another family, so I want to insert that “second’ family in working one, let’s call working family MainFamily and second SecondFamily. For that, I have used method NewFamilyInstance with next parameters: 

 

NewFamilyInstance(Reference reference, XYZ location, XYZ referenceDirection, FamilySymbol symbol);

 

  • reference: skethPlane.GetPlaneReference() – reference from filtered skethPlane.
  • location:GeometryCurve.GetEndPoint(0) – start point of reference line in MainFamily (working family)
  • referenceDirection: GeometryCurve.GetEndPoint(1) - referenceLine.GeometryCurve.GetEndPoint(0) – direction of line
  • symbol: symbol of SecondFamily

In SecondFamily I set parameter FAMILY_WORK_PLANE_BASED to true. familyDocument.OwnerFamily.get_Parameter(BuiltInParameter.FAMILY_WORK_PLANE_BASED).Set(1);

All that together looks like this:

FamilyInstance instance = familyDocument.FamilyCreate.NewFamilyInstance(skethPlane.GetPlaneReference(), referenceLine.GeometryCurve.GetEndPoint(0),
referenceLine.GeometryCurve.GetEndPoint(1) - referenceLine.GeometryCurve.GetEndPoint(0), profileSymbol);

 

But, it have not worked when I moved reference line I got warning or there is not connection between instance and reference plane from reference line. Do you have an idea what to do? Again, I want to place my SecondFamily on WorkPlane picked on ReferenceLine from MainFamily…

0 Likes