PDA

View Full Version : Update an Instance Mark from excel



christopher.pynn
2008-04-09, 01:47 PM
Hi all,

Now I have done some research of past posts and I am guessing what I would like to do is possible but as I have no experience with C programming I am after some help here.

I am attempting to have a simple beam schedule in RS2008 where by I have the Type, Type Mark and Instance Mark listed.

I would like to be able to export that table to excel. update all the instance marks using in excel, then pass that data back to the objects in the schedule.

Would appreciate if anyone could shed some light on that for me.

Cheers
C

mmason.65315
2008-04-09, 08:00 PM
If you have the Revit SDK, you'll find a sample called "Fire Rating". This example exports the Fire Rating parameter to excel, allows you to modify it, then allows you to import the changes back in...

It's pretty close to what you want, and should get you off to a good start.

-Matt

christopher.pynn
2008-04-10, 05:47 AM
Cheers for that.
I will take a look.

C

r.howarth
2008-04-10, 06:08 AM
if you are new to the API make sure you have a read of the threads for people new to the API
there is some good information that will save you some time.

I have a blog post I've made about this sort of thing: http://roddotnet.blogspot.com/2008/02/setting-up-template-for-revit-api.html

if you wanted live changes I believe that .Net allows for excel to be used as a data source (ie as if it were a database), I have used this in ASP, I assume it could be used in C# or VB.Net too: http://roddotnet.blogspot.com/2007/07/using-excel-documents-as-data-source-in.html


but I'd say your best bet is the fire rating example.

Best of luck!

mpruna
2008-04-10, 02:48 PM
try this, ripped from a code I wrote that worked, but this snippet is untested.



Excel1.Application my_excel = (Excel1.Application)Marshal.GetActiveObject("Excel.Application");
Excel1.Workbook my_book = (Excel1.Workbook)my_excel.ActiveWorkbook;
Excel1.Worksheet my_sheet = (Excel1.Worksheet)my_book.ActiveSheet;
Excel1.Range ranger;
string sranger="";
int roww=1;
int col=1;
ElementSetIterator it = myObjects.ForwardIterator();
while (it.MoveNext())
{
Element element = it.Current as Element;
ParameterSet parameters = element.Parameters;
foreach (Parameter param in parameters)
{

if (param.Definition.Name.ToString() =="Mark" )
{
my_sheet.Cells[roww, col] = param.AsString();
}
}
roww++;
}