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) { 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()) { 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 gs = ele.LineStyle as GraphicsStyle; if (!gs.Name.Contains(Enum.GetNames(typeof(ObjectCategory))[prediction])) { if (Enum.GetNames(typeof(ObjectCategory)).Any(x => gs.Name.Contains(x))) { Datatype.ObjectStyle.PropogateSingle(Enum.GetNames(typeof(ObjectCategory)).ToList().IndexOf( Enum.GetNames(typeof(ObjectCategory)).Where(x => gs.Name.Contains(x)).First()), new WriteToCMDLine(WriteNull), name, "line", dims); } } } } } catch (Exception e) { e.OutputError(); } } }