示例#1
0
        public void Execute(Autodesk.Revit.DB.UpdaterData data)
        {
            Document doc = data.GetDocument();

            try {
                Action <Document, ElementId> setElev = (d, id) => {
                    FamilyInstance fi = d.GetElement(id) as FamilyInstance;
                    SetBottomElev(fi);
                };

                foreach (ElementId addedElemId in data.GetAddedElementIds())
                {
                    setElev(doc, addedElemId);
                }

                foreach (ElementId changedElemId in data.GetModifiedElementIds())
                {
                    setElev(doc, changedElemId);
                }
            }
            catch (Exception ex) {
                Autodesk.Revit.UI.TaskDialog.Show("Exception", (string.Format
                                                                    ("{0}\n{1}", ex.Message, ex.StackTrace)));
            }
        }
示例#2
0
 /// <summary>
 /// Set Geometry Curve
 /// </summary>
 public void SetCurve(Autodesk.DesignScript.Geometry.Curve curve)
 {
     Autodesk.Revit.DB.Document document = DocumentManager.Instance.CurrentDBDocument;
     TransactionManager.Instance.EnsureInTransaction(document);
     this.InternalCurveElement.SetGeometryCurve(curve.ToRevitType(), true);
     TransactionManager.Instance.TransactionTaskDone();
 }
示例#3
0
        /// <summary>
        /// Init a new detail curve from curve
        /// </summary>
        /// <param name="view"></param>
        /// <param name="curve"></param>
        private void Init(Autodesk.Revit.DB.View view, Autodesk.Revit.DB.Curve curve)
        {
            // Open Transaction and get document
            Autodesk.Revit.DB.Document document = DocumentManager.Instance.CurrentDBDocument;
            TransactionManager.Instance.EnsureInTransaction(document);

            // Get exsiting element
            var element = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.DetailCurve>(document);

            if (element == null)
            {
                if (document.IsFamilyDocument)
                {
                    element = document.FamilyCreate.NewDetailCurve(view, curve);
                }
                else
                {
                    element = document.Create.NewDetailCurve(view, curve);
                }
            }
            else
            {
                element.SetGeometryCurve(curve, true);
            }

            InternalSetCurveElement(element);

            // Set transaction task done & element for trace
            TransactionManager.Instance.TransactionTaskDone();
            ElementBinder.SetElementForTrace(this.InternalElement);
        }
 /// <summary>
 /// Symbol Selection Form Class Instance and Initializer
 /// </summary>
 /// <param name="exEvent">External event which implemented when raise calling</param>
 /// <param name="handler">Revit API Externl Event Handler</param>
 /// <param name="m_doc">Active Revit Document</param>
 public SymbolSelectionForm(ExternalEvent exEvent, CreateBeamExternalEventHandler handler, Document m_doc)
 {
     InitializeComponent();
     m_Handler = handler;
     m_ExEvent = exEvent;
     doc       = m_doc;
 }
示例#5
0
 private static IList <Autodesk.Revit.DB.ViewSheetSet> GetViewSheetSet(Document doc)
 {
     return(new Collector(doc)
            .OfClass(typeof(Autodesk.Revit.DB.ViewSheetSet))
            .Cast <Autodesk.Revit.DB.ViewSheetSet>()
            .ToList());
 }
示例#6
0
        public static Dictionary <string, object> ByDirection(global::Revit.Elements.Wall hostingElement)
        {
            //obtains the current document for later use
            Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument;

            List <global::Revit.Elements.Mullion> horizontal = new List <Mullion>();
            List <global::Revit.Elements.Mullion> vertical   = new List <Mullion>();

            var mullions = Mullion.ByElement(hostingElement);

            foreach (var mullion in mullions)
            {
                if (mullion.LocationCurve.StartPoint.Z == mullion.LocationCurve.EndPoint.Z)
                {
                    horizontal.Add(mullion);
                }
                else
                {
                    vertical.Add(mullion);
                }
            }

            var orderedHorizontal = horizontal.OrderBy(m => m.LocationCurve.StartPoint.Z).ThenBy(m => m.LocationCurve.StartPoint.X);
            var orderedVertical   = vertical.OrderBy(m => m.LocationCurve.StartPoint.X).ThenBy(m => m.LocationCurve.StartPoint.Z);


            var outInfo = new Dictionary <string, object>
            {
                { "horizontal", orderedHorizontal },
                { "vertical", orderedVertical }
            };

            return(outInfo);
        }
示例#7
0
        public WorksheetSelectForm(List <WorksheetObject> objs, ManageExcelLinksForm parent, Autodesk.Revit.DB.Document doc)
        {
            _objs      = objs;
            formParent = parent;
            _doc       = doc;
            InitializeComponent();

            int counter = 0;

            foreach (WorksheetObject wo in _objs)
            {
                if (wo.Image == null)
                {
                    counter++;
                }
            }

            if (counter == _objs.Count)
            {
                this.Height             = 160;
                previewImage.Visibility = System.Windows.Visibility.Hidden;
            }
            linkCheckBox.IsChecked       = true;
            linkCheckBox.IsEnabled       = false;
            wsComboBox.ItemsSource       = _objs;
            wsComboBox.DisplayMemberPath = "Name";
            wsComboBox.SelectedIndex     = 0;
        }
示例#8
0
 public FrontForm(Autodesk.Revit.UI.UIDocument document, IList <Autodesk.Revit.DB.ViewSheet> sheets)
 {
     uidoc      = document;
     doc        = uidoc.Document;
     viewsheets = sheets;
     InitializeComponent();
 }
示例#9
0
        private string suggestModelName()
        {
            Autodesk.Revit.DB.Document doc = cbSelectedModel.SelectedItem as Autodesk.Revit.DB.Document;

            if (doc != null)
            {
                string filename = Path.GetFileNameWithoutExtension(doc.PathName);
                if (doc.IsWorkshared && (!doc.IsDetached))
                {
                    try
                    {
                        var    mp          = doc.GetWorksharingCentralModelPath();
                        string centralPath = Autodesk.Revit.DB.ModelPathUtils.ConvertModelPathToUserVisiblePath(mp);
                        if ((mp.ServerPath == false) && System.IO.Path.IsPathRooted(centralPath))
                        {
                            string folder   = Path.GetDirectoryName(centralPath);
                            string baseName = Path.GetFileNameWithoutExtension(centralPath);
                            filename = Path.Combine(folder, "Snapshots", baseName + "_" + DateTime.Now.ToString("yyyyMMdd_hhmm") + ".sdb");
                        }
                    }
                    catch { }
                }
                else
                {
                    filename = Path.Combine(Path.GetDirectoryName(doc.PathName), filename + "_" + DateTime.Now.ToString("yyyyMMdd_hhmm") + ".sdb");
                }



                return(filename);
            }

            return(string.Empty);
        }
示例#10
0
        Enumerable(string label, IEnumerable val, Autodesk.Revit.DB.Document doc)
            : base(label)
        {
            m_val = val;

            // iterate over the collection and put them in an ArrayList so we can pass on
            // to our Form
            if (m_val != null)
            {
                IEnumerator iter = m_val.GetEnumerator();
                while (iter.MoveNext())
                {
                    var elementId = iter.Current as Autodesk.Revit.DB.ElementId;

                    if (elementId != null && doc != null)
                    {
                        m_objs.Add(doc.GetElement(elementId)); // it's more useful for user to view element rather than element id.
                    }
                    else
                    {
                        m_objs.Add(iter.Current);
                    }
                }
            }
        }
示例#11
0
        public frmSheetMaker(Autodesk.Revit.DB.Document curDoc)
        {
            // The Me.InitializeComponent call is required for Windows Forms designer support.
            this.InitializeComponent();

            //
            // TODO : Add constructor code after InitializeComponents
            List <string> curTblocks = null;

            //get titleblocks in current model and output to combo box
            curTblocks = mFunctions.getAllTitleblockNames(curDoc);
            foreach (string tblock in curTblocks)
            {
                this.cmbTitleblock.Items.Add(tblock);
            }

            //set combo box to first titleblock
            this.cmbTitleblock.SelectedIndex = 0;

            //set sheet type to regular sheet
            this.cmbSheetType.SelectedIndex = 0;

            //set btnCreateCSV tooltip
            this.ttCreateCSV.ToolTipTitle = "Create Default CSV File";
        }
示例#12
0
        /// <summary>
        /// Set Global Parameter Value
        /// </summary>
        /// <param name="parameter"></param>
        /// <param name="value"></param>
        public static void SetValue(GlobalParameter parameter, object value)
        {
            if (!parameter.InternalGlobalParameter.IsReporting)
            {
                // get document and open transaction
                Autodesk.Revit.DB.Document document = Application.Document.Current.InternalDocument;
                TransactionManager.Instance.EnsureInTransaction(document);

                if (value == null)
                {
                    parameter.InternalGlobalParameter.SetValue(
                        new Autodesk.Revit.DB.NullParameterValue());
                }
                else if (value.GetType() == typeof(int))
                {
                    parameter.InternalGlobalParameter.SetValue(
                        new Autodesk.Revit.DB.IntegerParameterValue((int)value));
                }
                else if (value.GetType() == typeof(string))
                {
                    parameter.InternalGlobalParameter.SetValue(
                        new Autodesk.Revit.DB.StringParameterValue((string)value));
                }
                else if (value.GetType() == typeof(double))
                {
                    var valueToSet = (double)value * UnitConverter.DynamoToHostFactor(parameter.InternalGlobalParameter.GetDefinition().UnitType);

                    parameter.InternalGlobalParameter.SetValue(
                        new Autodesk.Revit.DB.DoubleParameterValue(valueToSet));
                }

                TransactionManager.Instance.TransactionTaskDone();
            }
        }
示例#13
0
        /// <summary>
        /// If run from Revit, returns Revit version
        /// </summary>
        /// <returns></returns>
        internal static string GetRevitData()
        {
            Autodesk.Revit.DB.Document doc = RevitServices.Persistence.DocumentManager.Instance.CurrentDBDocument;
            Autodesk.Revit.UI.UIApplication uiapp = RevitServices.Persistence.DocumentManager.Instance.CurrentUIApplication;
            Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;

            return String.Format("Revit Build: {0}", app.SubVersionNumber);
        }
示例#14
0
        public MainForm(Autodesk.Revit.DB.Document current)
        {
            InitializeComponent();
            tabControl1.Appearance = TabAppearance.FlatButtons; tabControl1.ItemSize = new Size(0, 1); tabControl1.SizeMode = TabSizeMode.Fixed;

            _currentDoc = current;
            initialRender();
        }
示例#15
0
 /// <summary>
 /// This will attempt to set the leader elbow position of the tag.
 /// </summary>
 /// <param name="tag">The tag to set leader elbow position of.</param>
 /// <param name="location">The new location for the leader elbow.</param>
 /// <search>
 /// Tag, Tag.Location
 /// </search>
 public static void SetLeaderElbowPosition(global::Revit.Elements.Tag tag, Point location)
 {
     Autodesk.Revit.DB.Document       doc         = DocumentManager.Instance.CurrentDBDocument;
     Autodesk.Revit.DB.IndependentTag internalTag = (Autodesk.Revit.DB.IndependentTag)tag.InternalElement;
     TransactionManager.Instance.EnsureInTransaction(doc);
     internalTag.LeaderElbow = location.ToXyz();
     TransactionManager.Instance.TransactionTaskDone();
 }
示例#16
0
        public FormSelectCategories(Autodesk.Revit.DB.Document doc, List <MyCategory> categories)
        {
            InitializeComponent();

            foreach (MyCategory mycat in categories)
            {
                checkedListBox1.Items.Add(mycat, CheckState.Checked);
            }
        }
示例#17
0
        public PrintWnd(RvtDocument doc)
        {
            InitializeComponent();
            IList <ViewSheetSet> viewSheetSets =
                SheetSelectorCmd.GetViewSheetSets(doc);

            this.lb_view_sets.ItemsSource
                = viewSheetSets;
        }
示例#18
0
        internal ImportedDWGForm(Autodesk.Revit.UI.UIDocument uidoc, List <ImportedDWG> dwg)
        {
            InitializeComponent();

            this.uidoc   = uidoc;
            this.doc     = uidoc.Document;
            this.dwgList = dwg;

            InitializeList();
        }
示例#19
0
        public static List <global::Revit.Elements.Element> UGrids(Autodesk.Revit.DB.CurtainGrid curtainGrid)
        {
            Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument;
            //gets U Grid Ids
            ICollection <Autodesk.Revit.DB.ElementId> uGridIds = curtainGrid.GetUGridLineIds();
            //make new list for U grids
            List <global::Revit.Elements.Element> uGrids = new List <global::Revit.Elements.Element>(uGridIds.Select(id => doc.GetElement(id).ToDSType(true)).ToArray());

            return(uGrids);
        }
示例#20
0
 public Apartment(Document doc, string number)
 {
     m_doc       = doc;
     m_number    = number;
     m_iRoomId   = new List <int>();
     m_totalArea = 0;
     m_totalAreaSansPartitions = 0;
     m_totalAreaSansWetAreas   = 0;
     m_roomAreas = new List <double>();
 }
 public void AddDocument(string documentGuid, Document document)
 {
     if (Documents.ContainsKey(documentGuid))
     {
         return;
     }
     {
         Documents[documentGuid] = document;
     }
 }
        public static object DbDocumentToOrchidDocument(Autodesk.Revit.DB.Document document)
        {
            //find the orchid assembly
            var  assembly = AppDomain.CurrentDomain.GetAssemblies().First(a => a.FullName.Contains("OrchidRB") && !a.FullName.Contains("customization"));
            Type type     = assembly.GetType("Orchid.RevitProject.Common.Document");

            //find the path of the document
            return(type.InvokeMember("BackgroundOpen", BindingFlags.Default | BindingFlags.InvokeMethod, null, null,
                                     new object[] { document.PathName }));
        }
示例#23
0
        public ExportSelectionForm(IList <Autodesk.Revit.DB.Document> docs, Autodesk.Revit.DB.Document current)
        {
            InitializeComponent();

            cbSelectedModel.DataSource = docs.ToArray();
            cbSelectedModel.Refresh();

            cbSelectedModel.SelectedItem = current;

            this.Text += " " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
        }
示例#24
0
        public DRInterface(Autodesk.Revit.UI.UIDocument uidoc, Command cmd)
        {
            this.uidoc = uidoc;
            this.doc   = uidoc.Document;
            this.cmd   = cmd;

            InitializeComponent();
            InitializeUI();

            doorTypes = new List <string>();
        }
示例#25
0
 /// <summary>
 /// This method does most of the work of the IPerformanceAdviserRule implementation.
 /// It is called by PerformanceAdviser.
 /// It examines the element passed to it (which was previously filtered by the filter
 /// returned by GetElementFilter() (see below)).  After checking to make sure that the
 /// element is an instance, it checks the FacingFlipped property of the element.
 ///
 /// If it is flipped, it adds the instance to a list to be used later.
 /// </summary>
 /// <param name="document">The active document</param>
 /// <param name="element">The current element being checked</param>
 public void ExecuteElementCheck(Autodesk.Revit.DB.Document document, Autodesk.Revit.DB.Element element)
 {
     if ((element is Autodesk.Revit.DB.FamilyInstance))
     {
         Autodesk.Revit.DB.FamilyInstance doorCurrent = element as Autodesk.Revit.DB.FamilyInstance;
         if (doorCurrent.FacingFlipped)
         {
             m_FlippedDoors.Add(doorCurrent.Id);
         }
     }
 }
示例#26
0
        /// <summary>
        /// Try to found an open <see cref="Autodesk.Revit.UI.UIDocument"/> that is referencing the specified <see cref="Autodesk.Revit.DB.Document"/>.
        /// </summary>
        /// <param name="document"></param>
        /// <param name="uiDocument"></param>
        /// <returns>true on succes.</returns>
        public static bool TryGetOpenUIDocument(this Autodesk.Revit.DB.Document document, out Autodesk.Revit.UI.UIDocument uiDocument)
        {
            uiDocument = new Autodesk.Revit.UI.UIDocument(document);
            if (uiDocument.GetOpenUIViews().Count == 0)
            {
                uiDocument.Dispose();
                uiDocument = default;
                return(false);
            }

            return(true);
        }
示例#27
0
 private void ImportAllSelectedParamsToTargetFile(Autodesk.Revit.DB.Document targetDoc)
 {
     // --- rebuild the insertlist
     //todo - put back
     //foreach (DataGridViewRow oRow in ParentFormParameterJerk. DataGridViewFromFile.SelectedRows)
     //{
     //    // If oRow.Selected Then
     //    ClassOneParamAssociation thisParameterData = oRow.DataBoundItem as ClassOneParamAssociation;
     //    thisParameterData.createSharedParameter(ParentFormParameterJerk.CheckBoxDeleteIfExists.Checked, targetDoc);
     //    // End If
     //}
 }
示例#28
0
        public static List <global::Revit.Elements.Element> Members(global::Revit.Elements.Element BeamSystem)
        {
            Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument;
            //convert input beam system to internal version
            Autodesk.Revit.DB.BeamSystem beamSystemInternal = (Autodesk.Revit.DB.BeamSystem)BeamSystem.InternalElement;
            //get beam ids from system
            var beamIdCollection = beamSystemInternal.GetBeamIds();
            //create list for the elements and add the beams to that list.
            List <global::Revit.Elements.Element> members = new List <global::Revit.Elements.Element>(beamIdCollection.Select(id => doc.GetElement(id).ToDSType(true)).ToArray());

            return(members);
        }
示例#29
0
 /// <summary>
 /// Does some preliminary work before executing tests on elements.  In this case,
 /// we instantiate a list of FamilyInstances representing all doors that are flipped.
 /// </summary>
 /// <param name="document">The document being checked</param>
 public void InitCheck(Autodesk.Revit.DB.Document document)
 {
     if (m_FlippedDoors == null)
     {
         m_FlippedDoors = new List <Autodesk.Revit.DB.ElementId>();
     }
     else
     {
         m_FlippedDoors.Clear();
     }
     return;
 }
示例#30
0
        /// <summary>
        /// This node will retrieve the room that a tag is tagging.
        /// </summary>
        /// <param name="roomTag">The room tag to retrieve elements from.</param>
        /// <returns name="room">The room that is tagged.</returns>
        /// <search>
        /// roomtag, rhythm
        /// </search>
        public static List <global::Revit.Elements.Element> TaggedRoom(List <global::Revit.Elements.Element> roomTag)
        {
            Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument;
            //convert room tags to internal representations
            List <global::Autodesk.Revit.DB.Architecture.RoomTag> internalRoomTagList =
                new List <global::Autodesk.Revit.DB.Architecture.RoomTag>(roomTag.Select(tag => (Autodesk.Revit.DB.Architecture.RoomTag)tag.InternalElement));
            //get the tagged rooms
            List <global::Revit.Elements.Element> taggedRoomList =
                new List <global::Revit.Elements.Element>(internalRoomTagList.Select(tag => doc.GetElement(tag.TaggedLocalRoomId).ToDSType(true)));

            return(taggedRoomList);
        }
示例#31
0
 internal Document(Autodesk.Revit.DB.Document currentDBDocument)
 {
     InternalDocument = currentDBDocument;
 }