Hi folks, I'm using this wicked tutorial (http://nmillerarch.blogspot.com/2010/01/streaming-grasshopper-points-into-revit.html) as a basis for a plug in that will read info out of a csv file. However its a few years old and grom what I gather some of the definations have been redefined our outdated. I've dome the 'first' revit api plug in tutorial and am stoked about my sucess. But I'm new to vb and C, so I was wondering if anyone has updated info? or could point out changes and where updated info might be found?
Cheers
Dermott
Dear Dermott,
I don't see what problems you might be running into.
I looked a thte VB code presented on
http://nmillerarch.blogspot.com/2010/01/streaming-grasshopper-points-into-revit.html
It looks perfectly ok and up to date to me.
Here is the C# version of the same:
string filepath = "insert file path here";
if( File.Exists( filepath ) )
{
StreamReader s = new StreamReader(
filepath );
while( -1 != s.Peek() )
{
string line = s.ReadLine();
string[] data = line.Split(
new char[] { ',' } );
XYZ p = app.Create.NewXYZ(
double.Parse( data[0] ),
double.Parse( data[1] ),
double.Parse( data[2] ) );
ReferencePoint rp = doc.FamilyCreate
.NewReferencePoint( p );
}
}
Best regards,
Jeremy
--
Jeremy Tammik
Autodesk Developer Network -- http://www.autodesk.com/joinadn
The Building Coder -- http://thebuildingcoder.typepad.com
Jeremy,
Thanks for your help. The code is very much appriciated. I am however having some trouble pasting it into the right context... i've tried some remedial trouble shooting but as I fix an error - it creates another one. I've pasted the code straight into a blank C# class library template (as per Revit API tutorial 1) as below but get lots of errors - I assume I'm making a stupid mistake in the syntax but can't figure it out. Any help appriciated... and again thatnks for the helping hand.
Dermott
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
namespace SnaggARAddon
{
string filepath = "insert file path here";
if( File.Exists( filepath ) )
{
StreamReader s = new StreamReader(
filepath );
while( -1 != s.Peek() )
{
string line = s.ReadLine();
string[] data = line.Split(
new char[] { ',' } );
XYZ p = app.Create.NewXYZ(
double.Parse( data[0] ),
double.Parse( data[1] ),
double.Parse( data[2] ) );
ReferencePoint rp = doc.FamilyCreate
.NewReferencePoint( p );
}
}
}
Dear Dermott,
Please work through one of the getting started tutorials first, before even thinking about CSV.
Then you will have a skeleton in place and gotten the hang of it.
http://thebuildingcoder.typepad.com/blog/2011/10/getting-started-with-the-revit-2012-api.html
http://thebuildingcoder.typepad.com/blog/2012/01/preparing-for-a-hands-on-revit-api-training.html
Best regards,
Jeremy
--
Jeremy Tammik
Autodesk Developer Network -- http://www.autodesk.com/joinadn
The Building Coder -- http://thebuildingcoder.typepad.com
Hi Dermott,
great, congratulations! I wrote a blog post draft summarising our conversation, if you don't mind sharing it there as well. I attached it to this message. Would you like to share your final add-in as well?
Or was it attached somewhere already and I overlooked it?
Thank you!
Best regards,
Jeremy
--
Jeremy Tammik
Autodesk Developer Network -- http://www.autodesk.com/joinadn
The Building Coder -- http://thebuildingcoder.typepad.com