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 Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { Document doc = commandData.Application.ActiveUIDocument.Document; using (Transaction t = new Transaction(doc, "Add Cats")) { t.Start(); for (int i = 0; i < Enum.GetNames(typeof(ObjectCategory)).Length; i++) { doc.AddCategories(i); } t.Commit(); } return(Result.Succeeded); }
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())) { GenericForm ele = doc.GetElement(e) as GenericForm; var bbox = ele.get_BoundingBox(null); if (bbox != null) { var dims = GetDims(bbox); int prediction = Datatype.ObjectStyle.PredictSingle(name, "null", dims); var subcat = doc.AddCategories(prediction); ele.Subcategory = subcat; } //run info through neural network (slightly larger than mf network. //update object style parameter } //profit } catch (Exception e) { e.OutputError(); } } }