User Input

User Input

Anonymous
Not applicable
979 Views
2 Replies
Message 1 of 3

User Input

Anonymous
Not applicable

Commands in Revit like Offset have a textbox just below the ribbon for user input. Is it possible to create a similar textbox using the Revit API? I have been using Windows Forms with some success, but I want the textbox to stay available while multiple objects are modified, similar to how the Offset function works. Thanks.

980 Views
2 Replies
Replies (2)
Message 2 of 3

jeremytammik
Autodesk
Autodesk

Dear Sethgover,

 

Nope, sorry, as far as I know this is currently not covered by the Revit API.

 

It would be interesting to see your current Windows Forms solution.

 

Thank you!

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 3

Anonymous
Not applicable

(This is my first Revit API command). I am attempting to create a command that can select multiple doors, and then number them sequentially given a starting number, in the order they were selected. I am just attaching the code that seems necessary, all this is inside the Execute command. I have two partially working options:

 

 

 

DoorFilter selDoor = new DoorFilter();

DoorTest.Form1 revitForm = new DoorTest.Form1();

revitForm.ShowDialog();                                             //my form is very basic, one text box and OK button

string input_num = revitForm.textBox1.Text;

int number = Convert.ToInt16(input_num);

string numWrite;     

                                                                       //this all works fine, dialog opens and number is assigned

 

 

//Solution A

IList<Reference> doorList = rvtUIdoc.Selection.PickObjects(ObjectType.Element, selDoor, "pick doors");

 

foreach (Reference door in doorList)

{

    numWrite = Convert.ToString(number);

    Element thisDoor = myRVTdoc.GetElement(door);

    thisDoor.get_Parameter("Mark").Set(numWrite);

    number++;

}

// this does exactly what I want, except that selection order is not retained, and doors are numbered sequentially based on order of their creation

// I need to do more research about possibly retaining selection order with PickObjects

 

 

 

//Solution B

while (!quitToggle)

{

    Transaction trans = new Transaction(myRVTdoc);

    trans.Start("start");

    Reference userSelect = rvtUIdoc.Selection.PickObject(ObjectType.Element, selDoor, "pick doors");

    Element pickedElem = myRVTdoc.GetElement(userSelect);

    numWrite = Convert.ToString(number);

    pickedElem.get_Parameter("Mark").Set(numWrite);

    trans.Commit();

    number++;

}

// I know while loops should be used very sparingly, as evidenced here. This code works great until you need to quit the command, doors are numbered as you click, but pressing escape cancels all changes. My thought was to use a key Press or click to turn the quitToggle bool to true, but I think the code gets stuck in while loop.

 

Using PickObject like Solution B seems to work better, but I don't know how to loop back to this until the command is exited.

 

Thanks for you time,

 

Seth

 

(P.S. to you and Autodesk, overall awesome job with documentation and examples of the Revit API, all the online material makes it quite simple for an amateur coder like myself to start writing commands. Thanks.)

0 Likes