// TODO : Extraire ChangeBeamFamilyType method private void ChangeBeamFamilyType(string targetTypeSign, IList <Element> elemCol) { if (elemCol.Count != 0) { foreach (Element elem in elemCol) { FamilyInstance beam = elem as FamilyInstance; string beamSign, beamMat; double beamHeight, beamWidth; BeamFamily.GetBeamSymbolProperties(beam.Symbol, out beamSign, out beamMat, out beamHeight, out beamWidth); if (!beamSign.Equals(targetTypeSign)) { FamilySymbol beamType = _beamFamily.GetBeamFamilyTypeOrCreateNew( targetTypeSign, beamMat, beamHeight, beamWidth); Transaction t = new Transaction(_doc); t.Start("Change beam type"); beam.Symbol = beamType; t.Commit(); } else { continue; } } } }
// TODO : Extraire ChangeBeamFamilyType method private void ChangeBeamFamilyType(string targetTypeSign, IList <Reference> refIds) { foreach (Reference reference in refIds) { FamilyInstance beam = _doc.GetElement(reference) as FamilyInstance; string selectedBeamSign, selectedBeamMat; double selectedBeamHeight, selectedBeamWidth; BeamFamily.GetBeamSymbolProperties( beam.Symbol, out selectedBeamSign, out selectedBeamMat, out selectedBeamHeight, out selectedBeamWidth); if (!selectedBeamSign.Equals(targetTypeSign)) { BeamFamily beamFamily = new BeamFamily(_doc); FamilySymbol beamType = beamFamily.GetBeamFamilyTypeOrCreateNew( targetTypeSign, selectedBeamMat, selectedBeamHeight, selectedBeamWidth); Transaction t = new Transaction(_doc); t.Start("Change beam type"); beam.Symbol = beamType; t.Commit(); } else { continue; } } }
public void Execute(UIApplication app) { _uidoc = app.ActiveUIDocument; _doc = _uidoc.Document; _beamFamily = new BeamFamily(_doc); _beamFamily.AdjustWholeBeamFamilyTypeName(); ChangeBeamFamilyType(Properties.Settings.Default.BEAM_TYPE_SIGN_POU, BeamsToBeNormal); ChangeBeamFamilyType(Properties.Settings.Default.BEAM_TYPE_SIGN_LON, BeamsToBeGoundBeam); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { _uiapp = commandData.Application; _uidoc = _uiapp.ActiveUIDocument; _doc = _uidoc.Document; try { BeamFamily bf = new BeamFamily(_doc); bf.AdjustWholeBeamFamilyProperties(); return(Result.Succeeded); } catch (Autodesk.Revit.Exceptions.OperationCanceledException) { return(Result.Cancelled); } }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { _uiapp = commandData.Application; _uidoc = _uiapp.ActiveUIDocument; _doc = _uidoc.Document; // TODO : Extract GetAllStructuralLevels the methode _strLevels = (from l in new FilteredElementCollector(_doc) .OfClass(typeof(Level)) where l.GetEntitySchemaGuids().Count != 0 select l) .Cast <Level>() .OrderBy(l => l.Elevation) .ToList(); if (_strLevels.Count == 0) { TaskDialog.Show("Revit", "Configurer les niveaux structuraux avant de lancer cette commande."); return(Result.Cancelled); } BeamCreationForm form = new BeamCreationForm(); if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { _axeIsOnArchView = form.AxeIsOnArchView; } else { return(Result.Cancelled); } Transaction t = new Transaction(_doc); // Get all the model lines created by plugin IList <CurveElement> lines = (from line in new FilteredElementCollector(_doc) .OfClass(typeof(CurveElement)) .OfCategory(BuiltInCategory.OST_Lines) .Cast <CurveElement>() where (line as ModelLine) != null && line.GetEntitySchemaGuids().Count != 0 select line) .ToList(); BeamFamily beamFamily = new BeamFamily(_doc); t.Start("Create beams"); foreach (CurveElement line in lines) { ModelLine modelLine = line as ModelLine; bool modelLineOnLevel = GetLevel(modelLine, out Level level); GetParameterFromEntity( modelLine, out string beamSign, out double beamHeight, out double beamWidth, out ElementId beamId); if (!modelLineOnLevel) { continue; } if (LineHasRelativeBeam(modelLine, beamSign, beamHeight, beamWidth, beamId)) { continue; } // TODO : Material should be choosed when creat model line FamilySymbol beamType = beamFamily.GetBeamFamilyTypeOrCreateNew(beamSign, "Béton25", beamHeight, beamWidth); ElementId newBeamId = PlaceBeam(line, level, beamType); SetBeamIdToModelLine(newBeamId, modelLine).ToString(); } t.Commit(); return(Result.Succeeded); }