How to place a face base family at column and beam?

How to place a face base family at column and beam?

thannaingoo.api
Advocate Advocate
973 Views
3 Replies
Message 1 of 4

How to place a face base family at column and beam?

thannaingoo.api
Advocate
Advocate

Dear Developer,

 

Is it possible to transform the face GetInstanceGeometry to GetSymbolGeometry?

 

I can use GetInstanceGeometry for intersection checking but I cannot use that face to place a family.

 

How should I place a family at intersection face of column and beam?

 

I want to check intersection at face  and then place a family.

 

Kindly help me.

 

Thanks Advance,

Naing Oo

 




List<Face> instanceFace = new List<Face>(); foreach (GeometryObject instObj in instance.GetInstanceGeometry()) { Solid solid = instObj as Solid; if (null == solid || 0 == solid.Faces.Size || 0 == solid.Edges.Size) { continue; } foreach (Face face in solid.Faces) { PlanarFace pf = face as PlanarFace; if (pf != null) { instanceFace.Add(pf); } } }
0 Likes
Accepted solutions (2)
974 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk
Accepted solution

Yes, that should be possible, by using the (possibly nested) sequence of geometry instance transform properties:

 

http://www.revitapidocs.com/2017/99cb4580-9b59-6564-8181-6082f275a869.htm

 

Some closely related aspects are discussed here:

 

http://thebuildingcoder.typepad.com/blog/2015/09/directshape-from-face-and-sketch-plane-reuse.html

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 4

thannaingoo.api
Advocate
Advocate

Thanks Jeremy, 

 

How should I place a face base family to Column and Beam?

 

I can place a face base family to wall but I can't do for column and beam.

 

Is there any reference?

 

Thanks,

Naing Oo

 

0 Likes
Message 4 of 4

aignatovich
Advisor
Advisor
Accepted solution

Hi!

 

You can create faced base family instances on another family instance without any limits:

 

private static void CreateInstancesOnHostFamilyFaces(FamilySymbol familySymbol, FamilyInstance hostInstance)
{
	var faces = GetSolids(hostInstance)
		.SelectMany(x => x.Faces.OfType<PlanarFace>());

	var doc = familySymbol.Document;

	using (var transaction = new Transaction(doc, "create families"))
	{
		transaction.Start();

		if (!familySymbol.IsActive)
			familySymbol.Activate();

		foreach (var planarFace in faces)
		{
			var faceBox = planarFace.GetBoundingBox();

			var center = planarFace.Evaluate(0.5*(faceBox.Max + faceBox.Min));

			doc.Create.NewFamilyInstance(planarFace, center, XYZ.Zero, familySymbol);
		}

		transaction.Commit();
	}
}

private static IEnumerable<Solid> GetSolids(Element element)
{
	var geometry = element
	  .get_Geometry(new Options {ComputeReferences = true});

	if (geometry == null)
		return Enumerable.Empty<Solid>();

	return GetSolids(geometry)
		.Where(x => x.Volume > 0);
}

private static IEnumerable<Solid> GetSolids(IEnumerable<GeometryObject> geometryElement)
{
	foreach (var geometry in geometryElement)
	{
		var solid = geometry as Solid;
		if (solid != null)
			yield return solid;

		var instance = geometry as GeometryInstance;
		if (instance != null)
			foreach (var instanceSolid in GetSolids(instance.GetInstanceGeometry()))
				yield return instanceSolid;

		var element = geometry as GeometryElement;
		if (element != null)
			foreach (var elementSolid in GetSolids(element))
				yield return elementSolid;
	}
}