public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIDocument uidoc = commandData.Application.ActiveUIDocument; Document doc = uidoc.Document; if ((uidoc.ActiveView as View3D) == null) { message = "Por favor, rode este comando em uma vista 3d"; return(Result.Failed); } ISelectionFilter ridgeSelectionFilter = new RoofClasses.SelectionFilters.StraightLinesAndFacesRidgeSelectionFilter(doc); Reference currentReference = uidoc.Selection.PickObject(ObjectType.Edge, ridgeSelectionFilter); FootPrintRoof currentFootPrintRoof = doc.GetElement(currentReference) as FootPrintRoof; Edge edge = Support.GetEdgeFromReference(currentReference, currentFootPrintRoof); IList <PlanarFace> pfaces = new List <PlanarFace>(); Support.IsListOfPlanarFaces(HostObjectUtils.GetBottomFaces(currentFootPrintRoof) , currentFootPrintRoof, out pfaces); IList <RoofClasses.EdgeInfo> currentEdgeInfoList = Support.GetRoofEdgeInfoList(currentFootPrintRoof, false); Curve currentCurve = Support.GetMostSimilarCurve(edge.AsCurve(), currentEdgeInfoList); RoofClasses.EdgeInfo currentInfo = Support.GetCurveInformation(currentFootPrintRoof, currentCurve, pfaces); TaskDialog.Show("fac", currentInfo.RoofLineType.ToString()); Element tTypeElement = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Where(fsy => fsy is TrussType).ToList().FirstOrDefault(); if (tTypeElement == null) { message = "Nenhum tipo de treliça foi encontrada no projeto, por favor, carregue um tipo e rode este comando novamente"; return(Result.Failed); } TrussType tType = tTypeElement as TrussType; Managers.TrussRidgeManager currentTrussManager = new Managers.TrussRidgeManager(); IList <RoofClasses.TrussInfo> currentTrussInfoList = currentTrussManager.CreateTrussesFromRidgeInfo(currentInfo, tType); TaskDialog tDialog = new TaskDialog("Trusses"); tDialog.MainInstruction = currentTrussInfoList.Count.ToString(); tDialog.Show(); return(Result.Succeeded); }
static internal EdgeInfo GetMostSimilarEdgeInfo(Reference currentReference, Document targetDoc) { FootPrintRoof currentFootPrintRoof = targetDoc.GetElement(currentReference) as FootPrintRoof; Edge edge = Support.GetEdgeFromReference(currentReference, currentFootPrintRoof); IList <PlanarFace> pfaces = new List <PlanarFace>(); Support.IsListOfPlanarFaces(HostObjectUtils.GetBottomFaces(currentFootPrintRoof) , currentFootPrintRoof, out pfaces); IList <RoofClasses.EdgeInfo> currentEdgeInfoList = GetRoofEdgeInfoList(currentFootPrintRoof, false); Curve currentCurve = GetMostSimilarCurve(edge.AsCurve(), currentEdgeInfoList); RoofClasses.EdgeInfo currentRidgeInfo = GetCurveInformation(currentFootPrintRoof, currentCurve, pfaces); return(currentRidgeInfo); }