You could always simply modify the appropriate Button Properties to use one Button for same, you'd just need to test for the Button's Text Property (presuming the ON / OFF is visible to indicate 'mode') to conditionally perform the appropriate Click event action(s). Either way.
... new job, need to get used to it I guess.
Congrats on the new job (I hope?); are you still in ZA?Thanks, yes ... still here. I'm now working for a much smaller local firm doing only commercial & office buildings. Much less pressure, and more time for my "hobbies" ... I hope. Also they're using Revit near-exclusively, which is why I'm now focussing on this for a start.
Is there a ToggleButton in WinForms? I use WPF and would use the ToggleButton events IsChecked to start creating a list of entities and IsUnchecked to stop collecting entities.Well, yes that is what I'm attempting. Though, it's not simply collecting entities: Each time the user picks an entity, it's data must be updated according to the increment value. Then the loop starts again.
Application app = sender as Application;
UIApplication uiApplication = new UIApplication( app );
toUIApplication uiApplication = sender as UIApplication;
Thanks. Will check that out.
Thanks, that's a good tip indeed!
Fortunately for this scenario I'm only interested in a selection of one item at a time. So I could probably disregard anything as such:Code - C#: [Select]What I'm worried about though is setting a selection filter. Sorry, I'm really a newbie to Revit's API - still using google a lot to find anything as and when I get stuck.
if (selected.size > 1)
[...]
UIDocument uidoc = commandData.Application.ActiveUIDocument; //I'll assume you're using a macro. If you're coding an add-in, retrieving the active document is a slightly different process
Document doc = uidoc.Document;
Autodesk.Revit.UI.Selection.Selection sel = uidoc.Selection;
Reference ref = sel.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element, new ElementSelectionFilter(), "Select an Element");
Element el = doc.get_Element(ref.ElementId);
[...]
public class ElementSelectionFilter : ISelectionFilter
{
public bool AllowElement(Element elem)
{
if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_WhatEverCategoryYouWantToFilterFor) return true;
//Put any other kind of check here, return true to allow the element to be selected, otherwise return false
return false;
}
public bool AllowReference(Reference refer, XYZ pos)
{
return false;
}
}
Reference ref = sel.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element, new ElementSelectionFilter(), "Select an Element");
withIList<Reference> referenceList = sel.PickObjects(Autodesk.Revit.UI.Selection.ObjectType.Element, new ElementSelectionFilter(), "Select desired elements. Press Finish when done.");
bool continueLoop = true;
while (continueLoop) {
String val = GetCalculatedString();
try {
Reference sel = doc.Selection.PickObject(ObjectType.Element, new BoudParameterFilter(),
"Pick the element to set new value of [" + val + "], press ESC to stop");
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
{
//Pressing escape to cancel the pick object operation throws the above exception
continueLoop = false;
}
[...]
}
using (Transaction trans = new Transaction(doc))
{
trans.Start("Doing something");
//Operation
trans.Commit();
}