public void CreateSectionOfFamily() { UIDocument uidoc = this.ActiveUIDocument; Document doc = uidoc.Document; Selection sel = uidoc.Selection; ISelectionFilter f = new JtElementsOfClassSelectionFilter <FamilyInstance>(); Reference refer = sel.PickObject(ObjectType.Element, f, "Select the family instance"); FamilyInstance fi = doc.GetElement(refer) as FamilyInstance; ViewFamilyType vft = new FilteredElementCollector(doc) .OfClass(typeof(ViewFamilyType)) .Cast <ViewFamilyType>() .FirstOrDefault <ViewFamilyType>(x => ViewFamily.Section == x.ViewFamily); var loc = fi.Location as LocationPoint; var locPt = loc.Point; var bb = fi.get_BoundingBox(null); var height = bb.Max.Z; var width = bb.Max - bb.Min; var minPt = new XYZ(locPt.X, locPt.Y + width.Y, height); var message = locPt.ToString() + "\n" + bb.Max.ToString() + "\n" + bb.Min.ToString() + "\n" + width.ToString() + "\n" + minPt.ToString(); TaskDialog.Show("Title", message); }
public void CheckFamilyInstance() { UIDocument uidoc = this.ActiveUIDocument; Document doc = uidoc.Document; Selection sel = uidoc.Selection; ISelectionFilter f = new JtElementsOfClassSelectionFilter <FamilyInstance>(); Reference refe = sel.PickObject(ObjectType.Element, f, "Select an Family Instance"); FamilyInstance elem = doc.GetElement(refe) as FamilyInstance; Family fam = elem.Symbol.Family; if (fam.IsInPlace) { TaskDialog.Show("In Place Family or Not", "Its In place family"); } else { TaskDialog.Show("In Place Family or Not", "Its not In place family"); } }
public void ShrinkMultipleGrids() { UIDocument uidoc = this.ActiveUIDocument; Document doc = uidoc.Document; Selection sel = uidoc.Selection; View view = doc.ActiveView; var num = 3; #region Shrinking Grids using the Line - WIP // ISelectionFilter l = new JtElementsOfClassSelectionFilter<DetailCurve>(); // Reference lineRef = uidoc.Selection.PickObject(ObjectType.Element, l, "Pick the grid extent"); // LocationCurve crv = doc.GetElement(lineRef).Location as LocationCurve; // var cr = crv.Curve; #endregion // Get the Grids to extend from the project ISelectionFilter f = new JtElementsOfClassSelectionFilter <Grid>(); IList <Reference> picked = sel.PickObjects(ObjectType.Element, f, "Pick Grids"); foreach (var elemRef in picked) { Grid grid = doc.GetElement(elemRef) as Grid; IList <Curve> gridCurves = grid.GetCurvesInView(DatumExtentType.ViewSpecific, view); using (Transaction tx = new Transaction(doc)) { tx.Start("Modify the grids endpoints"); foreach (var c in gridCurves) { XYZ start = c.GetEndPoint(0); XYZ end = c.GetEndPoint(1); XYZ newStart = start.Add(num * XYZ.BasisX); XYZ newEnd = end.Subtract(num * XYZ.BasisX); Line newLine = Line.CreateBound(newStart, newEnd); grid.SetCurveInView(DatumExtentType.ViewSpecific, view, newLine); } tx.Commit(); } } TaskDialog.Show("Result", "The Grids are extended"); }
public void CreateInstancesOnHostFamilyFaces() { UIDocument uidoc = this.ActiveUIDocument; Document doc = uidoc.Document; Selection sel = uidoc.Selection; ISelectionFilter famFilter = new JtElementsOfClassSelectionFilter <FamilyInstance>(); ISelectionFilter elemFilter = new JtElementsOfClassSelectionFilter <Element>(); Reference famRefer = sel.PickObject(ObjectType.Element, famFilter, "Select the family instance"); Reference elemRefer = sel.PickObject(ObjectType.Element, elemFilter, "Select the Host element"); Element elem = doc.GetElement(elemRefer) as Element; FamilyInstance famInst = doc.GetElement(famRefer) as FamilyInstance; FamilySymbol famSym = famInst.Symbol; var faces = GetSolids(elem) .SelectMany(x => x.Faces.OfType <PlanarFace>()); using (var transaction = new Transaction(doc, "create families")) { transaction.Start(); if (!famSym.IsActive) { famSym.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, famSym); } transaction.Commit(); } }
public void resetParamValues() { UIDocument uidoc = this.ActiveUIDocument; Document doc = uidoc.Document; Selection sel = uidoc.Selection; var spacFilter = new JtElementsOfClassSelectionFilter <Space>(); Reference spaRefer = sel.PickObject(ObjectType.Element, spacFilter, "Select the space"); var elem = doc.GetElement(spaRefer) as Element; var parameter = elem.LookupParameter("SP_Space_Temperature"); var check = false; using (Transaction t = new Transaction(doc, "Clear the parameter Values")) { t.Start(); check = parameter.ClearValue(); t.Commit(); } TaskDialog.Show("The result", check.ToString() + " " + parameter.AsString()); }
public void ShrinkGrid() { UIDocument uidoc = this.ActiveUIDocument; Document doc = uidoc.Document; Selection sel = uidoc.Selection; View view = doc.ActiveView; var num = 2; ISelectionFilter f = new JtElementsOfClassSelectionFilter <Grid>(); Reference elemRef = uidoc.Selection.PickObject(ObjectType.Element, f, "Pick a Grid"); Grid grid = doc.GetElement(elemRef) as Grid; IList <Curve> gridCurves = grid.GetCurvesInView(DatumExtentType.ViewSpecific, view); using (Transaction tx = new Transaction(doc)) { tx.Start("Modify the grid start and end point"); foreach (var c in gridCurves) { XYZ start = c.GetEndPoint(0); XYZ end = c.GetEndPoint(1); XYZ newStart = start + num * XYZ.BasisX; XYZ newEnd = end - num * XYZ.BasisX; Line newLine = Line.CreateBound(newStart, newEnd); // XYZ crStart = cr.GetEndPoint(0); // XYZ crEnd = cr.GetEndPoint(1); // Line crLine = Line.CreateBound(crStart, crEnd); grid.SetCurveInView(DatumExtentType.ViewSpecific, view, newLine); } tx.Commit(); } TaskDialog.Show("Result", "The Grid is extended"); }