Message 1 of 4

Not applicable
06-01-2017
02:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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!!!
Solved! Go to Solution.