

Public bool OnFamilyFound(bool familyInUse, out bool overwriteParameterValues) Public class CustomFamilyLoadOption : IFamilyLoadOptions Return new FilteredElementCollector( doc ).OfClass( targetType ).FirstOrDefault(e => e.Name.Equals( targetName ) ) Static public Element FindElementByName(Document doc,Type targetType,string targetName) Using (Transaction trans = new Transaction(document))įamilyInstance gratingvoid = ( p, famsymb, lev, lev, StructuralType.NonStructural ) List fsym = new FilteredElementCollector(document).OfClass(typeof(FamilySymbol)).Cast().ToList() ICollection collection = collector1.WhereElementIsNotElementType().ToElements() TaskDialog.Show("Revit", "Family Does Not Exist") įilteredElementCollector collector1 = new FilteredElementCollector(document) TaskDialog.Show("Revit", "Could Not Write to Curve Array or Create Extrusion") ĭocfamily.LoadFamily(document, new CustomFamilyLoadOption()) įamily familynew = FindElementByName(document,typeof(Family),famname)as Family Level" ) as SketchPlane ĭocfamily.Famil圜reate.NewExtrusion(false, switcharr, sketch, end) SketchPlane sketch = FindElementByName( docfamily,typeof( SketchPlane ), "Ref. CurveArrArray newcurarr = new CurveArrArray() switcharr.Append(newcurarr.get_Item(1)) Below is edited for error control - leaving out the secondary loops for nowĬurveArrArray switcharr = new CurveArrArray() TaskDialog.Show("Revit CurveArray within Array Size", ca.Size.ToString()) TaskDialog.Show("Revit CurveArray Array Size", ()) If (loccurva.get_Item(0).GetType().ToString() = ".Arc")ĬurveArrArray newcurarr = new CurveArrArray() If (circleflag = true & loccurva.Size = 2) LocationCurve lcurve = mc.Location as LocationCurve Using (Transaction trans = new Transaction(docfamily))įilteredElementCollector collector = new FilteredElementCollector( docfamily ) įoreach(Element element in collector.OfClass(typeof(GenericForm))) List fsym0 = new FilteredElementCollector(document).OfClass(typeof(FamilySymbol)).Cast().ToList() ĭocfamily = "Could Not Save Void Family") While (counter collection0 = collector0.WhereElementIsNotElementType().ToElements() String sfinpath = fpath.Substring(0,finpathlen) TaskDialog.Show("debug", sb.ToString()) Sb.AppendLine(string.Format("", mc.Geometr圜urve.GetEndPoint(0), mc.Geometr圜urve.GetEndPoint(1))) TaskDialog.Show("Revit", "Circle Found") If (mc.GetType().ToString() = ".ModelArc" & mc.Geometr圜urve.IsBound = false) Sb.AppendLine(string.Format("", mc.Geometr圜())) Sb.AppendLine(string.Format("floor ", mc.GetType(), mc.Id))

ModelCurve mc = document.GetElement(id) as ModelCurve įoreach (Floor key in dict_SketchLines.Keys) _deleted = document.Delete(elem.Id).ToList() Using (Transaction t = new Transaction(document, "temp")) Reference refsel = (ObjectType.Element, "Select Floor to Add Grating To") Įlement elem = document.GetElement(refsel.ElementId) UIDocument uidoc = this.ActiveUIDocument Įlement levelem = document.GetElement( levelId ) This.Shutdown += new System.EventHandler(Module_Shutdown) ĭictionary> dict_SketchLines = new Dictionary>() This.Startup += new System.EventHandler(Module_Startup)

Private void Module_Shutdown(object sender, EventArgs e) Private void Module_Startup(object sender, EventArgs e) * To change this template use Tools | Options | Coding | Edit Standard Headers. The "If found" near the bottom last page and a half of code, is where the for loop is not behaving as expected.

It says the array elements are being changed but when the loop runs again the element i is back to it's original content? The TaskDialog clearly says the elements have changed, until the loop iterates again.įull code: To work it requires a generic family with the name "Void - Custom" to be in the project. In my template it cannot properly split the curves into a secondary array. It half works in my custom project template, when I try to use it in an out of the box project generated from revit default template it gives the error "a managed exception was thrown by revit or by one of its external applications"
#IMPORT REVIT TO SKETCHUP CODE#
Struggling with some Revit code to copy the profile of a floor and use it as the sketch profile for a void extrusion in a family.
