Note to Mods: I can only select the 2014 prefix...
I have recently begun learning how to set up macros in Revit 2013. I can set up a macro easily that will create a TaskDialog box. I then tried to follow numerous tutorials on creating a simple line in Revit. When I run the macro I just get the error below:
error.JPG
I have narrowed it down to this bit of code :The .cs file looks like this :Code:SketchPlane planeSF = doc.FamilyCreate.NewSketchPlane(plane);
/*
* Revit Macro created by SharpDevelop
* User: s.bland
* Date: 25/04/2013
* Time: 10:06
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.DB.Events;
using Autodesk.Revit.UI.Events;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.ApplicationServices;
namespace TestingModule
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.UI.Macros.AddInId("A08DF99D-E407-4529-B84A-CB5F57715466")]
public partial class ThisApplication
{
private void Module_Startup(object sender, EventArgs e)
{
}
private void Module_Shutdown(object sender, EventArgs e)
{
}
#region Revit Macros generated code
private void InternalStartup()
{
this.Startup += new System.EventHandler(Module_Startup);
this.Shutdown += new System.EventHandler(Module_Shutdown);
}
#endregion
public void TestMacro()
{
// Begin a series of instructions to Revit
Transaction trans1 = new Transaction(ActiveUIDocument.Document, "Line");
trans1.Start();
// Define the document into which the geometry will be placed
Document doc = ActiveUIDocument.Document;
// Revit uses Imperial Feet as its internal definition for length -
// So provide a conversion variable in order to work in Millimetres:-
double ftMM = 1 / 304.8;
// Define two points on the Line - multiply by the conversion variable
XYZ point01 = new XYZ(); // Defaults to (0.0, 0.0, 0.0) if no values are provided
XYZ point02 = new XYZ(3000.0, 2400.0, 0.0) * ftMM;
// Create the Line geometry - 'true' indicates it terminates at the setout points
Line line01 = doc.Application.Create.NewLine(point01, point02, true);
// Define the Plane for the Line placement - X-Axis, Y-Axis, Origin
Plane plane = doc.Application.Create.NewPlane(XYZ.BasisX, XYZ.BasisY, point01);
// Create a Sketch Plane from this Plane in order to display the Line
SketchPlane planeSF = doc.FamilyCreate.NewSketchPlane(plane);
// Display the Line
ModelLine line01F = doc.FamilyCreate.NewModelCurve(line01, planeSF) as ModelLine;
// End the series of instructions
trans1.Commit();
}
}
}
I hit the same problems when I try to create anything.
Any ideas?
Thanks for the help.