Results 1 to 2 of 2

Thread: Sharp Development

  1. #1
    Member
    Join Date
    2008-06
    Posts
    16
    Login to Give a bone
    0

    Default Sharp Development

    I was trying to get some of the examples from the Revit API Help to work with the Sharp Development version included with Revit 2015.

    I got the "hello world" message box to work, but I got stuck after that.

    If I go to the Macros in Revit, and create a new module, and create a new Macro under that, I can't figure out how to add the code from the "Retrieve Selected Elements" example.

    Can anyone offer some insight into what I need to do to make these examples work? The examples all seem to make a IExternalCommand or IExternalApplication interface. That doesn't seem to work with Sharp. And I'm not sure what to do with the extra code Sharp creates.

    For example, I was trying to get this to work:
    Code:
    [Autodesk.Revit.Attributes.Transaction(TransactionMode.ReadOnly)]
    public class Document_Selection : IExternalCommand
    {
        public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
            ref string message, ElementSet elements)
        {
            try
            {
                // Select some elements in Revit before invoking this command
    
                // Get the handle of current document.
                UIDocument uidoc = commandData.Application.ActiveUIDocument;
                    
                // Get the element selection of current document.
                Selection selection = uidoc.Selection;
                ICollection<ElementId> selectedIds = uidoc.Selection.GetElementIds();
    
                if (0 == selectedIds.Count)
                {
                    // If no elements selected.
                    TaskDialog.Show("Revit","You haven't selected any elements.");
                }
                else
                {
                    String info = "Ids of selected elements in the document are: ";
                    foreach (ElementId id in selectedIds)
                    {
                        info += "\n\t" + id.IntegerValue;
                    }
    
                    TaskDialog.Show("Revit",info);
                }
            }
            catch (Exception e)
            {
                message = e.Message;
                return Autodesk.Revit.UI.Result.Failed;
            }
    
            return Autodesk.Revit.UI.Result.Succeeded;
        }
        /// </ExampleMethod>
    }
    But sharp already has a class definition that looks like this:

    Code:
    public partial class ThisApplication
    and another that looks like this:

    Code:
    public void Document_Selection()
    My application fails when I try to build it with the error "The name commanddata does not exist in the current context (CS103)"
    Last edited by Wanderer; 2014-12-29 at 02:57 PM. Reason: added code tags

  2. #2
    I could stop if I wanted to
    Join Date
    2007-07
    Location
    London, UK
    Posts
    361
    Login to Give a bone
    0

    Default Re: Sharp Development

    add to the using block: using Autodesk.Revit.UI;
    or prefix it: Autodesk.Revit.UI.ExternalCommandData

Similar Threads

  1. Arc become sharp right-angle
    By Jack Cheong in forum AutoCAD General
    Replies: 8
    Last Post: 2010-08-05, 05:29 AM
  2. cant publish to sharp copiers
    By Sideways Phoenix in forum AutoCAD Plotting
    Replies: 0
    Last Post: 2009-06-23, 01:40 PM
  3. Theoretical Sharp Corners
    By sgiffin.164769 in forum Inventor - General
    Replies: 7
    Last Post: 2008-09-17, 08:03 PM
  4. Theoretical Sharp Corners
    By sgiffin.164769 in forum AutoCAD Map 3D - General
    Replies: 7
    Last Post: 2008-09-17, 08:03 PM
  5. Render w/sharp edges
    By jefflormans in forum AutoCAD 3D (2007 and above)
    Replies: 2
    Last Post: 2007-10-04, 08:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •