Trouble creating wall

Trouble creating wall

Anonymous
Not applicable
552 Views
2 Replies
Message 1 of 3

Trouble creating wall

Anonymous
Not applicable

Hi everyone: I'm trying to make a simple add-in which creates a wall. It compile fine, but it doesn't works. What I'm doing wrong?

Here's the code:

 

Highlight.cs

using System;
using System.Reflection;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using System.Windows.Media.Imaging;
using System.Windows.Forms;
namespace Walkthrough
{
   /// <remarks>
   /// This application's main class. The class must be Public.
   /// </remarks>
   public class Highlight : IExternalApplication
   {
      // Both OnStartup and OnShutdown must be implemented as public method
      public Result OnStartup(UIControlledApplication application)
      {
        	
      	
      	// Add a new ribbon panel
         RibbonPanel ribbonPanel = application.CreateRibbonPanel("NewRibbonPanel");

         // Create a push button to trigger a command add it to the ribbon panel.
         string thisAssemblyPath = Assembly.GetExecutingAssembly().Location;

        
         PushButtonData buttonData = new PushButtonData("cmdHelloWorld",
            "Hello World", thisAssemblyPath, "Walkthrough.HelloWorld");

         PushButton pushButton = ribbonPanel.AddItem(buttonData) as PushButton;

         
         
         
         // Optionally, other properties may be assigned to the button
         // a) tool-tip
         pushButton.ToolTip = "Say hello to the entire world.";

         // b) large bitmap
         Uri uriImage = new Uri(@"C:\globe.png");
         BitmapImage largeImage = new BitmapImage(uriImage);
         pushButton.LargeImage = largeImage;

         return Result.Succeeded;
      }

      public Result OnShutdown(UIControlledApplication application)
      {
         // nothing to clean up in this simple case
         return Result.Succeeded;
      }
   }
   /// <remarks>
   /// The "HelloWorld" external command. The class must be Public.
   /// </remarks>
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
   public class HelloWorld : IExternalCommand
   {
    
   	// The main Execute method (inherited from IExternalCommand) must be public
      public Autodesk.Revit.UI.Result Execute(ExternalCommandData revit,
          ref string message, ElementSet elements)
      {
   		Document doc = revit.Application.ActiveUIDocument.Document;
   		
   		Transaction trans = new Transaction(doc);
        trans.Start("CreationMurAuto");


       //Create line 
        XYZ start = new XYZ(0,0,0);
        XYZ end = new XYZ(100,100,0);
       
        Curve wallLine = Line.CreateBound(start, end);
        Level nivel = Level.Create(doc, 20.0);


		Wall.Create(doc, wallLine, nivel.Id, false);
        
        trans.Dispose();
        return Result.Succeeded;

      }
   }
}

Thank you

0 Likes
Accepted solutions (1)
553 Views
2 Replies
Replies (2)
Message 2 of 3

Revitalizer
Advisor
Advisor
Accepted solution

Hi,

 

"trans.Commit()" is missing.

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 3 of 3

Anonymous
Not applicable

It worked fine! Thanks a lot.

0 Likes