- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi there,
First of all I haven't found an answer to my question in an existing post, please feel free to redirect me there if you know one.
I'm currently coding a plugin for Revit 2015 that insert a family of my choice inside an existing project.
I want to insert the family directly on a face of an existing 3D item. But depending on the situation I must insert it on different type of faces, such as planar faces or cylindrical. Problem is, I can't get my code to function on either, I don't know how to check for the type of face prior to my operations.
That's my code for cylindrical faces
Reference r = uidoc.Selection.PickObject(ObjectType.Face,
"Please pick a point on a face for family instance insertion");
Element e = doc.GetElement(r.ElementId);
GeometryObject obj = e.GetGeometryObjectFromReference(r);
//PlanarFace face = obj as PlanarFace;
CylindricalFace face = obj as CylindricalFace;
XYZ p = r.GlobalPoint;
XYZ v = face.Axis.CrossProduct(XYZ.BasisZ);
if (v.IsZeroLength())
{
v = face.Axis.CrossProduct(XYZ.BasisX);
}
doc.Create.NewFamilyInstance(r, p, v, symbol);And that's my code for planar faces
Reference r = uidoc.Selection.PickObject(ObjectType.Face,
"Please pick a point on a face for family instance insertion");
Element e = doc.GetElement(r.ElementId);
GeometryObject obj = e.GetGeometryObjectFromReference(r);
PlanarFace face = obj as PlanarFace;
//CylindricalFace face = obj as CylindricalFace;
XYZ p = r.GlobalPoint;
XYZ v = face.Normal.CrossProduct(XYZ.BasisZ);
if (v.IsZeroLength())
{
v = face.Normal.CrossProduct(XYZ.BasisX);
}
doc.Create.NewFamilyInstance(r, p, v, symbol);Almost nothing changes except for the declaration of v with the change : Axis/Normal
I've been using the code from Jeremy Tammik thebuildingcoder, I'm fairly new to programming and totally new to C#, and I've never used any API before.
I also have other questions :
Right now I'm typing the path and the name of the family item that I want to insert directly inside my code. Ideally, I'd like the user to pick the family when he starts the plugin, but I have no idea how to do that.
Last thing I'd like to know is, after my family is inserted, how do I run automatically an interference check to see if there is any collision. The plugin is aimed to people totally new to geomatics, that have never used any software like autocad, I want them to push the least buttons possible to achivieve their goal.
Thank you very much in advance for your time.
Jordi
Solved! Go to Solution.
Developer Advocacy and Support +