public void Execute(UpdaterData data) { Document doc = data.GetDocument(); List <ElementId> list = data.GetAddedElementIds().ToList(); list.AddRange(data.GetModifiedElementIds()); IList <Element> first = (from ElementId id in list select doc.GetElement(id)).ToList(); IList <FamilyInstance> projectZones = ZoneData.GetProjectZones(doc); IList <ElementId> list2 = (from Element pZ in projectZones select pZ.get_Id()).ToList(); Parameter val = (from FamilyInstance pZ in projectZones let param = pZ.LookupParameter("Name") where param != null select param).First(); Definition zoneNameDef = val.get_Definition(); foreach (Element item in first.Except((IEnumerable <Element>)projectZones)) { BoundingBoxXYZ val2 = item.get_BoundingBox(null); if (val2 != null) { BoundingBoxIntersectsFilter val3 = new BoundingBoxIntersectsFilter(ToOutline(val2)); IList <Element> source = new FilteredElementCollector(doc, (ICollection <ElementId>)list2).WherePasses(val3).ToElements(); IEnumerable <string> values = from Element zone in source let name = zone.get_Parameter(zoneNameDef).AsString() where !string.IsNullOrWhiteSpace(name) select name; string text = string.Join(", ", values); item.LookupParameter("Zone").Set(text); } } }
public void Execute(UpdaterData data) { processUpdates( data.GetModifiedElementIds(), data.GetDeletedElementIds(), data.GetAddedElementIds()); }
/// <summary> /// 采用 Extensible Storage /// </summary> /// <param name="updateData"></param> public void Execute(UpdaterData updateData) { var doc = updateData.GetDocument(); var adds = updateData.GetAddedElementIds(); var edits = updateData.GetModifiedElementIds(); var deletes = updateData.GetDeletedElementIds(); var collection = MyTestContext.GetCollection(doc); if (deletes.Count == 0) { return; } foreach (var deleteId in deletes) { var entity = collection.FirstOrDefault(c => c.TagId == deleteId.IntegerValue); if (entity != null) { var line = doc.GetElement(new ElementId(entity.LineId)); if (line != null) { doc.Delete(line.Id); } collection.Remove(entity); } //var element = doc.GetElement(deleteId); //SchemaEntityOpr opr = new SchemaEntityOpr(element); //string relatedLineField = BeamAnnotationConstaints.relatedLineField; //var relatedLineId = opr.GetParm(relatedLineField); //var line = doc.GetElement(new ElementId(int.Parse(relatedLineId))) as DetailLine; //if (line != null) // doc.Delete(line.Id); } }
public void Execute(UpdaterData data) { if (data == null) { throw new ArgumentNullException(nameof(data)); } Document document = data.GetDocument(); if (!registered) { registered = true; _pilingCoordinator.RegisterDocument(document); } List <ElementId> modifiedElementIds = new List <ElementId>(); modifiedElementIds.AddRange(data.GetAddedElementIds()); modifiedElementIds.AddRange(data.GetModifiedElementIds()); foreach (ElementId id in modifiedElementIds) { _pilingCoordinator.UpdateElement(document, id); } }
public void Execute(UpdaterData data) { Document doc = data.GetDocument(); if (doc.IsFamilyDocument) { try { //Get document Name string name = doc.Title; if (String.IsNullOrEmpty(name)) { name = "null"; } //Get form location info (Varies by type?) foreach (ElementId e in data.GetModifiedElementIds().Concat(data.GetAddedElementIds())) { CurveElement ele = doc.GetElement(e) as CurveElement; var bbox = ele.get_BoundingBox(null); if (bbox != null) { var dims = GetDims(bbox); int prediction = Datatype.ObjectStyle.PredictSingle(name, "line", dims); var subcat = doc.AddCategories(prediction); ele.LineStyle = subcat.GetGraphicsStyle(GraphicsStyleType.Projection); } } } catch (Exception e) { e.OutputError(); } } }
public void Execute(UpdaterData data) { Document doc = data.GetDocument(); if (!doc.IsFamilyDocument) { var Eles = data.GetModifiedElementIds().ToList(); foreach (var eid in Eles) { var ele = doc.GetElement(eid) as FamilySymbol; if (ele != null) { string name = ""; int MF = 0; try { name = ele.FamilyName; } catch (Exception e) { e.OutputError(); } if (name != "") { try { var output = MasterformatNetwork.Predict(name, new WriteToCMDLine(CMDLibrary.WriteNull)); MF = output.ToList().IndexOf(output.Max()); } catch (Exception e) { e.OutputError(); } } try { ele.Set(Params.Masterformat, MF.ToString()); } catch (Exception e) { e.OutputError(); } } } } }
public void Execute(UpdaterData data) { List <ElementId> eids = data.GetModifiedElementIds().ToList(); Document doc = data.GetDocument(); foreach (ElementId eid in eids) { Element ele = doc.GetElement(eid); Room r = ele as Room; if (r != null) { /* * Parameter p = r.get_Parameter(BuiltInParameter.ROOM_NAME); * string s = p.AsString(); * //var OLF = s.PredictOLF(); * double lf = double.Parse(OLF); * double Area = r.get_Parameter(BuiltInParameter.ROOM_AREA).AsDouble(); * int load = 0; * if(lf > 0) * load = (int)Math.Ceiling(Area / lf); * TaskDialog.Show("Load Factor Change", "The New Load Factor for " + s + " is " + OLF + "\r\n" + "The new Occupany Load is " + load); + ele.SetElementParam(CCParameter.OccupantLoadFactor, OLF); + ele.SetElementParam(CCParameter.OccupantLoad, load.ToString()); */ } else { TaskDialog.Show("Error", "The room was null"); } } }
public void Execute(UpdaterData data) { Document doc = data.GetDocument(); // Cache the wall type if (m_wallType == null) { FilteredElementCollector collector = new FilteredElementCollector(doc); collector.OfClass(typeof(WallType)); var wallTypes = from element in collector where element.Name == "Exterior - Brick on CMU" select element; if (wallTypes.Count <Element>() > 0) { m_wallType = wallTypes.Cast <WallType>().ElementAt <WallType>(0); } } if (m_wallType != null) { // Change the wall to the cached wall type. foreach (ElementId addedElemId in data.GetAddedElementIds()) { Wall wall = doc.GetElement(addedElemId) as Wall; if (wall != null) { wall.WallType = m_wallType; } } } }
public void Execute(UpdaterData data) { try { Document doc = data.GetDocument(); if (doc.IsFamilyDocument) { var modrps = data.GetModifiedElementIds(); var addrps = data.GetAddedElementIds(); List <ElementId> rps = modrps.ToList(); rps.AddRange(addrps.ToList()); foreach (ElementId eid in rps) { ReferencePlane rp = doc.GetElement(eid) as ReferencePlane; if (rp.ParametersMap.get_Item("Is Reference").AsInteger() == 14) { rp.ParametersMap.get_Item("Is Reference").Set(12); } } } } catch (Exception ex) { ex.OutputError(); } }
// Execution method for the updater public void Execute(UpdaterData data) { // Remove old idling event callback UIApplication uiApp = new UIApplication(data.GetDocument().Application); uiApp.Idling -= containerOld.UpdateWhileIdling; containerOld.Stop(); // Clear the current AVF results Document doc = data.GetDocument(); View activeView = doc.GetElement(s_activeViewId) as View; SpatialFieldManager sfm = SpatialFieldManager.GetSpatialFieldManager(activeView); sfm.Clear(); // Restart the multithread calculation with a new container Element modifiedElem = doc.GetElement(data.GetModifiedElementIds().First <ElementId>()); MultithreadedCalculationContainer container = MultithreadedCalculation.CreateContainer(modifiedElem); containerOld = container; // Setup the new idling callback uiApp.Idling += new EventHandler <IdlingEventArgs>(container.UpdateWhileIdling); // Start the thread Thread threadNew = new Thread(new ThreadStart(container.Run)); threadNew.Start(); }
/// <inheritdoc /> public void Execute(UpdaterData data) { var doc = data.GetDocument(); // ReSharper disable once UseNullPropagation if (doc == null) { return; } if (doc.ActiveView == null) { return; } if (doc.IsFamilyDocument) { return; } foreach (var elementId in data.GetModifiedElementIds()) { if (doc.GetElement(elementId) is FamilyInstance familyInstance && familyInstance.Category.Id.IntegerValue == (int)BuiltInCategory.OST_StructuralFraming) { try { var parameter = familyInstance.get_Parameter(BuiltInParameter.STRUCTURAL_COPING_DISTANCE); parameter?.Set(CopingDistanceCommand.DistanceInMm.MmToFt()); } catch (Exception exception) { ExceptionBox.Show(exception); } } } }
public override void InnerExecute(UpdaterData data) { var modified = data.GetModifiedElementIds(); var added = data.GetAddedElementIds(); var deleted = data.GetDeletedElementIds(); foreach (ElementId id in modified.Concat(added)) { try { Element el = Document.GetElement(id); if (el is Room) { FinishingData.Calculate(el as Room); FinishingData.AggregateFloors(el); } else { if (el != null) { List <Room> rooms = FinishingData.GetCollidedRooms(el); foreach (Room r in rooms) { FinishingData.Calculate(r); } } else { foreach (Room r in new FilteredElementCollector(Document, Document.ActiveView.Id).OfCategory(BuiltInCategory.OST_Rooms).Cast <Room>()) { FinishingData.Calculate(r); } } } } catch (Exception ex) { Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); Debug.WriteLine("Addition/Modification error: id " + id.IntegerValue.ToString()); } } if (deleted.Count > 0) { try { foreach (Room r in new FilteredElementCollector(Document, Document.ActiveView.Id).OfCategory(BuiltInCategory.OST_Rooms).Cast <Room>()) { FinishingData.Calculate(r); } } catch (Exception ex) { Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); Debug.WriteLine("Deletion error"); } } }
public void Execute(UpdaterData updateData) { var document = updateData.GetDocument(); var edits = updateData.GetModifiedElementIds(); var storageEntity = new TestStorageEntity(); ExtensibleStorageHelperV2.SetData(document, storageEntity, storageEntity.FieldStr, "111"); }
public void Execute(UpdaterData data) { try { Document doc = data.GetDocument(); string centralPath = FileInfoUtil.GetCentralFilePath(doc); string configId = ""; if (AppCommand.Instance.ConfigDictionary.ContainsKey(centralPath)) { configId = AppCommand.Instance.ConfigDictionary[centralPath]._id; } List <ElementId> addedElementIds = data.GetAddedElementIds().ToList(); foreach (ElementId id in addedElementIds) { Element element = doc.GetElement(id); if (null != element) { BuiltInCategory bltCategory = (BuiltInCategory)element.Category.Id.IntegerValue; if (bltCategory == BuiltInCategory.OST_RvtLinks) { RunCategoryActionItems(centralPath, data, element); } else { AddCategoryCache(configId, centralPath, element); } } } List <ElementId> modifiedElementIds = data.GetModifiedElementIds().ToList(); foreach (ElementId id in modifiedElementIds) { Element element = doc.GetElement(id); if (null != element) { RunCategoryActionItems(centralPath, data, element); } } List <ElementId> deletedElementIds = data.GetDeletedElementIds().ToList(); foreach (ElementId id in deletedElementIds) { //Process Failure var infoFound = from info in reportingElements where info.CentralPath == centralPath && info.ReportingElementId == id select info; if (infoFound.Count() > 0) { ReportFailure(doc, infoFound.First()); } } } catch (Exception ex) { string message = ex.Message; LogUtil.AppendLog("DTMUpdater-Execute:" + ex.Message); } }
/// <summary> /// Implements IUpdater.Execute() /// </summary> /// <param name="data"></param> public void Execute(UpdaterData data) { // Only previously formatted schedules should trigger - so just reformat them foreach (ElementId scheduleId in data.GetModifiedElementIds()) { ViewSchedule schedule = data.GetDocument().GetElement(scheduleId) as ViewSchedule; FormatScheduleColumns(schedule); } }
public override void Execute(UpdaterData data) { var modded = data.GetModifiedElementIds(); if (modded.Any()) { OnUpdated(new UpdaterArgs(new List <ElementId>(), modded, new List <ElementId>())); } }
public void Execute(UpdaterData data) { Func <ICollection <ElementId>, string> toString = ids => ids.Aggregate("", (ss, id) => ss + "," + id).TrimStart(','); var sb = new StringBuilder(); sb.AppendLine("added:" + toString(data.GetAddedElementIds())); sb.AppendLine("modified:" + toString(data.GetModifiedElementIds())); sb.AppendLine("deleted:" + toString(data.GetDeletedElementIds())); TaskDialog.Show("Changes", sb.ToString()); }
public void Execute(UpdaterData data) { try { } catch (Exception ex) { string message = ex.Message; } }
private string GetArgumentsFromJsonFile(string path) { if (string.IsNullOrEmpty(path)) { return(""); } var updaterParams = UpdaterData.ReadFromFile(path); return(updaterParams.GetPasswordBossUpdater().silent); }
public override void InnerExecute(UpdaterData data) { var modified = data.GetModifiedElementIds(); var added = data.GetAddedElementIds(); foreach (ElementId id in modified.Concat(added)) { UpdateMark(id); } }
public Resolvers(UpdaterData data) { All = new IModResolver[] { // Listed in order of preference. new NugetRepositoryResolver(data), new GitHubLatestUpdateResolver(), new GameBananaUpdateResolver() }; }
public void Execute(UpdaterData data) { //Toggle check if (m_updateActive == false) { return; } Document doc = data.GetDocument(); //Check schema by getting the titleblock family symbol SchemaAndStoreData schema = new SchemaAndStoreData(); Titleblock titleblock = new Titleblock(); titleblock.getTitleblockCurrentView(doc); titleblock.TitleblockFamilySymbolList(doc); titleblock.getTitleblockName(); string test = titleblock.getSheetName(); FamilySymbol familySymbol = titleblock.getFamilySymbol(titleblock.getSheetName()); if (schema.StorageExists(familySymbol) == true) { var modifiedIds = data.GetModifiedElementIds(); foreach (var id in modifiedIds) { // gets modifed element in project Element modifiedId = doc.GetElement(id); if (modifiedId.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Viewports) { Viewport modifiedView = (Viewport)modifiedId; string selectedview = null; string selectedNumber = null; string selectedSheetNumber = null; ViewLocation viewLocation = new ViewLocation(); selectedview = modifiedView.get_Parameter(BuiltInParameter.VIEW_NAME).AsString(); selectedNumber = modifiedView.get_Parameter(BuiltInParameter.VIEWPORT_DETAIL_NUMBER).AsString(); selectedSheetNumber = modifiedView.get_Parameter(BuiltInParameter.VIEWPORT_SHEET_NUMBER).AsString(); try { if (selectedview != null && selectedNumber != null) { viewLocation.getViewCoord(doc, selectedview); viewLocation.setCoordinate(doc, selectedview, selectedNumber, selectedSheetNumber); // TODO add auto trigger for title. Not avaiable in API } } catch { } } } } }
public void Execute(UpdaterData data) { List <ElementId> eids = data.GetModifiedElementIds().ToList(); Document doc = data.GetDocument(); foreach (ElementId eid in eids) { Element ele = doc.GetElement(eid) as Material; var cat = ele.GetElementParam(MaterialParams.Category); if (string.IsNullOrEmpty(cat) || string.IsNullOrWhiteSpace(cat)) { cat = "null"; } var mdl = ele.GetElementParam(MaterialParams.Model); if (string.IsNullOrEmpty(mdl) || string.IsNullOrWhiteSpace(mdl)) { mdl = "null"; } var mfr = ele.GetElementParam(MaterialParams.Manufacturer); if (string.IsNullOrEmpty(mfr) || string.IsNullOrWhiteSpace(mfr)) { mfr = "null"; } var ptn = ele.GetElementParam(MaterialParams.PatternStyle); if (string.IsNullOrEmpty(ptn) || string.IsNullOrWhiteSpace(ptn)) { ptn = "null"; } var clr = ele.GetElementParam(MaterialParams.ColorFinish); if (string.IsNullOrEmpty(clr) || string.IsNullOrWhiteSpace(clr)) { clr = "null"; } var dsc = ele.GetElementParam(MaterialParams.MatDescription); if (string.IsNullOrEmpty(dsc) || string.IsNullOrWhiteSpace(dsc)) { dsc = "null"; } var prj = doc.ProjectInformation.Number; if (string.IsNullOrEmpty(prj) || string.IsNullOrWhiteSpace(prj)) { prj = "null"; } CCMaterial mat = CCMaterial.Get(cat, mdl); mat.Manufacturer = mfr; mat.Color = clr; mat.Description = dsc; mat.AddPattern(ptn); mat.AddProject(prj); mat.Save(); } }
public override void InnerExecute(UpdaterData data) { var modified = data.GetModifiedElementIds(); var added = data.GetAddedElementIds(); var elements = added.Concat(modified).Select(x => doc.GetElement(x)); foreach (Element e in elements) { SpaceNaming.TransferData(e); } }
private void RunCategoryActionItems(string centralPath, UpdaterData data, Element element) { try { ReportingElementInfo reportingInfo = null; Document doc = data.GetDocument(); var infoFound = from info in reportingElements where info.CentralPath == centralPath && info.ReportingUniqueId == element.UniqueId select info; if (infoFound.Count() > 0) { reportingInfo = infoFound.First(); } BuiltInCategory bltCategory = (BuiltInCategory)element.Category.Id.IntegerValue; switch (bltCategory) { case BuiltInCategory.OST_Grids: Grid grid = element as Grid; if (GridUtils.ExtentGeometryChanged(centralPath, grid.Id, grid.GetExtents())) { if (null != reportingInfo) { ReportFailure(doc, reportingInfo); } } else if (GridUtils.gridParameters.ContainsKey(centralPath)) { //parameter changed foreach (ElementId paramId in GridUtils.gridParameters[centralPath]) { if (data.IsChangeTriggered(grid.Id, Element.GetChangeTypeParameter(paramId))) { if (null != reportingInfo) { ReportFailure(doc, reportingInfo); } } } } break; default: if (null != reportingInfo) { ReportFailure(doc, reportingInfo); } break; } } catch (Exception ex) { string message = ex.Message; LogUtil.AppendLog("DTMUpdater-RunCategoryActionItems:" + ex.Message); } }
public override void InnerExecute(UpdaterData data) { var modified = data.GetModifiedElementIds(); var added = data.GetAddedElementIds(); var elements = added.Concat(modified).Select(x => Document.GetElement(x)); foreach (Element e in elements) { Room2SpaceData(e); } }
public void Execute( UpdaterData data ) { // we need to modify something here, or the // updater requirement will not be saved in // the document. Document doc = data.GetDocument(); //Transaction t = new Transaction( doc, // "Dummy Updater Transaction" ); //t.Start(); //t.Commit(); //if( 0 < data.GetModifiedElementIds().Count ) //{ // foreach( ElementId id in data.GetModifiedElementIds() ) // { // Element e = doc.get_Element( id ); // Parameter p = e.get_Parameter( BuiltInParameter.ALL_MODEL_MARK ); // string s = p.AsString(); // p.Set( s + " modified by " + ToString() ); // } //} ProjectInfo a = new FilteredElementCollector( doc ) .OfClass( typeof( ProjectInfo ) ) .FirstElement() as ProjectInfo; try { Parameter p = a.get_Parameter(BuiltInParameter.PROJECT_STATUS); string s = p.AsString(); if (s == null) s = string.Empty; if (0 < s.Length) { s += " "; } p.Set(s + "modified by " + ToString()); Debug.Print("DummyUpdater.Execute: " + GetUpdaterName() + " " + GetUpdaterId()); } catch (Exception ex) { var td = new TaskDialog("Error"); td.MainInstruction = ex.Message; td.ExpandedContent = ex.ToString(); td.Show(); } }
public virtual void Execute(UpdaterData data) { var added = data.GetAddedElementIds(); var modded = data.GetModifiedElementIds(); var deleted = data.GetDeletedElementIds(); if (added.Any() || modded.Any() || deleted.Any()) { OnUpdated(new UpdaterArgs(added, modded, deleted)); } }
public void Execute(UpdaterData data) { var doc = data.GetDocument(); var elementIds = new List<ElementId>(); elementIds.AddRange(data.GetAddedElementIds()); elementIds.AddRange(data.GetModifiedElementIds()); Settings.GetCO2eCalculator().UpdateElementCO2eParameters( elementIds.Select(doc.get_Element).ToList()); }
public void Execute(UpdaterData data) { Deleteds = new List <ElementId>(); var ids3 = data.GetDeletedElementIds(); var doc = data.GetDocument(); Deleteds.AddRange(ids3); }
public void Execute(UpdaterData data) { Autodesk.Revit.DB.CodeChecking.Storage.StorageService service = Autodesk.Revit.DB.CodeChecking.Storage.StorageService.GetStorageService(); Autodesk.Revit.DB.CodeChecking.Storage.StorageDocument storageDocument = service.GetStorageDocument(data.GetDocument()); foreach (ElementId elId in data.GetModifiedElementIds()) { Element el = data.GetDocument().GetElement(elId); storageDocument.ResultsManager.OutDateResults(Server.Server.ID, el); } }
public void Execute(UpdaterData updateData) { var document = updateData.GetDocument(); var edits = updateData.GetModifiedElementIds(); var storageEntity = new TestStorageEntity(); var lineCollector = new FilteredElementCollector(document).OfCategory(BuiltInCategory.OST_Lines).WhereElementIsNotElementType(); foreach (var line in lineCollector) { ElementTransformUtils.MoveElement(document, line.Id, new XYZ(10, 20, 0)); } }
public void Execute(UpdaterData data) { try { if (IsSheetManagerOn) { return; } if (SheetDataWriter.dbFile != configuration.DatabaseFile) { SheetDataWriter.OpenDatabase(configuration.DatabaseFile); } Document doc = data.GetDocument(); foreach (ElementId sheetId in data.GetAddedElementIds()) { ViewSheet viewSheet = doc.GetElement(sheetId) as ViewSheet; if (null != viewSheet) { bool inserted = InsertSheet(viewSheet); } } foreach (ElementId sheetId in data.GetModifiedElementIds()) { ViewSheet viewSheet = doc.GetElement(sheetId) as ViewSheet; if (null != viewSheet) { List <ElementId> parameterChanged = new List <ElementId>(); foreach (ElementId paramId in sheetParameters.Keys) { if (data.IsChangeTriggered(sheetId, Element.GetChangeTypeParameter(paramId))) { parameterChanged.Add(paramId); } } bool updated = UpdateSheet(viewSheet, parameterChanged); } } foreach (ElementId sheetId in data.GetDeletedElementIds()) { //bool deleted = DeleteSheet(sheetId); } } catch (Exception ex) { string message = ex.Message; } }
public void Execute(UpdaterData data) { Document doc = data.GetDocument(); Application app = doc.Application; foreach (ElementId id in data.GetDeletedElementIds()) { if (Command.IsProtected(id)) { FailureMessage failureMessage = new FailureMessage(_failureId); failureMessage.SetFailingElement(id); doc.PostFailure(failureMessage); } } }
public void Execute(UpdaterData data) { Document doc = data.GetDocument(); Application app = doc.Application; foreach (ElementId id in data.GetAddedElementIds()) { View view = doc.GetElement(id) as View; if (null != view && ViewType.Elevation == view.ViewType) { TaskDialog.Show("ElevationWatcher Updater", string.Format("Новый фасад'{0}'", view.Name)); } } }
public void Execute(UpdaterData data) { foreach (var elementId in data.GetModifiedElementIds()) { var document = data.GetDocument(); var sheetNote = DocumentAccess.GetNoteFromElement(document, elementId, _familyName); if (null == sheetNote) continue; if (sheetNote.Series == "" || sheetNote.Number == "" || sheetNote.Text == "") continue; try { Application.ThisApp.GetSheetNoteModel().DynamicUpdate(sheetNote); DocumentAccess.UpdateIdsInStorage(document, elementId, sheetNote); } catch (Exception e) { TaskDialog.Show("Error", e.Message); } } }
public void Execute(UpdaterData data) { foreach (var elementId in data.GetAddedElementIds()) { var document = data.GetDocument(); var sheetNote = DocumentAccess.GetNoteFromElement(document, elementId, _familyName); if (null == sheetNote) continue; if (sheetNote.Series == "" || sheetNote.Number == "" || sheetNote.Text == "") { sheetNote = DropHandlerSheetNote.SheetNote; if (null == sheetNote) continue; try { DocumentAccess.SetNoteInElement(document, elementId, sheetNote); } catch (Exception e) { TaskDialog.Show("Error", e.Message); } DropHandlerSheetNote.SheetNote = null; } try { DocumentAccess.UpdateIdsInStorage(document, elementId, sheetNote); } catch (Exception e) { TaskDialog.Show("Error", e.Message); } } }
public override void Execute(UpdaterData data) { var modded = data.GetModifiedElementIds(); if (modded.Any()) { OnUpdated(new UpdaterArgs(new List<ElementId>(), modded, new List<ElementId>())); } }
// Execution method for the updater public void Execute(UpdaterData data) { // Remove old idling event callback UIApplication uiApp = new UIApplication(data.GetDocument().Application); uiApp.Idling -= containerOld.UpdateWhileIdling; containerOld.Stop(); // Clear the current AVF results Document doc = data.GetDocument(); View activeView = doc.get_Element(s_activeViewId) as View; SpatialFieldManager sfm = SpatialFieldManager.GetSpatialFieldManager(activeView); sfm.Clear(); // Restart the multithread calculation with a new container Element modifiedElem = doc.get_Element(data.GetModifiedElementIds().First<ElementId>()); MultithreadedCalculationContainer container = MultithreadedCalculation.CreateContainer(modifiedElem); containerOld = container; // Setup the new idling callback uiApp.Idling += new EventHandler<IdlingEventArgs>(container.UpdateWhileIdling); // Start the thread Thread threadNew = new Thread(new ThreadStart(container.Run)); threadNew.Start(); }
/// <summary> /// This is the main function to do the actual job. /// For this exercise, we assume that we want to keep the door and window always at the center. /// </summary> public void Execute(UpdaterData data) { if (!m_updateActive) return; Document rvtDoc = data.GetDocument(); ICollection<ElementId> idsModified = data.GetModifiedElementIds(); foreach (ElementId id in idsModified) { // Wall aWall = rvtDoc.get_Element(id) as Wall; // For 2012 Wall aWall = rvtDoc.GetElement(id) as Wall; // For 2013 CenterWindowDoor(rvtDoc, aWall); } }
public void Execute(UpdaterData data) { Document doc = data.GetDocument(); Autodesk.Revit.ApplicationServices.Application app = doc.Application; View view = doc.get_Element(viewID) as View; FamilyInstance sphere = doc.get_Element(sphereID) as FamilyInstance; LocationPoint sphereLP = sphere.Location as LocationPoint; XYZ sphereXYZ = sphereLP.Point; SpatialFieldManager sfm = SpatialFieldManager.GetSpatialFieldManager(view); if (sfm == null) sfm = SpatialFieldManager.CreateSpatialFieldManager(view, 3); // Three measurement values for each point sfm.Clear(); FilteredElementCollector collector = new FilteredElementCollector(doc,view.Id); ElementCategoryFilter wallFilter = new ElementCategoryFilter(BuiltInCategory.OST_Walls); ElementCategoryFilter massFilter = new ElementCategoryFilter(BuiltInCategory.OST_Mass); LogicalOrFilter filter = new LogicalOrFilter(wallFilter, massFilter); ICollection<Element> elements = collector.WherePasses(filter).WhereElementIsNotElementType().ToElements(); foreach (Face face in GetFaces(elements)) { int idx = sfm.AddSpatialFieldPrimitive(face.Reference); List<double> doubleList = new List<double>(); IList<UV> uvPts = new List<UV>(); IList<ValueAtPoint> valList = new List<ValueAtPoint>(); BoundingBoxUV bb = face.GetBoundingBox(); for (double u = bb.Min.U; u < bb.Max.U; u = u + (bb.Max.U - bb.Min.U) / 15) { for (double v = bb.Min.V; v < bb.Max.V; v = v + (bb.Max.V - bb.Min.V) / 15) { UV uvPnt = new UV(u, v); uvPts.Add(uvPnt); XYZ faceXYZ = face.Evaluate(uvPnt); // Specify three values for each point doubleList.Add(faceXYZ.DistanceTo(sphereXYZ)); doubleList.Add(-faceXYZ.DistanceTo(sphereXYZ)); doubleList.Add(faceXYZ.DistanceTo(sphereXYZ) * 10); valList.Add(new ValueAtPoint(doubleList)); doubleList.Clear(); } } FieldDomainPointsByUV pnts = new FieldDomainPointsByUV(uvPts); FieldValues vals = new FieldValues(valList); AnalysisResultSchema resultSchema1 = new AnalysisResultSchema("Schema 1", "Schema 1 Description"); IList<int> registeredResults = new List<int>(); registeredResults = sfm.GetRegisteredResults(); int idx1 = 0; if (registeredResults.Count == 0) { idx1 = sfm.RegisterResult(resultSchema1); } else { idx1 = registeredResults.First(); } sfm.UpdateSpatialFieldPrimitive(idx, pnts, vals, idx1); } }
public void Execute(UpdaterData data) { Document doc = data.GetDocument(); //sync the modified elements foreach (ElementId ElemId in data.GetModifiedElementIds()) { SyncPhaseGraphics(doc, ElemId); } //sync the added elements foreach (ElementId ElemId in data.GetAddedElementIds()) { SyncPhaseGraphics(doc, ElemId); } }
public void Execute(UpdaterData data) { Document doc = data.GetDocument(); Autodesk.Revit.DB.View view = doc.ActiveView; SpatialFieldManager sfm = SpatialFieldManager.GetSpatialFieldManager(view); UpdaterData tempData = data; if (sfm != null) { // Cache the spatial field manager if ther is one if (m_sfm == null) { //FilteredElementCollector collector = new FilteredElementCollector(doc); //collector.OfClass(typeof(SpatialFieldManager)); //var sfm = from element in collector // select element; //if (sfm.Count<Element>() > 0) // if we actually found an SFM //{ //m_sfm = sfm.Cast<SpatialFieldManager>().ElementAt<SpatialFieldManager>(0); m_sfm = sfm; //TaskDialog.Show("ah hah", "found spatial field manager adding to cache"); //} } if (m_sfm != null) { // if we find an sfm has been updated and it matches what already have one cached, send it to dyanmo //foreach (ElementId addedElemId in data.GetAddedElementIds()) //{ //SpatialFieldManager sfm = doc.get_Element(addedElemId) as SpatialFieldManager; //if (sfm != null) //{ // TaskDialog.Show("ah hah", "found spatial field manager yet, passing to dynamo"); dynElementSettings.SharedInstance.SpatialFieldManagerUpdated = sfm; //Dynamo.Elements.OnDynElementReadyToBuild(EventArgs.Empty);//kick it //} //} } } else { //TaskDialog.Show("ah hah", "no spatial field manager yet, please run sr tool"); } }
public void Execute(UpdaterData data) { if (m_updateActive == false) { return; } Document doc = data.GetDocument(); var modifiedIds = data.GetModifiedElementIds(); var addedIds = data.GetAddedElementIds(); //viewport added to sheet foreach (var id in addedIds) { Element addedElem = doc.GetElement(id); //When a view is added to a sheet the title on sheet will be renamed and the view name will be added if (addedElem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Viewports) { Viewport addedView = (Viewport)addedElem; string sheetNumber = addedView.get_Parameter(BuiltInParameter.VIEWPORT_SHEET_NUMBER).AsString(); string TitleOnSheet = addedView.get_Parameter(BuiltInParameter.VIEW_DESCRIPTION).AsString(); string detailNumber = addedView.get_Parameter(BuiltInParameter.VIEWPORT_DETAIL_NUMBER).AsString(); //Stops when Imported Sheets int x = addedView.SheetId.IntegerValue; if (x == -1) { break; } //Skips when Legends are added to a sheet if (detailNumber == "") { break; } //copy the view name to title on sheet if its empty if (TitleOnSheet == "") { setRename.SetViewportTileOnSheet(addedView); } //rename the view name setRename.SetViewportName(addedView, sheetNumber); } } //When a sheet number is changed all viewports will be renamed foreach (var id in modifiedIds) { Element modifedElem = doc.GetElement(id); Element addedElem = doc.GetElement(id); if (modifedElem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Sheets) { foreach (var ids in modifiedIds) { ViewSheet modifiedViewSheet = (ViewSheet)modifedElem; List<View> viewToSet = new List<View>(); foreach (View v in modifiedViewSheet.Views) { //skip legends var viewType = v.ViewType.ToString(); if (viewType == "Legend") { continue; } //Set every view in sheet to new sheet number viewToSet.Add(v); } foreach (View v in viewToSet) { setRename.SetViewNameOnSheet(v, modifiedViewSheet); } } } if (modifedElem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Viewports) { Viewport modifiedViewport = (Viewport)modifedElem; string sheetNumber = modifiedViewport.get_Parameter(BuiltInParameter.VIEWPORT_SHEET_NUMBER).AsString(); setRename.SetViewportName(modifiedViewport, sheetNumber); } if (modifedElem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Views) { View modifiedView = (View)modifedElem; if (modifiedView.IsTemplate) return; string sheetNumber = modifiedView.get_Parameter(BuiltInParameter.VIEWPORT_SHEET_NUMBER).AsString(); setRename.SetViewName(modifiedView, sheetNumber); } } }
// The Execute method for the updater public void Execute(UpdaterData data) { try { Document doc = data.GetDocument(); FamilyInstance window = doc.get_Element(m_windowId) as FamilyInstance; Element section = doc.get_Element(m_sectionId); // iterate through modified elements to find the one we want the section to follow foreach (ElementId id in data.GetModifiedElementIds()) { if (id == m_windowId) { //Let's take this out temporarily. bool enableLookup = false; if (enableLookup) m_schema = Schema.Lookup(m_schemaId); // (new Guid("{4DE4BE80-0857-4785-A7DF-8A8918851CB2}")); Entity storedEntity = null; storedEntity = window.GetEntity(m_schema); // // first we look-up X-Y-Z parameters, which we know are set on our windows // and the values are set to the current coordinates of the window instance Field fieldPosition = m_schema.GetField("Position"); XYZ oldPosition = storedEntity.Get<XYZ>(fieldPosition, DisplayUnitType.DUT_FEET_FRACTIONAL_INCHES); TaskDialog.Show("Old position", oldPosition.ToString()); LocationPoint lp = window.Location as LocationPoint; XYZ newPosition = lp.Point; // XYZ has operator overloads XYZ translationVec = newPosition - oldPosition; // move the section by the same vector if (!translationVec.IsZeroLength()) { ElementTransformUtils.MoveElement(doc, section.Id, translationVec); } TaskDialog.Show("Moving", "Moving"); // Lookup the normal vector (i,j,we assume k=0) Field fieldOrientation = m_schema.GetField("Orientation"); // Establish the old and new orientation vectors XYZ oldNormal = storedEntity.Get<XYZ>(fieldOrientation, DisplayUnitType.DUT_FEET_FRACTIONAL_INCHES); XYZ newNormal = window.FacingOrientation; // If different, rotate the section by the angle around the location point of the window double angle = oldNormal.AngleTo(newNormal); // Need to adjust the rotation angle based on the direction of rotation (not covered by AngleTo) XYZ cross = oldNormal.CrossProduct(newNormal).Normalize(); double sign = 1.0; if (!cross.IsAlmostEqualTo(XYZ.BasisZ)) { sign = -1.0; } angle *= sign; if (Math.Abs(angle) > 0) { Line axis = doc.Application.Create.NewLineBound(newPosition, newPosition + XYZ.BasisZ); ElementTransformUtils.RotateElement(doc, section.Id, axis, angle); } // update the parameters on the window instance (to be the current position and orientation) storedEntity.Set<XYZ>(fieldPosition, newPosition, DisplayUnitType.DUT_FEET_FRACTIONAL_INCHES); storedEntity.Set<XYZ>(fieldOrientation, newNormal, DisplayUnitType.DUT_FEET_FRACTIONAL_INCHES); window.SetEntity(storedEntity); } } } catch (System.Exception ex) { TaskDialog.Show("Exception", ex.ToString()); } return; }