Create wall based window family with non rectangular cut

Create wall based window family with non rectangular cut

Anonymous
Not applicable
1,089 Views
3 Replies
Message 1 of 4

Create wall based window family with non rectangular cut

Anonymous
Not applicable

Hi,

 

I'd like to create a wall based window family with a non rectangular cut by API.

 

I load a family template file containing a rectangular wall. ("Cut with Voids When Loaded" is set to true) Then I add an extrusion and call InstanceVoidCutUtils.AddInstanceVoidCut() with the wall and the extrusion. But CanBeCutWithVoid() returns false and I'm getting an exception when running AddInstanceVoidCut(): "The element cannot be cut with a void instance.\r\nParameter name: element"

 

My code is:

 

 

Document docFamily = uiapp.Application.NewFamilyDocument("c:\\Window_template.rft");

using (Transaction tx = new Transaction(docFamily, "Modify"))
{
	tx.Start();

	XYZ p1 = new XYZ(0, 0, 0);
	XYZ p2 = new XYZ(5, 0, 0);
	XYZ p3 = new XYZ(5, 0, 10);
	Line line1 = Line.CreateBound(p1, p2);
	Line line2 = Line.CreateBound(p2, p3);
	Line line3 = Line.CreateBound(p3, p1);

	CurveArray item = new CurveArray();
	item.Append(line1);
	item.Append(line2);
	item.Append(line3);

	CurveArrArray profile = new CurveArrArray();
	profile.Append(item);

	Plane plane = Plane.CreateByNormalAndOrigin(new XYZ(0, 1, 0), new XYZ(0, -1, 0));
	SketchPlane sketchPlane = SketchPlane.Create(docFamily, plane);

	// Create the extrusion. The first parameter "false" specifies that it will be a void
	Extrusion extrusion = docFamily.FamilyCreate.NewExtrusion(false, profile, sketchPlane, 2.0);

	Wall wall = null;
	foreach (Wall w in new FilteredElementCollector(docFamily).OfClass(typeof(Wall)))
	{
		wall = w;
	}

	bool b = InstanceVoidCutUtils.CanBeCutWithVoid(wall);
	InstanceVoidCutUtils.AddInstanceVoidCut(docFamily, wall, extrusion);

	docFamily.Regenerate();

	tx.Commit();
}

// save family file
FileHelper.SaveDocToFile(docFamily, sFamilyFileName);

// close family file
docFamily.Close();

What am I doing wrong?

I attached the template file too.

 

Thanks!!!

 

 

 

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

bimwood
Explorer
Explorer

Looks to me as though the InstanceVoidCutUtils.AddInstanceVoidCut() method expects cuttingInstance to be a FamilyInstance (containing unattached voids), not a bare void extrusion.

 

Jeremy has a worked example using a FamilyInstance: http://thebuildingcoder.typepad.com/blog/2011/06/boolean-operations-and-instancevoidcututils.html

0 Likes
Message 3 of 4

Anonymous
Not applicable

Thank you for the reply!

 

But in the mentioned blog Jeremy wrote: "... the Revit API now provides several possibilities to perform Boolean operations in the project model: BooleanOperationsUtils, InstanceVoidCutUtils, SolidSolidCutUtils ..."

 

If I understand this correctly, I can use BooleanOperationsUtils, InstanceVoidCutUtils and SolidSolidCutUtils only on revit project files (.rvt), not for programmatical creation of revit family files. (.rfa)

 

But I want to create programmatically wall based window families with a non rectangular cut in the wall. (.rfa)

 

How can I do this?

0 Likes
Message 4 of 4

Anonymous
Not applicable
Accepted solution

Now I found a solution:

 

I do not use void extrusions because the boolean operations are not implemented for walls in family documents. Instead I use openings, which can be constructed of curve arrays.

0 Likes