Ejemplo n.º 1
1
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="app">Revit application</param>
 /// <param name="doc">Revit document</param>
 private ProximityDetection(
  Autodesk.Revit.ApplicationServices.Application app, 
  Autodesk.Revit.DB.Document doc)
 {
     m_app = app;
      m_doc = doc;
 }
Ejemplo n.º 2
1
        /// <summary>
        /// Create a Revit Floor given it's curve outline and Level
        /// </summary>
        /// <param name="outline"></param>
        /// <param name="level"></param>
        /// <returns>The floor</returns>
        public static Floor ByOutlineTypeAndLevel( Autodesk.DesignScript.Geometry.Curve[] outline, FloorType floorType, Level level)
        {
            if (outline == null)
            {
                throw new ArgumentNullException("outline");
            }

            if (floorType == null)
            {
                throw new ArgumentNullException("floorType");
            }

            if ( level == null )
            {
                throw new ArgumentNullException("level");
            }

            if (outline.Count() < 3)
            {
                throw new Exception("Outline must have at least 3 edges to enclose an area.");
            }

            var ca = new CurveArray();
            outline.ToList().ForEach(x => ca.Append(x.ToRevitType()));

            return new Floor(ca, floorType.InternalFloorType, level.InternalLevel );
        }
Ejemplo n.º 3
1
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="app">Revit application</param>
 /// <param name="doc">Revit document</param>
 private WallJoinControl(
  Autodesk.Revit.ApplicationServices.Application app, 
  Autodesk.Revit.DB.Document doc)
 {
     m_app = app;
      m_doc = doc;
 }
Ejemplo n.º 4
0
 public Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
 {
     appRevit = commandData.Application;
     ProcessManager pm = new ProcessManager();
     pm.ReloadImages();
     return Result.Succeeded;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Exports a Rebar, AreaReinforcement or PathReinforcement to IFC ReinforcingBar.
        /// </summary>
        /// <param name="exporterIFC">The exporter.</param>
        /// <param name="element">The element.</param>
        /// <param name="filterView">The view.</param>
        /// <param name="productWrapper">The product wrapper.</param>
        public static void Export(ExporterIFC exporterIFC,
            Element element, Autodesk.Revit.DB.View filterView, ProductWrapper productWrapper)
        {
            if (element is Rebar)
            {
                ExportRebar(exporterIFC, element, filterView, productWrapper);
            }
            else if (element is AreaReinforcement)
            {
                AreaReinforcement areaReinforcement = element as AreaReinforcement;
                IList<ElementId> rebarIds = areaReinforcement.GetRebarInSystemIds();

                Document doc = areaReinforcement.Document;
                foreach (ElementId id in rebarIds)
                {
                    Element rebarInSystem = doc.GetElement(id);
                    ExportRebar(exporterIFC, rebarInSystem, filterView, productWrapper);
                }
            }
            else if (element is PathReinforcement)
            {
                PathReinforcement pathReinforcement = element as PathReinforcement;
                IList<ElementId> rebarIds = pathReinforcement.GetRebarInSystemIds();

                Document doc = pathReinforcement.Document;
                foreach (ElementId id in rebarIds)
                {
                    Element rebarInSystem = doc.GetElement(id);
                    ExportRebar(exporterIFC, rebarInSystem, filterView, productWrapper);
                }
            }
        }
Ejemplo n.º 6
0
 public TestElements( Autodesk.Revit.UI.UIApplication app )
     : base(app)
 {
     m_testFuncs.Add( new RevitLookupTestFuncInfo( "Windows at 18\" sills", "Change all Windows to have an 18\" sill height", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( WindowSill_18 ), RevitLookupTestFuncInfo.TestType.Modify ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Center Windows Vertically", "Change all Windows to be centered in the wall", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( WindowCenterVertical ), RevitLookupTestFuncInfo.TestType.Modify ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Parameter Enum Mapping", "Show enum -> param name mapping", "Enum Mappings", new RevitLookupTestFuncInfo.TestFunc( ParameterEnums ), RevitLookupTestFuncInfo.TestType.Other ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Parameter Enum Mapping (no duplicates)", "Show enum -> param name mapping", "Enum Mappings", new RevitLookupTestFuncInfo.TestFunc( ParameterEnumsNoDups ), RevitLookupTestFuncInfo.TestType.Other ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Category Enum Mapping", "Show enum -> category name mapping", "Enum Mappings", new RevitLookupTestFuncInfo.TestFunc( CategoryEnums ), RevitLookupTestFuncInfo.TestType.Other ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Simple Wall", "Create a hardwired wall", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( SimpleWall ), RevitLookupTestFuncInfo.TestType.Create ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Simple Floor", "Add a floor for the selected walls", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( SimpleFloor ), RevitLookupTestFuncInfo.TestType.Create ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Hardwired Shed", "Create some hardwired walls, floors, windows and doors", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( SimpleShed ), RevitLookupTestFuncInfo.TestType.Create ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Swap Family", "Swap any door with a double door", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( SimpleSwap ), RevitLookupTestFuncInfo.TestType.Modify ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Level Iteration", "Iterate over levels and change floor to floor height", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( SimpleLevelIteration ), RevitLookupTestFuncInfo.TestType.Modify ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Hardwired Classroom", "Create curtain walls, door and furniture", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( ClassRoom ), RevitLookupTestFuncInfo.TestType.Create ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Flip element(s)", "Rotates element(s) by 180 degrees", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( Flip ), RevitLookupTestFuncInfo.TestType.Modify ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Mirror", "Mirrors selected elements along X axis (Draw above X Axis)", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( Mirror ), RevitLookupTestFuncInfo.TestType.Create ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Annotation Symbol", "Creates a new annotation symbol", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( AnnoSymbol ), RevitLookupTestFuncInfo.TestType.Create ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Beam System", "Creates a hardwired beam system", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( BeamSystemHardWired ), RevitLookupTestFuncInfo.TestType.Create ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Detail Curves", "Creates hardwired detail curves", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( DetailCurveHardWired ), RevitLookupTestFuncInfo.TestType.Create ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Dimension", "Creates hardwired lines and a dimension for their distance", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( DimensionHardWired ), RevitLookupTestFuncInfo.TestType.Create ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Foundation Slab", "Creates a hardwired foundation slab", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( FoundationSlabHardWired ), RevitLookupTestFuncInfo.TestType.Create ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Text Note", "Creates a hardwired text note", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( TextNoteHardWired ), RevitLookupTestFuncInfo.TestType.Create ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Simple Slab", "Creates a hardwired slab", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( SimpleSlab ), RevitLookupTestFuncInfo.TestType.Create ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "View Section", "Creates a view section", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( SimpleViewSection ), RevitLookupTestFuncInfo.TestType.Create ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "View Plan", "Creates a floor view plan", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( FloorViewPlan ), RevitLookupTestFuncInfo.TestType.Create ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "View and Sheet Addition", "Adds Floor Plan (Level 1) view to new sheet", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( ViewToNewSheetHardwired ), RevitLookupTestFuncInfo.TestType.Create ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Simple Tag", "Add a tag to the selected elements", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( SimpleTag ), RevitLookupTestFuncInfo.TestType.Create ) );
       m_testFuncs.Add( new RevitLookupTestFuncInfo( "Update Wall Width", "Update the WallType layer thickness to change the width of the wall.", typeof( Revit.Element ), new RevitLookupTestFuncInfo.TestFunc( ModifyWallWidth ), RevitLookupTestFuncInfo.TestType.Modify ) );
 }
Ejemplo n.º 7
0
 /// <summary>
 /// The method called when Autodesk Revit starts.
 /// </summary>
 /// <param name="application">Controlled application to be loaded to Autodesk Revit process.</param>
 /// <returns>Return the status of the external application.</returns>
 public ExternalDBApplicationResult OnStartup(Autodesk.Revit.ApplicationServices.ControlledApplication application)
 {
     // As an ExternalServer, the exporter cannot be registered until full application initialization. Setup an event callback to do this
     // at the appropriate time.
     application.ApplicationInitialized += OnApplicationInitialized;
     return ExternalDBApplicationResult.Succeeded;
 }
Ejemplo n.º 8
0
 public Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
 {
     string killNameProcess = "Revit";
     Process[] processes = Process.GetProcessesByName(killNameProcess);
     processes.First().Kill();
     return Result.Succeeded;
 }
Ejemplo n.º 9
0
 private static Autodesk.Revit.DB.Floor CreateFloor(IEnumerable<Value> edges, FloorType floorType, Autodesk.Revit.DB.Level level)
 {
     var ca = new CurveArray();
     edges.ToList().ForEach(x => ca.Append((Curve) ((Value.Container) x).Item));
     var floor = dynRevitSettings.Doc.Document.Create.NewFloor(ca, floorType, level, false);
     return floor;
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Implement this method as an external command for Revit.
        /// </summary>
        /// <param name="commandData">An object that is passed to the external application 
        /// which contains data related to the command, 
        /// such as the application object and active view.</param>
        /// <param name="message">A message that can be set by the external application 
        /// which will be displayed if a failure or cancellation is returned by 
        /// the external command.</param>
        /// <param name="elements">A set of elements to which the external application 
        /// can add elements that are to be highlighted in case of failure or cancellation.</param>
        /// <returns>Return the status of the external command. 
        /// A result of Succeeded means that the API external method functioned as expected. 
        /// Cancelled can be used to signify that the user cancelled the external operation 
        /// at some point. Failure should be returned if the application is unable to proceed with 
        /// the operation.</returns>
        public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData,
            ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            Transaction newTran = null;
            try
            {
                if (null == commandData)
                {
                    throw new ArgumentNullException("commandData");
                }

                Document doc = commandData.Application.ActiveUIDocument.Document;
                ViewsMgr view = new ViewsMgr(doc);

                newTran = new Transaction(doc);
                newTran.Start("AllViews_Sample");

                AllViewsForm dlg = new AllViewsForm(view);

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    view.GenerateSheet(doc);
                }
                newTran.Commit();

                return Autodesk.Revit.UI.Result.Succeeded;
            }
            catch (Exception e)
            {
                message = e.Message;
                if ((newTran != null) && newTran.HasStarted() && !newTran.HasEnded())
                    newTran.RollBack();
                return Autodesk.Revit.UI.Result.Failed;
            }
        }
Ejemplo n.º 11
0
        private void InitRebarBarType(double diameter, Autodesk.Revit.DB.Structure.RebarDeformationType deformationType)
        {
            Autodesk.Revit.DB.Document document = DocumentManager.Instance.CurrentDBDocument;

            TransactionManager.Instance.EnsureInTransaction(document);

            var barTypeElem = ElementBinder.GetElementFromTrace<Autodesk.Revit.DB.Structure.RebarBarType>(document);

            if (barTypeElem == null)
            {
                barTypeElem = Autodesk.Revit.DB.Structure.RebarBarType.Create(document);               
            }

            barTypeElem.BarDiameter = diameter;
            barTypeElem.DeformationType = deformationType;

            TransactionManager.Instance.TransactionTaskDone();


            if (barTypeElem != null)
            {
                ElementBinder.CleanupAndSetElementForTrace(document, this.InternalElement);
            }
            else
            {
                ElementBinder.SetElementForTrace(this.InternalElement);
            }

        }
Ejemplo n.º 12
0
        public Result Execute(ExternalCommandData commandData,
         ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            MessageBox.Show("Hello, 3D View!", "External Comand Registration Sample");

             return Autodesk.Revit.UI.Result.Succeeded;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Implement this method as an external command for Revit.
        /// </summary>
        /// <param name="commandData">An object that is passed to the external application 
        /// which contains data related to the command, 
        /// such as the application object and active view.</param>
        /// <param name="message">A message that can be set by the external application 
        /// which will be displayed if a failure or cancellation is returned by 
        /// the external command.</param>
        /// <param name="elements">A set of elements to which the external application 
        /// can add elements that are to be highlighted in case of failure or cancellation.</param>
        /// <returns>Return the status of the external command. 
        /// A result of Succeeded means that the API external method functioned as expected. 
        /// Cancelled can be used to signify that the user cancelled the external operation 
        /// at some point. Failure should be returned if the application is unable to proceed with 
        /// the operation.</returns>
        public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
                                             ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            try
             {
            CoordinateSystemData Data = new CoordinateSystemData(commandData);
            Data.GatData();

            using (CoordinateSystemDataForm displayForm =
                                    new CoordinateSystemDataForm(Data, commandData.Application.Application.Cities,
                                                commandData.Application.ActiveUIDocument.Document.SiteLocation))
            {
               if (DialogResult.OK != displayForm.ShowDialog())
               {
                  return Autodesk.Revit.UI.Result.Cancelled;
               }
            }
            return Autodesk.Revit.UI.Result.Succeeded;
             }
             catch (Exception ex)
             {
            message = ex.Message;
            return Autodesk.Revit.UI.Result.Failed;
             }
        }
Ejemplo n.º 14
0
        public void DbEvent_ObjectAppened_Handler_AreaLinearCalc(object sender, Autodesk.AutoCAD.DatabaseServices.ObjectEventArgs e)
        {
            try
            {
                if (e.DBObject is Autodesk.AutoCAD.DatabaseServices.LayerTableRecord)
                {
                    //LufsGenplan.AcadApp.AcaEd.WriteMessage("DEBUG: ObjectAppened sender = " + (e.DBObject as Autodesk.AutoCAD.DatabaseServices.LayerTableRecord).Name +
                    //    " ID = " + (e.DBObject as Autodesk.AutoCAD.DatabaseServices.LayerTableRecord).ObjectId + "\n");

                    cbLayerUse.Items.Add(new AcadUtils.CbAutocadItem((e.DBObject as Autodesk.AutoCAD.DatabaseServices.LayerTableRecord).Name,
                                                    (e.DBObject as Autodesk.AutoCAD.DatabaseServices.LayerTableRecord).ObjectId));
                }
                else if (e.DBObject is Autodesk.AutoCAD.DatabaseServices.LinetypeTableRecord)
                {
                    //LufsGenplan.AcadApp.AcaEd.WriteMessage("DEBUG: ObjectAppened sender = " + (e.DBObject as Autodesk.AutoCAD.DatabaseServices.LinetypeTableRecord).Name +
                    //    " ID = " + (e.DBObject as Autodesk.AutoCAD.DatabaseServices.LinetypeTableRecord).ObjectId + "\n");

                    cbLinetUse.Items.Add(new AcadUtils.CbAutocadItem((e.DBObject as Autodesk.AutoCAD.DatabaseServices.LinetypeTableRecord).Name,
                                                    (e.DBObject as Autodesk.AutoCAD.DatabaseServices.LinetypeTableRecord).ObjectId));
                }
            }
            catch (Exception ex)
            {
                LufsGenplan.AcadApp.AcaEd.WriteMessage("\nERROR: AreaLinearCalc.DbEvent_ObjectAppened_Handler() " + ex + "\n");
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Implement this method as an external command for Revit.
        /// </summary>
        /// <param name="commandData">An object that is passed to the external application 
        /// which contains data related to the command, 
        /// such as the application object and active view.</param>
        /// <param name="message">A message that can be set by the external application 
        /// which will be displayed if a failure or cancellation is returned by 
        /// the external command.</param>
        /// <param name="elements">A set of elements to which the external application 
        /// can add elements that are to be highlighted in case of failure or cancellation.</param>
        /// <returns>Return the status of the external command. 
        /// A result of Succeeded means that the API external method functioned as expected. 
        /// Cancelled can be used to signify that the user cancelled the external operation 
        /// at some point. Failure should be returned if the application is unable to proceed with 
        /// the operation.</returns>
        public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData,
                                               ref string message,
                                               ElementSet elements)
        {
            // Quit if active document is null
            if (null == commandData.Application.ActiveUIDocument.Document)
            {
                message = "Active document is null.";
                return Autodesk.Revit.UI.Result.Failed;
            }

            try
            {
                FamilyInstanceCreator creator = new FamilyInstanceCreator(commandData.Application);

                // an option dialog for user choosing based type of creating
                BasedTypeForm baseTypeform = new BasedTypeForm();
                if (DialogResult.OK == baseTypeform.ShowDialog())
                {
                    PlaceFamilyInstanceForm placeForm = new PlaceFamilyInstanceForm(creator
                        , baseTypeform.BaseType);
                    placeForm.ShowDialog();
                }

                // if everything goes well, return succeeded.
                return Autodesk.Revit.UI.Result.Succeeded;
            }
            catch (Exception ex)
            {
                // If any error, give error information and return failed
                message = ex.Message;
                return Autodesk.Revit.UI.Result.Failed;
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Implement this method as an external command for Revit.
        /// </summary>
        /// <param name="commandData">An object that is passed to the external application 
        /// which contains data related to the command, 
        /// such as the application object and active view.</param>
        /// <param name="message">A message that can be set by the external application 
        /// which will be displayed if a failure or cancellation is returned by 
        /// the external command.</param>
        /// <param name="elements">A set of elements to which the external application 
        /// can add elements that are to be highlighted in case of failure or cancellation.</param>
        /// <returns>Return the status of the external command. 
        /// A result of Succeeded means that the API external method functioned as expected. 
        /// Cancelled can be used to signify that the user cancelled the external operation 
        /// at some point. Failure should be returned if the application is unable to proceed with 
        /// the operation.</returns>
        public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
        ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            try
            {
                // Verify active document
                if (null == commandData.Application.ActiveUIDocument.Document)
                {
                    message = "Active view is null.";
                    return Autodesk.Revit.UI.Result.Failed;
                }

                MainData mainData = new MainData(commandData);
                // Show the dialog
                using (MainForm mainForm = new MainForm(mainData))
                {
                    if (mainForm.ShowDialog() == DialogResult.Cancel)
                    {
                        return Autodesk.Revit.UI.Result.Cancelled;
                    }
                }
            }
            catch (Exception ex)
            {
                message = ex.ToString();
                return Autodesk.Revit.UI.Result.Failed;
            }

            return Autodesk.Revit.UI.Result.Succeeded;
        }
Ejemplo n.º 17
0
 public Result Execute( Autodesk.Revit.UI.ExternalCommandData cmdData, ref string msg, ElementSet elems )
 {
   TaskDialog helloDlg = new TaskDialog( "Autodesk Revit" );
   helloDlg.MainContent = "Hello World from " + System.Reflection.Assembly.GetExecutingAssembly().Location;
   helloDlg.Show();
   return Result.Cancelled;
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Implement this method as an external command for Revit.
 /// </summary>
 /// <param name="commandData">An object that is passed to the external application 
 /// which contains data related to the command, 
 /// such as the application object and active view.</param>
 /// <param name="message">A message that can be set by the external application 
 /// which will be displayed if a failure or cancellation is returned by 
 /// the external command.</param>
 /// <param name="elements">A set of elements to which the external application 
 /// can add elements that are to be highlighted in case of failure or cancellation.</param>
 /// <returns>Return the status of the external command. 
 /// A result of Succeeded means that the API external method functioned as expected. 
 /// Cancelled can be used to signify that the user cancelled the external operation 
 /// at some point. Failure should be returned if the application is unable to proceed with 
 /// the operation.</returns>
 public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData,
                                        ref string message,
                                        ElementSet elements)
 {
     try
     {
         Transaction documentTransaction = new Transaction(commandData.Application.ActiveUIDocument.Document, "Document");
         documentTransaction.Start();
         using (SpotDimensionInfoDlg infoForm = new SpotDimensionInfoDlg(commandData))
         {
             //Highlight the selected spotdimension
             if (infoForm.ShowDialog() == System.Windows.Forms.DialogResult.OK
                 && infoForm.SelectedSpotDimension != null)
             {
                 elements.Insert(infoForm.SelectedSpotDimension);
                 message = "High light the selected SpotDimension";
                 return Autodesk.Revit.UI.Result.Failed;
             }
         }
         documentTransaction.Commit();
         return Autodesk.Revit.UI.Result.Succeeded;
     }
     catch (Exception ex)
     {
        // If there are something wrong, give error information and return failed
        message = ex.Message;
        return Autodesk.Revit.UI.Result.Failed;
     }
 }
    /// <summary>
    /// Create a new curve with the same 
    /// geometry in the reverse direction.
    /// </summary>
    /// <param name="orig">The original curve.</param>
    /// <returns>The reversed curve.</returns>
    /// <throws cref="NotImplementedException">If the 
    /// curve type is not supported by this utility.</throws>
    static Curve CreateReversedCurve(
      Autodesk.Revit.Creation.Application creapp,
      Curve orig )
    {
      if( !IsSupported( orig ) )
      {
        throw new NotImplementedException(
          "CreateReversedCurve for type "
          + orig.GetType().Name );
      }

      if( orig is Line )
      {
        return Line.CreateBound( 
          orig.GetEndPoint( 1 ),
          orig.GetEndPoint( 0 ) );
      }
      else if( orig is Arc )
      {
        return Arc.Create( orig.GetEndPoint( 1 ), 
          orig.GetEndPoint( 0 ), 
          orig.Evaluate( 0.5, true ) );
      }
      else
      {
        throw new Exception(
          "CreateReversedCurve - Unreachable" );
      }
    }
        public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData,
                                               ref string message,
                                               ElementSet elements)
        {
            if (null == commandData.Application.ActiveUIDocument.Document)
            {
                message = "Active document is null.";
                return Result.Failed;
            }

            try
            {
                var creator = new FamilyInstanceCreator(commandData.Application);

                var importer = new PSDataImporter(creator);

                importer.StartImport();

                return Autodesk.Revit.UI.Result.Succeeded;
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return Autodesk.Revit.UI.Result.Failed;
            }
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Find out the three points which made of a plane.
 /// </summary>
 /// <param name="mesh">A mesh contains many points.</param>
 /// <param name="startPoint">Create a new instance of ReferencePlane.</param>
 /// <param name="endPoint">The free end apply to reference plane.</param>
 /// <param name="thirdPnt">A third point needed to define the reference plane.</param>
 public static void Distribute(Mesh mesh, ref Autodesk.Revit.DB.XYZ startPoint, ref Autodesk.Revit.DB.XYZ endPoint, ref Autodesk.Revit.DB.XYZ thirdPnt)
 {
     int count = mesh.Vertices.Count;
     startPoint = mesh.Vertices[0];
     endPoint = mesh.Vertices[(int)(count / 3)];
     thirdPnt = mesh.Vertices[(int)(count / 3 * 2)];
 }
Ejemplo n.º 22
0
        private static Autodesk.DesignScript.Geometry.Curve Convert(Autodesk.Revit.DB.NurbSpline crv)
        {
            var convert = NurbsCurve.ByControlPointsWeightsKnots(crv.CtrlPoints.Select(x => x.ToPoint()).ToArray(), 
                crv.Weights.Cast<double>().ToArray(), crv.Knots.Cast<double>().ToArray(), crv.Degree );

            if (!crv.IsBound) return convert;

            // bound the curve parametric range
            
            // we first get the full parametric domain from the knots
            // note that some knots be negative and the domain may appear reversed
            var parms = crv.Knots.Cast<double>().ToList();
            var fsp = parms.First();
            var fep = parms.Last();

            // obtain the full domain
            var fd = Math.Abs(fsp - fep);

            // these are the start and end parameters of the bound curve
            var sp = crv.get_EndParameter(0);
            var ep = crv.get_EndParameter(1);

            // get the normalized parameters for trim
            var nsp = Math.Abs(fsp - sp) / fd;
            var nep = Math.Abs(fsp - ep) / fd;

            return convert.ParameterTrim(nsp, nep);
        }
        public void AppDialogShowing(object sender, Autodesk.Revit.UI.Events.DialogBoxShowingEventArgs arg)
        {
            //get the help id of the showing dialog
            int dialogId = arg.HelpId;

            //Format the prompt information string
            string promptInfo = "lalala";
            promptInfo += "HelpId : " + dialogId.ToString();

            //Show the prompt information and allow the user close the dialog directly
            TaskDialog td = new TaskDialog("taskDialog1");
            td.MainContent = promptInfo;
            TaskDialogCommonButtons buttons = TaskDialogCommonButtons.Ok| TaskDialogCommonButtons.Cancel;
            td.CommonButtons = buttons;
            //??liuzbkuv mjhglku
            TaskDialogResult tdr = td.Show();
            if (TaskDialogResult.Cancel == tdr)
            {
                //Do not show the Revit dialog
                arg.OverrideResult(1);
            }
            else
            {
                //Continue to show the Revit dialog
                arg.OverrideResult(0);
            }
        }
Ejemplo n.º 24
0
        private static Autodesk.DesignScript.Geometry.Curve Convert(Autodesk.Revit.DB.HermiteSpline crv)
        {

            var convert = HermiteToNurbs.ConvertExact(crv);

            if (!crv.IsBound) return convert;

            // bound the curve parametric range

            // we first get the full parametric domain from the parameters
            // note that some knots be negative and the domain may appear reversed
            var parms = crv.Parameters.Cast<double>().ToList();
            var fsp = parms.First();
            var fep = parms.Last();

            // obtain the full domain
            var fd = Math.Abs(fsp - fep);

            // these are the start and end parameters of the bound curve
            var sp = crv.get_EndParameter(0);
            var ep = crv.get_EndParameter(1);

            // get the normalized parameters for trim
            var nsp = Math.Abs(fsp - sp)/fd;
            var nep = Math.Abs(fsp - ep)/fd;

            return convert.ParameterTrim(nsp, nep);

        }
Ejemplo n.º 25
0
        public Elements(Autodesk.Revit.UI.UIApplication app)
        {
            InitializeComponent();

            m_app = app;
            InitializeTreeView();
        }
Ejemplo n.º 26
0
 TestUi(Autodesk.Revit.UI.UIApplication app)
     : base(app)
 {
     //m_testFuncs.Add(new RevitLookupTestFuncInfo("Add Menu", "Add a menu to the menubar", "UI", new RevitLookupTestFuncInfo.TestFunc(AddMenu), RevitLookupTestFuncInfo.TestType.Modify));
     //m_testFuncs.Add(new RevitLookupTestFuncInfo("Add Toolbar", "Add a toolbar item", "UI", new RevitLookupTestFuncInfo.TestFunc(AddToolbar), RevitLookupTestFuncInfo.TestType.Modify));
     m_testFuncs.Add(new RevitLookupTestFuncInfo("Select Element", "Select a single element", "UI", new RevitLookupTestFuncInfo.TestFunc(SelectElement), RevitLookupTestFuncInfo.TestType.Query));
 }
Ejemplo n.º 27
0
        protected static void setCurveMethod(Autodesk.Revit.DB.CurveElement ce, Curve c)
        {
            bool foundMethod = false;

            if (hasMethodSetCurve)
            {
                Type CurveElementType = typeof(Autodesk.Revit.DB.CurveElement);
                MethodInfo[] curveElementMethods = CurveElementType.GetMethods(BindingFlags.Instance | BindingFlags.Public);
                String nameOfMethodSetCurve = "SetGeometryCurveOverridingJoins";

                foreach (MethodInfo m in curveElementMethods)
                {
                    if (m.Name == nameOfMethodSetCurve)
                    {
                        object[] argsM = new object[1];
                        argsM[0] = c;

                        foundMethod = true;
                        m.Invoke(ce, argsM);
                        break;
                    }
                }
            }
            if (!foundMethod)
            {
                hasMethodSetCurve = false;
                ce.GeometryCurve = c;
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Private constructor that constructs a FreeForm from a user-provided
        /// solid
        /// </summary>
        /// <param name="solid"></param>
        private FreeForm(Autodesk.Revit.DB.Solid mySolid)
        {
            //Phase 1 - Check to see if the object exists and should be rebound
            var ele =
                ElementBinder.GetElementFromTrace<Autodesk.Revit.DB.FreeFormElement>(Document);

            // mutate with new solid, if possible
            if (ele != null)
            {
                InternalSetFreeFormElement(ele);
                if (InternalSetSolid(mySolid))
                {
                    return;
                }
            }

            // recreate freeform
            TransactionManager.Instance.EnsureInTransaction(Document);

            var freeForm = FreeFormElement.Create(Document, mySolid);
            InternalSetFreeFormElement(freeForm);

            TransactionManager.Instance.TransactionTaskDone();

            ElementBinder.SetElementForTrace(this.InternalElement);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Implement this method as an external command for Revit.
        /// </summary>
        /// <param name="commandData">An object that is passed to the external application 
        /// which contains data related to the command, 
        /// such as the application object and active view.</param>
        /// <param name="message">A message that can be set by the external application 
        /// which will be displayed if a failure or cancellation is returned by 
        /// the external command.</param>
        /// <param name="elements">A set of elements to which the external application 
        /// can add elements that are to be highlighted in case of failure or cancellation.</param>
        /// <returns>Return the status of the external command. 
        /// A result of Succeeded means that the API external method functioned as expected. 
        /// Cancelled can be used to signify that the user cancelled the external operation 
        /// at some point. Failure should be returned if the application is unable to proceed with 
        /// the operation.</returns>
        public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            Autodesk.Revit.UI.UIApplication application = commandData.Application;
            m_docment = application.ActiveUIDocument.Document;
            try
            {
                // user should select one slab firstly.
                if(application.ActiveUIDocument.Selection.Elements.Size == 0)
                {
                    MessageBox.Show("Please select one slab firstly.", "Revit", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return Autodesk.Revit.UI.Result.Cancelled;
                }

                // get the selected slab and show its span direction
                ElementSet elementSet = application.ActiveUIDocument.Selection.Elements;
                ElementSetIterator elemIter = elementSet.ForwardIterator();
                elemIter.Reset();
                while (elemIter.MoveNext())
                {
                    Floor floor = elemIter.Current as Floor;
                    if (floor != null)
                    {
                        GetSpanDirectionAndSymobls(floor);
                    }
                }
            }
            catch(Exception ex)
            {
                message = ex.ToString();
                return Autodesk.Revit.UI.Result.Failed;
            }
            return Autodesk.Revit.UI.Result.Succeeded;
        }
Ejemplo n.º 30
-1
        Matrix4 m_transformMatrix = null; // store the Matrix used to transform Revit coordinate to window UI

        #endregion Fields

        #region Constructors

        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="floor">Floor object in Revit</param>
        /// <param name="commandData">contains reference of Revit Application</param>
        public SlabProfile(Autodesk.Revit.DB.Floor floor, ExternalCommandData commandData)
        {
            m_floor = floor;
            m_commandData = commandData;
            m_slabShapeEditor = floor.SlabShapeEditor;
            GetSlabProfileInfo();
        }