Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi there!
- I have to use containsPoint(point) to check a point that constaint by a CurveLoop. I had debug and see that true but containsPoint method always return false. Can somebody help me.? this is my source and family I use to check.
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)] public class ExportGeometryInfoToCSV : Autodesk.Revit.UI.IExternalCommand { public object SiteEditingUtils { get; private set; } public Autodesk.Revit.UI.Result Execute( Autodesk.Revit.UI.ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uiDoc = uiapp.ActiveUIDocument; Document doc = uiDoc.Document; Selection choices = uiDoc.Selection; // Pick one object from Revit. Reference hasPickOne = choices.PickObject(ObjectType.Element); if (hasPickOne == null) { return Result.Succeeded; } Element element = uiDoc.Document.GetElement(hasPickOne); if (element is FamilyInstance) { double width = 0.0; double height = 0.0; ElementType type = doc.GetElement(element.GetTypeId()) as ElementType; Parameter paramWidth = type.LookupParameter("Width"); if (paramWidth != null) { width = paramWidth.AsDouble(); } Parameter paramHeight = type.LookupParameter("Height"); if (paramHeight != null) { height = paramHeight.AsDouble(); } FamilyInstance familyInstance = element as FamilyInstance; Family family = familyInstance.Symbol.Family; Document familyDoc = doc.EditFamily(family); if (null != familyDoc && familyDoc.IsFamilyDocument == true) { using (Transaction trans = new Transaction(familyDoc, "Add Type to Family")) { trans.Start(); FamilyManager familyManager = familyDoc.FamilyManager; string text = string.Empty; foreach (FamilyParameter familyParam in familyManager.Parameters) { text += familyParam.Definition.Name + "\n"; if (string.Compare(familyParam.Definition.Name, "Width") == 0) { familyManager.Set(familyParam, width); } if (string.Compare(familyParam.Definition.Name, "Height") == 0) { familyManager.Set(familyParam, height); } } trans.Commit(); } FilteredElementCollector collector = new FilteredElementCollector(familyDoc); ICollection<Element> collection = collector.OfClass(typeof(GenericForm)).ToElements(); StringBuilder csv = new StringBuilder(); foreach (Element elem in collection) { if (elem is Extrusion) { Extrusion extrusion = elem as Extrusion; if (extrusion.Name == "Void Extrusion") { continue; } Plane plan = extrusion.Sketch.SketchPlane.GetPlane(); CurveArrArray curveArrArray = extrusion.Sketch.Profile; try { FindBoun(curveArrArray, doc); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message + "\n" + ex.StackTrace.ToString()); return Result.Succeeded; } } } } } return Result.Succeeded; } bool FindBoun(CurveArrArray curveArrArray, Autodesk.Revit.DB.Document doc) { FilteredElementCollector collector = new FilteredElementCollector(doc); collector.OfClass(typeof(FamilySymbol)).OfCategory(BuiltInCategory.OST_Columns); List<XYZ> points = new List<XYZ>(); foreach (CurveArray curveArr in curveArrArray) { foreach (Curve curve in curveArr) { XYZ startpoint = curve.GetEndPoint(0); points.Add(startpoint); } } foreach (CurveArray curveArr in curveArrArray) { List<Curve> curves = new List<Curve>(); foreach (Curve curve in curveArr) { curves.Add(curve); } using (Transaction acTrans = new Transaction(doc, "TempSkecth")) { acTrans.Start(); TopographySurface topography = TopographySurface.Create(doc, points); CurveLoop curveLoop = CurveLoop.Create(curves); List<CurveLoop> curveLoops = new List<CurveLoop>(); curveLoops.Add(curveLoop); XYZ origin = new XYZ(0,0,0); SiteSubRegion region = SiteSubRegion.Create(doc, curveLoops, topography.Id); if (true == region.TopographySurface.ContainsPoint(origin)) { System.Windows.Forms.MessageBox.Show("in"); } else { System.Windows.Forms.MessageBox.Show("out"); } acTrans.Commit(); } } return true; } }
Solved! Go to Solution.