« Move Duct Join Add-In with Video and GitHub Support | Main | Using the Built-In Revit AcGe Functionality »

October 17, 2013

Comments

Hi, I am trying to write a little macro to open a file and set up sheet parameters according to file contents (each line is a sheet number along with 2 other parameters to be set: name and a drawing number). I have several standalone projects (nothing to do with Revit) that do similar things, but getting Revit macros to do this is proving difficult.

I get an error that "The type or namespace name 'OpenFileDialog' could not be found" . . . I have a using System.IO entry, but it seems that the macro works differently than the dll route. Any insight into how to get this to work as a macro?

Here is my code:
public void LoadDrawingNumbers()
{
//Get document object
Document doc = this.ActiveUIDocument.Document;
FilteredElementCollector Sheets = new FilteredElementCollector(doc);
OpenFileDialog openFile = new OpenFileDialog();
openFile.InitialDirectory = "c:\\";
openFile.Filter = "txt files (*.txt)|*.txt|All Files (*.*)|*.*";
openFile.FilterIndex = 2;
openFile.RestoreDirectory = true;

if(openFile.ShowDialog() == TaskDialogResult.OK) {
try
{
// line by line
}
catch (Exception ex) {
MessageBox.Show("Error: " + ex.Message);
}
}
}

Dear Paul,

No, I am not very familiar with the macro environment, so I don't know offhand. Did you solve this? How, please? Thank you!

Cheers, Jeremy.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Your Information

(Name and email address are required. Email address will not be displayed with the comment.)

Jeremy Tammik

AboutTopicsIndexSource