private void btnManageTourType_Click(object sender, EventArgs e) { GenericForm <TourType> dialog = new GenericForm <TourType>(_unitOfWork); _tourTypes = _unitOfWork.TourTypes.GetAll(); LoadComboTourType(); }
public void Connect(GenericForm <Connector> form, IList <int> targetIDs) { var tConnector = Table <Connector>(); // delete all exist connector for connectorType and sourceID var connectors = tConnector.Where(w => w.IsDeleted == false && w.ConnectorType == form.DataModel.ConnectorType && w.SourceID == form.DataModel.SourceID); foreach (var connector in connectors) { if (targetIDs.Contains(connector.TargetID)) { targetIDs.Remove(connector.TargetID); } else { UpdateAuditFields(connector, form.ByUserID); connector.IsDeleted = true; } } // add new one or set delete flag to false foreach (var targetID in targetIDs) { form.DataModel.TargetID = targetID; var connector = tConnector.GetOrAdd(w => w.ConnectorType == form.DataModel.ConnectorType && w.SourceID == form.DataModel.SourceID && w.TargetID == form.DataModel.TargetID); UpdateAuditFields(connector, form.ByUserID); MapProperty(form.DataModel, connector); connector.IsDeleted = false; } // save SaveChanges(); }
/// <summary> /// Implement this method as an external command for Revit. /// </summary> /// <param name="commandData">An object that is passed to the external application /// which contains data related to the command, /// such as the application object and active view.</param> /// <param name="message">A message that can be set by the external application /// which will be displayed if a failure or cancellation is returned by /// the external command.</param> /// <param name="elements">A set of elements to which the external application /// can add elements that are to be highlighted in case of failure or cancellation.</param> /// <returns>Return the status of the external command. /// A result of Succeeded means that the API external method functioned as expected. /// Cancelled can be used to signify that the user cancelled the external operation /// at some point. Failure should be returned if the application is unable to proceed with /// the operation.</returns> public virtual Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData , ref string message, Autodesk.Revit.DB.ElementSet elements) { if (null == s_appCreation) { // share for class Intersection. s_appCreation = commandData.Application.Application.Create; } UIDocument doc = commandData.Application.ActiveUIDocument; CombinableElementArray solids = new CombinableElementArray(); ElementSet es = new ElementSet(); foreach (ElementId elemId in es) { es.Insert(doc.Document.GetElement(elemId)); } if (0 < es.Size) { foreach (Autodesk.Revit.DB.ElementId elementId in doc.Selection.GetElementIds()) { Autodesk.Revit.DB.Element element = doc.Document.GetElement(elementId); System.Diagnostics.Trace.WriteLine(element.GetType().ToString()); GenericForm gf = element as GenericForm; if (null != gf && !gf.IsSolid) { continue; } CombinableElement ce = element as CombinableElement; if (null != ce) { solids.Append(ce); } } if (solids.Size < 2) { message = "At least 2 combinable elements should be selected."; return(Autodesk.Revit.UI.Result.Failed); } doc.Document.CombineElements(solids); //The selected generic forms are joined, whether or not they overlap. return(Autodesk.Revit.UI.Result.Succeeded); } AutoJoin autojoin = new AutoJoin(); autojoin.Join(doc.Document); //All overlapping generic forms are joined. return(Autodesk.Revit.UI.Result.Succeeded); }
/// <summary> /// Sets the element's visible. /// </summary> /// <param name="gf"></param> public static void SetExtrusionVisible(this GenericForm gf) { var visibility = gf.GetVisibility(); // No display on plane view. visibility.IsShownInTopBottom = false; gf.SetVisibility(visibility); }
public bool AllowElement(Element element) { GenericForm gf = element as GenericForm; if (gf != null) { return(true); } else { return(false); } }
public int SaveChanges(GenericForm <Feed> form) { var tFeed = Table <Feed>(); var feed = tFeed.GetOrAdd(w => w.ID == form.DataModel.ID); MapProperty(form.DataModel, feed, form.InlineEditProperty); UpdateAuditFields(feed, form.ByUserID); // save SaveChanges(); return(feed.ID); }
/// <summary> /// Sets the element's visible. /// </summary> /// <param name="gf"></param> public static void SetExtrusionVisible(this GenericForm gf) { if (gf == null) { throw new ArgumentNullException(nameof(gf)); } var visibility = gf.GetVisibility(); // No display on plane view. visibility.IsShownInTopBottom = false; gf.SetVisibility(visibility); }
private void AssignSubCategory(Document familyDoc, GenericForm extrusion) { try { Category cat = familyDoc.OwnerFamily.FamilyCategory; Category subCat = familyDoc.Settings.Categories.NewSubcategory(cat, _name); subCat.Material = CreateMaterial(familyDoc); extrusion.Subcategory = subCat; } catch (Exception ex) { TaskDialog.Show("SubCategory Error", ex.Message); } }
/// <summary>Close the form</summary> public virtual void Close() { if (Thread == null) { throw new Exception("Tried to close gui before launching it"); } if (IsAlive) { try { GenericForm.Invoke((Action)GenericForm.Close); } catch (ObjectDisposedException) { Console.WriteLine("Form was already closed"); } } }
public void Execute(UpdaterData data) { Document doc = data.GetDocument(); if (doc.IsFamilyDocument) { try { //Get document Name string name = doc.Title; string n2 = "null"; if (String.IsNullOrEmpty(name)) { name = "null"; } //Get form location info (Varies by type?) foreach (ElementId e in data.GetModifiedElementIds()) { GenericForm ele = doc.GetElement(e) as GenericForm; if (ele != null) { Sweep sweep = doc.GetElement(e) as Sweep; if (sweep != null) { if (sweep.ProfileSymbol != null) { n2 = sweep.ProfileSymbol.Profile.Name; } } var bbox = ele.get_BoundingBox(null); if (bbox != null) { var dims = GetDims(bbox); if (Enum.GetNames(typeof(ObjectCategory)).ToList().Any(x => ele.Subcategory.Name.Contains(x))) { int Correct = Enum.GetNames(typeof(ObjectCategory)).ToList().IndexOf(Enum.GetNames(typeof(ObjectCategory)).ToList().Where(x => ele.Subcategory.Name.Contains(x)).First()); Datatype.ObjectStyle.PropogateSingle(Correct, new WriteToCMDLine(WriteNull), name, n2, dims); } } } } } catch (Exception e) { e.OutputError(); } } }
public static void PaintByMaterial(UIDocument uidoc, Param par) { Document doc = uidoc.Document; if (doc.IsFamilyDocument) { Selection sel = uidoc.Selection; ISelectionFilter selectionFilter = new GFSelectionFilter(); Reference ChangedObject = sel.PickObject(ObjectType.Element, selectionFilter); GenericForm gf = doc.GetElement(ChangedObject.ElementId) as GenericForm; using (Transaction t = new Transaction(doc, "Paint Faces")) { t.Start(); FamilyManager fmgr = doc.FamilyManager; FamilyParameter p; if (doc.FamilyManager.get_Parameter(par.Guid) == null) { ExternalDefinition def = par.CreateDefinition(doc) as ExternalDefinition; p = doc.FamilyManager.AddParameter(def, BuiltInParameterGroup.PG_IFC, par.Instance); } else { p = doc.FamilyManager.get_Parameter(par.Guid); } Options geoOptions = new Options(); geoOptions.DetailLevel = ViewDetailLevel.Fine; GeometryElement geoEle = gf.get_Geometry(geoOptions); IEnumerator <GeometryObject> geoObjIt = geoEle.GetEnumerator(); while (geoObjIt.MoveNext()) { Solid solid = geoObjIt.Current as Solid; if (solid != null) { foreach (Face f in solid.Faces) { doc.Paint(gf.Id, f, p); } } } t.Commit(); } } }
public override FScheme.Value Evaluate(FSharpList <FScheme.Value> args) { Element thisElement = (Element)((FScheme.Value.Container)args[0]).Item; instanceGeometryObjects = new List <GeometryObject>(); var result = FSharpList <FScheme.Value> .Empty; Autodesk.Revit.DB.Options geoOptionsOne = new Autodesk.Revit.DB.Options(); geoOptionsOne.ComputeReferences = true; GeometryObject geomObj = thisElement.get_Geometry(geoOptionsOne); GeometryElement geomElement = geomObj as GeometryElement; if ((thisElement is GenericForm) && (geomElement.Count() < 1)) { GenericForm gF = (GenericForm)thisElement; if (!gF.Combinations.IsEmpty) { Autodesk.Revit.DB.Options geoOptionsTwo = new Autodesk.Revit.DB.Options(); geoOptionsTwo.IncludeNonVisibleObjects = true; geoOptionsTwo.ComputeReferences = true; geomObj = thisElement.get_Geometry(geoOptionsTwo); geomElement = geomObj as GeometryElement; } } foreach (GeometryObject geob in geomElement) { GeometryInstance ginsta = geob as GeometryInstance; if (ginsta != null) { GeometryElement instanceGeom = ginsta.GetInstanceGeometry(); instanceGeometryObjects.Add(instanceGeom); foreach (GeometryObject geobInst in instanceGeom) { result = FSharpList <FScheme.Value> .Cons(FScheme.Value.NewContainer(geobInst), result); } } else { result = FSharpList <FScheme.Value> .Cons(FScheme.Value.NewContainer(geob), result); } } return(FScheme.Value.NewList(result)); }
/// <summary> /// Join geometry between overlapping solids. /// </summary> /// <param name="document">The active document</param> /// <returns>The number of geometry combination be joined in this document.</returns> public int Join(Document document) { int combinated = 0; // CombinableElement is of an element type that exists in the API, but not in Revit's native object model. // We use a combination of GenericForm and GeomCombination elements instead to find all CombinableElement. LogicalOrFilter filter = new LogicalOrFilter( new ElementClassFilter(typeof(GenericForm)), new ElementClassFilter(typeof(GeomCombination))); FilteredElementIterator itor = (new FilteredElementCollector(document)).WherePasses(filter).GetElementIterator(); itor.Reset(); while (itor.MoveNext()) { GenericForm gf = itor.Current as GenericForm; if (null != gf && !gf.IsSolid) { continue; } CombinableElement ce = itor.Current as CombinableElement; if (null == ce) { continue; } else { m_elements.Add(ce); } } // Added all solid forms in this document. while (1 < m_elements.Count) { GeomCombination geomCombination = JoinOverlapping(m_elements, document); if (null == geomCombination) { return(combinated);//No overlapping. } combinated++; } return(combinated); }
/// <summary> /// Associates material. /// </summary> /// <param name="elm"></param> /// <param name="parmName"></param> /// <param name="isInstance"></param> public static void AssociateMaterial(this GenericForm elm, string parmName, bool isInstance = true) { if (elm is null) { throw new ArgumentNullException(nameof(elm)); } if (string.IsNullOrWhiteSpace(parmName)) { throw new ArgumentNullException(nameof(parmName)); } var mgr = elm.Document.FamilyManager; var familyParm = mgr.AddParameter(parmName, BuiltInParameterGroup.PG_MATERIALS, ParameterType.Material, isInstance); var parm = elm.get_Parameter(BuiltInParameter.MATERIAL_ID_PARAM); if (parm != null) { mgr.AssociateElementParameterToFamilyParameter(parm, familyParm); } }
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(); } } }
private void insertCourse_Click(object sender, EventArgs e) { try { string idpiste = GenericForm.OnSelectedItemId(pistecombo); string npiste = GenericForm.OnSelectedItemValue(pistecombo); string pistelong = longpiste.Text; int tours = Convert.ToInt32(this.nbTours.Text); coursse = Fonction.SaveCourse(idpiste, npiste, Convert.ToInt32(textBox1.Text), tours, dateTimePicker1.Value, int.Parse(pistelong)); Console.WriteLine(idpiste); piste = Fonction.GetPiste(idpiste); Rally rally = new Rally(piste, coursse, int.Parse(pistelong)); rally.Show(); Dispose(false); } catch (Exception exception) { MessageBox.Show(@"erreur"); Console.WriteLine(exception.Message); MessageBox.Show(exception.Message); } }
private void ComponentLoad() { _model = new FormViewModel(); ScrollView scrollView = new ScrollView(); Frame mainFrame = new Frame() { BorderColor = Color.Black, Padding = 5, Margin = 2 }; StackLayout mainStackLayout = new StackLayout() { Padding = 0, Spacing = 10 }; _genericForm = new GenericForm <FormViewModel>("Başlık"); mainStackLayout.Children.Add(_genericForm); mainFrame.Content = mainStackLayout; scrollView.Content = mainFrame; _genericForm.AddView(GetFormContent()); _genericForm.AddView(GetFormOtherComponent()); _genericForm.AddView(GetFormFooter()); _genericForm.FinishForm(FormSerialize, CancelForm); Content = scrollView; }
internal static List <GenericFormField <TModel> > Create(GenericForm <TModel> form) { var result = new List <GenericFormField <TModel> >(); var properties = typeof(TModel).GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy); foreach (var prop in properties) { // Skip readonly properties if (prop.SetMethod == null) { continue; } if (prop.GetCustomAttribute <EditableAttribute>() is { } editor&& !editor.AllowEdit) { continue; } var field = new GenericFormField <TModel>(form, prop); result.Add(field); } return(result); }
public override Value Evaluate(FSharpList <Value> args) { ElementId deleteId = ElementId.InvalidElementId; //If we already have a form stored... if (this.Elements.Any()) { //And register the form for deletion. Since we've already deleted it here manually, we can //pass "true" as the second argument. deleteId = this.Elements[0]; this.DeleteElement(this.Elements[0], false); } //Surface argument Solid mySolid = (Solid)((Value.Container)args[0]).Item; GenericForm ffe = null; //use reflection to check for the method System.Reflection.Assembly revitAPIAssembly = System.Reflection.Assembly.GetAssembly(typeof(GenericForm)); Type FreeFormType = revitAPIAssembly.GetType("Autodesk.Revit.DB.FreeFormElement", true); bool methodCalled = false; if (FreeFormType != null) { MethodInfo[] freeFormMethods = FreeFormType.GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public); String nameOfMethodCreate = "Create"; foreach (MethodInfo m in freeFormMethods) { if (m.Name == nameOfMethodCreate) { object[] argsM = new object[2]; argsM[0] = this.UIDocument.Document; argsM[1] = mySolid; methodCalled = true; ffe = (GenericForm)m.Invoke(null, argsM); break; } } } if (ffe != null) { this.Elements.Add(ffe.Id); freeFormSolids[ffe.Id] = mySolid; if (deleteId != ElementId.InvalidElementId) { if (previouslyDeletedFreeForms == null) { previouslyDeletedFreeForms = new Dictionary <ElementId, ElementId>(); } previouslyDeletedFreeForms[ffe.Id] = deleteId; if (previouslyDeletedFreeForms.ContainsKey(deleteId)) { ElementId previouslyDeletedId = previouslyDeletedFreeForms[deleteId]; if (previouslyDeletedId != ElementId.InvalidElementId) { freeFormSolids.Remove(previouslyDeletedFreeForms[deleteId]); } previouslyDeletedFreeForms.Remove(deleteId); } } } else if (!methodCalled) { throw new Exception("This method is not available before 2014 release."); } return(Value.NewContainer(ffe)); }
private void AssignSubCategory(Document familyDoc, GenericForm extrusion) { try { Category cat = familyDoc.OwnerFamily.FamilyCategory; Category subCat = familyDoc.Settings.Categories.NewSubcategory(cat, _Name); subCat.Material = CreateMaterial(familyDoc); extrusion.Subcategory = subCat; } catch (Exception ex) { TaskDialog.Show("SubCategory Error", ex.Message); } }
private void btnManageLocation_Click(object sender, EventArgs e) { GenericForm <Location> dialog = new GenericForm <Location>(_unitOfWork); _locations = _unitOfWork.Locations.GetAll(); }
private void SetListPiste(List <Piste> pistes) { GenericForm.SetComboBox(pistecombo, pistes.Cast <BaseModele>().ToList(), "nom"); }
private void Stream( ArrayList data, GenericForm genForm ) { data.Add( new Snoop.Data.ClassSeparator( typeof( GenericForm ) ) ); data.Add( new Snoop.Data.Bool( "Visible", genForm.Visible ) ); data.Add( new Snoop.Data.Bool( "Is solid", genForm.IsSolid ) ); try { data.Add( new Snoop.Data.Object( "Visibillity", genForm.GetVisibility() ) ); } catch { } Blend blend = genForm as Blend; if( blend != null ) { Stream( data, blend ); return; } Extrusion ext = genForm as Extrusion; if( ext != null ) { Stream( data, ext ); return; } Revolution rev = genForm as Revolution; if( rev != null ) { Stream( data, rev ); return; } Sweep sweep = genForm as Sweep; if( sweep != null ) { Stream( data, sweep ); return; } Form form = genForm as Form; if( form != null ) { Stream( data, form ); return; } SweptBlend sweptBlend = genForm as SweptBlend; if( sweptBlend != null ) { Stream( data, sweptBlend ); return; } }
private void btnManageCostType_Click(object sender, EventArgs e) { GenericForm <CostType> dialog = new GenericForm <CostType>(_unitOfWork); }
private void btnManageJob_Click(object sender, EventArgs e) { GenericForm <Job> dialog = new GenericForm <Job>(_unitOfWork); }
public int AddSeries(SeriesForm form) { using (var uow = UnitOfWorkFactory.Create <NovelContext>()) { var service = new SeriesService(uow); var id = service.SaveChanges(form); var connectorService = new ConnectorService(uow); if (form.Categories != null || form.InlineEditProperty == form.PropertyName(m => m.Categories)) { form.Categories = form.Categories ?? new List <int>(); var connectorForm = new GenericForm <Connector> { ByUserID = form.ByUserID, DataModel = new Connector { ConnectorType = R.ConnectorType.SERIES_TAGCATEGORY, SourceID = id } }; connectorService.Connect(connectorForm, form.Categories); } if (form.Genres != null || form.InlineEditProperty == form.PropertyName(m => m.Genres)) { form.Genres = form.Genres ?? new List <int>(); var connectorForm = new GenericForm <Connector> { ByUserID = form.ByUserID, DataModel = new Connector { ConnectorType = R.ConnectorType.SERIES_TAGGENRE, SourceID = id } }; connectorService.Connect(connectorForm, form.Genres); } if (form.Contains != null || form.InlineEditProperty == form.PropertyName(m => m.Contains)) { form.Contains = form.Contains ?? new List <int>(); var connectorForm = new GenericForm <Connector> { ByUserID = form.ByUserID, DataModel = new Connector { ConnectorType = R.ConnectorType.SERIES_TAGCONTAIN, SourceID = id } }; connectorService.Connect(connectorForm, form.Contains); } if (form.Feeds != null || form.InlineEditProperty == form.PropertyName(m => m.Feeds)) { var feedService = new FeedService(uow); foreach (var feed in form.Feeds) { feed.UrlHash = feed.Url.GetIntHash(); feed.Status = feed.Status == 0 ? R.FeedStatus.ACTIVE : feed.Status; feed.LastSuccessDate = feed.LastSuccessDate == DateTime.MinValue ? DateTime.Now : feed.LastSuccessDate; var feedForm = new GenericForm <Feed> { ByUserID = form.ByUserID, DataModel = feed }; var feedID = feedService.SaveChanges(feedForm); // add to connector only if it a new feed if (feed.ID == 0) { // connect series to feed var connectorForm = new ConnectorForm() { ByUserID = form.ByUserID, ConnectorType = R.ConnectorType.SERIES_FEED, SourceID = id, TargetID = feedID }; connectorService.SaveChanges(connectorForm); } } } if (form.Groups != null || form.InlineEditProperty == form.PropertyName(m => m.Groups)) { foreach (var group in form.Groups) { // connect series to feed var connectorForm = new ConnectorForm() { ByUserID = form.ByUserID, ConnectorType = R.ConnectorType.SERIES_GROUP, SourceID = id, TargetID = group.ID }; connectorService.SaveChanges(connectorForm); } } if (form.Authors != null || form.InlineEditProperty == form.PropertyName(m => m.Authors)) { foreach (var author in form.Authors) { // connect series to feed var connectorForm = new ConnectorForm() { ByUserID = form.ByUserID, ConnectorType = R.ConnectorType.SERIES_AUTHOR, SourceID = id, TargetID = author.ID }; connectorService.SaveChanges(connectorForm); } } if (form.Akas != null || form.InlineEditProperty == form.PropertyName(m => m.Akas)) { var akaService = new AkaService(uow); foreach (var aka in form.Akas) { var akaForm = new AkaForm { ByUserID = form.ByUserID, SourceID = form.ID, SourceTable = R.SourceTable.SERIES }; new PropertyMapper <Aka, AkaForm>(aka, akaForm).Map(); var akaID = akaService.SaveChanges(akaForm); } } return(id); } }
private GenericFormField(GenericForm <TModel> form, PropertyInfo propertyInfo) { _form = form; Property = propertyInfo; }
public int AddGroup(GroupForm form) { using (var uow = UnitOfWorkFactory.Create <NovelContext>()) { var service = new GroupService(uow); var id = service.SaveChanges(form); var connectorService = new ConnectorService(uow); if (form.Feeds != null || form.InlineEditProperty == form.PropertyName(m => m.Feeds)) { var feedService = new FeedService(uow); foreach (var feed in form.Feeds) { feed.UrlHash = feed.Url.GetIntHash(); feed.Status = feed.Status == 0 ? R.FeedStatus.ACTIVE : feed.Status; feed.LastSuccessDate = DateTime.Now.AddYears(-10); var feedForm = new GenericForm <Feed> { ByUserID = form.ByUserID, DataModel = feed }; var feedID = feedService.SaveChanges(feedForm); // add to connector only if it a new feed if (feed.ID == 0) { // connect series to feed var connectorForm = new ConnectorForm() { ByUserID = form.ByUserID, ConnectorType = R.ConnectorType.GROUP_FEED, SourceID = id, TargetID = feedID }; connectorService.SaveChanges(connectorForm); } } } if (form.Glossaries != null && form.InlineEditProperty == form.PropertyName(m => m.Glossaries)) { foreach (var glossary in form.Glossaries) { var glossaryService = new GlossaryService(uow); var glossaryForm = new GlossaryForm(); new PropertyMapper <Glossary, GlossaryForm>(glossary, glossaryForm).Map(); glossaryForm.ByUserID = form.ByUserID; var glossaryID = glossaryService.SaveChanges(glossaryForm); // connect group to glossary var connectorForm = new ConnectorForm() { ByUserID = form.ByUserID, ConnectorType = R.ConnectorType.GROUP_GLOSSARY, SourceID = id, TargetID = glossaryID }; connectorService.SaveChanges(connectorForm); } } return(id); } }