protected override void Updater_ElementsDeleted( Document document, IEnumerable <ElementId> deleted) { if (!SelectionResults.Any() || !document.Equals(SelectionOwner) || !deleted.Any()) { return; } // If the deleting operations does not make any elements in SelectionResults // invalid, then there is no need to update. if (SelectionResults.Where(el => !el.IsValidObject).Count() == 0) { return; } // We are given a set of ElementIds, but because the elements // have already been deleted from Revit, we can't get the // corresponding GUID. Instead, we just go through the collection of // elements and get the ones that are still valid. var validEls = Selection.Where(el => el.IsValidObject).ToList(); UpdateSelection(validEls); }
public override string ToString() { if (Selection.Any() && !SelectionResults.Any()) { return(Resources.NoFamilyInstancesInDividedSurfaceWarning); } return(base.ToString()); }
protected override void Updater_ElementsDeleted( Document document, IEnumerable <ElementId> deleted) { if (!SelectionResults.Any() || !document.Equals(SelectionOwner)) { return; } var uuids = deleted.Select(document.GetElement) .Where(el => el != null) .Select(el => el.UniqueId); UpdateSelection(Selection.Where(x => !uuids.Contains(x.UniqueId))); }
public override IEnumerable <AssociativeNode> BuildOutputAst( List <AssociativeNode> inputAstNodes) { AssociativeNode node; if (SelectionResults == null || !SelectionResults.Any()) { node = AstFactory.BuildNullNode(); } else { var newInputs = new List <AssociativeNode>(); foreach (var reference in SelectionResults) { if (reference.GlobalPoint == null) { return(new[] { AstFactory.BuildAssignment( GetAstIdentifierForOutputIndex(0), AstFactory.BuildNullNode()) }); } var pt = reference.GlobalPoint.ToPoint(); //this is a selected point on a face var ptArgs = new List <AssociativeNode> { AstFactory.BuildDoubleNode(pt.X), AstFactory.BuildDoubleNode(pt.Y), AstFactory.BuildDoubleNode(pt.Z) }; var functionCallNode = AstFactory.BuildFunctionCall( new Func <double, double, double, Point>(Point.ByCoordinates), ptArgs); newInputs.Add(functionCallNode); } node = AstFactory.BuildExprList(newInputs); } return(new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), node) }); }
protected override void SaveNode(XmlDocument xmlDoc, XmlElement nodeElement, SaveContext context) { if (!SelectionResults.Any()) { return; } var uuidsSelection = selection.Select(GetIdentifierFromModelObject).Where(x => x != null); foreach (var id in uuidsSelection) { XmlElement outEl = xmlDoc.CreateElement("instance"); outEl.SetAttribute("id", id); nodeElement.AppendChild(outEl); } }
protected override void Updater_ElementsDeleted( Document document, IEnumerable <ElementId> deleted) { // If an element is deleted, ensure all references which refer // to that element are removed from the selection if (!SelectionResults.Any() || !document.Equals(SelectionOwner)) { return; } UpdateSelection(SelectionResults.Where(x => !deleted.Contains(x.ElementId))); RaisePropertyChanged("SelectionResults"); RaisePropertyChanged("Text"); RequiresRecalc = true; }
/// <summary> /// /// </summary> /// <param name="inputAstNodes"></param> /// <returns></returns> public override IEnumerable <AssociativeNode> BuildOutputAst(List <AssociativeNode> inputAstNodes) { AssociativeNode node; if (SelectionResults == null || !SelectionResults.Any()) { node = AstFactory.BuildNullNode(); } else { IEnumerable <AssociativeNode> strInputs = SelectionResults.Select(res => AstFactory.BuildStringNode(res) as AssociativeNode); ExprListNode inputNode1 = AstFactory.BuildExprList(strInputs.ToList()); node = AstFactory.BuildFunctionCall(new Func <IEnumerable <string>, IEnumerable <SteelDbObject> >(Utils.GetDynObjects), new List <AssociativeNode>() { inputNode1 }); } return(new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), node) }); }
/// <summary> /// /// </summary> /// <param name="inputAstNodes"></param> /// <returns></returns> public override IEnumerable <AssociativeNode> BuildOutputAst(List <AssociativeNode> inputAstNodes) { AssociativeNode node; if (SelectionResults == null || !SelectionResults.Any()) { node = AstFactory.BuildNullNode(); } else { //IEnumerable<AssociativeNode> strInputs = SelectionResults.Select(res => AstFactory.BuildStringNode(res) as AssociativeNode); //ExprListNode inputNode1 = AstFactory.BuildExprList(strInputs.ToList()); //node = AstFactory.BuildFunctionCall(new Func<IEnumerable<string>, IEnumerable<SteelDbObject>>(Utils.GetDynObjects), new List<AssociativeNode>() { inputNode1 }); var newInputs = new List <AssociativeNode>(); foreach (var resP in SelectionResults) { //this is a selected point on a face var ptArgs = new List <AssociativeNode> { AstFactory.BuildDoubleNode(resP.X), AstFactory.BuildDoubleNode(resP.Y), AstFactory.BuildDoubleNode(resP.Z) }; var functionCallNode = AstFactory.BuildFunctionCall( new Func <double, double, double, Autodesk.DesignScript.Geometry.Point>(Autodesk.DesignScript.Geometry.Point.ByCoordinates), ptArgs); newInputs.Add(functionCallNode); } node = AstFactory.BuildExprList(newInputs); } return(new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), node) }); }
public override IEnumerable <AssociativeNode> BuildOutputAst( List <AssociativeNode> inputAstNodes) { AssociativeNode node; Func <string, object> func = GeometryObjectSelector.GetPointByReference; if (SelectionResults == null || !SelectionResults.Any()) { node = AstFactory.BuildNullNode(); } else { var newInputs = new List <AssociativeNode>(); foreach (var reference in SelectionResults) { var stableRef = GetIdentifierFromModelObject(reference); //this is a selected point on a face var ptArgs = new List <AssociativeNode> { AstFactory.BuildStringNode(stableRef) }; var functionCallNode = AstFactory.BuildFunctionCall( func, ptArgs); newInputs.Add(functionCallNode); } node = AstFactory.BuildExprList(newInputs); } return(new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), node) }); }
protected override void Updater_ElementsDeleted( Document document, IEnumerable <ElementId> deleted) { // If an element is deleted, ensure all references which refer // to that element are removed from the selection // If there is no selection, or the doc of the deleted // elements is not this doc, or if there is nothing // in the deleted set, then return if (!SelectionResults.Any() || !document.Equals(SelectionOwner) || !deleted.Any() || !SelectionResults.Any(x => deleted.Contains(x.ElementId))) { return; } // The new selections is everything in the current selection // that is not in the deleted collection as well var newSelection = SelectionResults.Where(x => !deleted.Contains(x.ElementId)); UpdateSelection(newSelection); }
public override string ToString() { return(SelectionResults.Any() ? string.Format("{0} : {1}", Prefix, FormatSelectionText(SelectionResults)) : Resources.SelectionNodeNothingSelected); }
public override string ToString() { return(SelectionResults.Any() ? string.Format("{0} : {1}", Prefix, FormatSelectionText(SelectionResults)) : "Nothing selected."); }