示例#1
0
        private void performShow()
        {
            try
            {
                Autodesk.Revit.DB.ElementId toShow = Autodesk.Revit.DB.ElementId.InvalidElementId;

                Models.ClearWidth cw = treeView1.SelectedNode.Tag as Models.ClearWidth;
                if (cw != null)
                {
                    toShow = cw.Id;
                }

                Models.Node node = treeView1.SelectedNode.Tag as Models.Node;
                if (node != null)
                {
                    toShow = node.RoomId;
                }

                if (toShow == Autodesk.Revit.DB.ElementId.InvalidElementId)
                {
                    return;
                }
                _controller.Show(toShow);
            }
            catch (Exception ex)
            {
                Autodesk.Revit.UI.TaskDialog td = new Autodesk.Revit.UI.TaskDialog("Error");
                td.MainContent     = "Unexpected error: " + ex.GetType().Name + ":  " + ex.Message;
                td.ExpandedContent = ex.StackTrace;
                td.Show();
            }
        }
        public static bool TryGetUserString(this GeometryBase geometry, string key, out Autodesk.Revit.DB.ElementId value, Autodesk.Revit.DB.ElementId def)
        {
            if (geometry.TryGetUserString(key, out int id, def.IntegerValue))
            {
                value = new Autodesk.Revit.DB.ElementId(id);
                return(true);
            }

            value = def;
            return(false);
        }
        public static bool GetUserElementId(this GeometryBase geometry, string key, out Autodesk.Revit.DB.ElementId value, Autodesk.Revit.DB.ElementId def)
        {
            if (geometry.GetUserInteger(key, out var idx))
            {
                value = new Autodesk.Revit.DB.ElementId(idx);
                return(true);
            }

            value = def;
            return(false);
        }
示例#4
0
        public static bool IsOrphaned(int id)
        {
            var doc = DocumentManager.Instance.CurrentDBDocument;
            var eId = new Autodesk.Revit.DB.ElementId(id);

            if (!(doc.GetElement(eId) is Autodesk.Revit.DB.IndependentTag t))
            {
                throw new ArgumentNullException(nameof(id));
            }

            return(t.IsOrphaned);
        }
示例#5
0
        public static bool IsTaggingLinkDoc(int id)
        {
            var doc = DocumentManager.Instance.CurrentDBDocument;
            var eId = new Autodesk.Revit.DB.ElementId(id);

            if (!(doc.GetElement(eId) is Autodesk.Revit.DB.IndependentTag t))
            {
                throw new ArgumentNullException(nameof(id));
            }

            return(t.TaggedLocalElementId == Autodesk.Revit.DB.ElementId.InvalidElementId);
        }
示例#6
0
        public static View OwnerView(int id)
        {
            var doc = DocumentManager.Instance.CurrentDBDocument;
            var eId = new Autodesk.Revit.DB.ElementId(id);

            if (!(doc.GetElement(eId) is Autodesk.Revit.DB.IndependentTag t))
            {
                throw new ArgumentNullException(nameof(id));
            }

            return(doc.GetElement(t.OwnerViewId).ToDSType(true) as View);
        }
示例#7
0
        /// <summary>
        /// Set Global Parameter Value to an Element ID from Integer
        /// </summary>
        /// <param name="parameter"></param>
        /// <param name="elementId"></param>
        public static void SetValueToElementId(GlobalParameter parameter, int elementId)
        {
            if (!parameter.InternalGlobalParameter.IsReporting)
            {
                // get document and open transaction
                Autodesk.Revit.DB.Document document = Application.Document.Current.InternalDocument;
                TransactionManager.Instance.EnsureInTransaction(document);

                Autodesk.Revit.DB.ElementId id = new Autodesk.Revit.DB.ElementId(elementId);
                parameter.InternalGlobalParameter.SetValue(new Autodesk.Revit.DB.ElementIdParameterValue(id));

                TransactionManager.Instance.TransactionTaskDone();
            }
        }
示例#8
0
        public void SetFamilyInstanceRotation()
        {
            string samplePath = Path.Combine(workingDirectory, @".\Family\SetFamilyInstanceRotation.dyn");
            string testPath   = Path.GetFullPath(samplePath);

            ViewModel.OpenCommand.Execute(testPath);

            RunCurrentModel();
            var elId      = new Autodesk.Revit.DB.ElementId(187030);
            var famInst   = RevitServices.Persistence.DocumentManager.Instance.CurrentDBDocument.GetElement(elId) as Autodesk.Revit.DB.FamilyInstance;
            var transform = famInst.GetTransform();

            double[] rotationAngles;
            Revit.Elements.InternalUtilities.TransformUtils.ExtractEularAnglesFromTransform(transform, out rotationAngles);
            Assert.AreEqual(30.0, rotationAngles[0] * 180 / System.Math.PI, 1.0e-6);
        }
示例#9
0
        private void InitImageInstance(Autodesk.Revit.DB.View view, Autodesk.Revit.DB.ElementId typeId, Autodesk.Revit.DB.ImagePlacementOptions options)
        {
            //Phase 1 - Check to see if the object exists and should be rebound
            var oldEle = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.ImageInstance>(DocumentManager.Instance.CurrentDBDocument);

            // Rebind to Element
            if (oldEle != null)
            {
                InternalSetImageInstance(oldEle);
                return;
            }

            //Phase 2 - There was no existing Element, create new one
            TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument);

            var ii = Autodesk.Revit.DB.ImageInstance.Create(DocumentManager.Instance.CurrentDBDocument, view, typeId, options);

            InternalSetImageInstance(ii);

            TransactionManager.Instance.TransactionTaskDone();

            ElementBinder.SetElementForTrace(InternalElement);
        }
示例#10
0
        /// <summary>
        /// The constructor is used to initialize some object.
        /// </summary>
        /// <param name="opt">Used to get the Command class's object.</param>
        public LevelsForm(Command opt)
        {
            InitializeComponent();

            m_objectReference = opt;

            //Set control on UI
            LevelName            = new DataGridViewTextBoxColumn();
            LevelName.HeaderText = "Name";
            LevelName.Width      = 142;

            LevelElevation            = new DataGridViewTextBoxColumn();
            LevelElevation.HeaderText = "Elevation";
            LevelElevation.Width      = 142;

            levelsDataGridView.Columns.AddRange(new DataGridViewColumn[] { LevelName, LevelElevation });

            bindingSource1.DataSource = typeof(Revit.SDK.Samples.LevelsProperty.CS.LevelsDataSource);
            //Must place below code on the code "dataGridView1.DataSource = bindingSource1"
            levelsDataGridView.AutoGenerateColumns = false;
            levelsDataGridView.DataSource          = bindingSource1;
            LevelName.DataPropertyName             = "Name";
            LevelElevation.DataPropertyName        = "Elevation";

            //pass datum to BindingSource
            bindingSource1.DataSource = m_objectReference.SystemLevelsDatum;

            //Record system levels' total
            m_systemLevelsTotal = m_objectReference.SystemLevelsDatum.Count;

            //Record changed items
            m_changedItemsFlag = new int[m_systemLevelsTotal];

            //Record deleted items
            m_deleteExistLevelIDValue = new Autodesk.Revit.DB.ElementId[m_systemLevelsTotal];
            m_deleteExistLevelTotal   = 0;
        }
示例#11
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())
                {
                    if (iter.Current is Autodesk.Revit.DB.ElementId)    // it's more useful for user to view element rather than element id.
                    {
                        Autodesk.Revit.DB.ElementId elemId = iter.Current as Autodesk.Revit.DB.ElementId;
                        m_objs.Add(doc.GetElement(elemId));
                    }
                    else
                    {
                        m_objs.Add(iter.Current);
                    }
                }
            }
        }
示例#12
0
    /// <summary>
    /// Display sheet, the views it contains, the BIM 
    /// parts and  family instances they display in a 
    /// temporary form generated on the fly.
    /// </summary>
    /// <param name="owner">Owner window</param>
    /// <param name="caption">Form caption</param>
    /// <param name="modal">Modal versus modeless</param>
    /// <param name="roomLoops">Sheet and viewport boundary loops</param>
    /// <param name="geometryLoopss">Family symbol and part geometry</param>
    /// <param name="familyInstances">Family instances</param>
    public static Bitmap DisplaySheet(
      ElementId sheetId,
      JtLoops sheetViewportLoops,
      SheetModelCollections modelCollections )
    {
      // Source rectangle.
 
      JtBoundingBox2dInt bbFrom = sheetViewportLoops
        .BoundingBox;

      // Adjust target rectangle height to the 
      // displayee loop height.

      int width = _form_width;
      int height = (int) ( width * bbFrom.AspectRatio + 0.5 );

      // Specify transformation target rectangle 
      // including a margin.

      int top = 0;
      int left = 0;
      int bottom = height - ( _margin + _margin );

      Point[] parallelogramPoints = new Point[] {
        new Point( left + _margin, bottom ), // upper left
        new Point( left + width - _margin, bottom ), // upper right
        new Point( left + _margin, top + _margin ) // lower left
      };

      // Transform from native loop coordinate system
      // (sheet) to target display coordinates form).

      Matrix transformSheetBbToForm = new Matrix(
        bbFrom.Rectangle, parallelogramPoints );

      Bitmap bmp = new Bitmap( width, height );
      Graphics graphics = Graphics.FromImage( bmp );

      graphics.Clear( System.Drawing.Color.White );

      // Display sheet and viewport rectangles.

      DrawLoopsOnGraphics( graphics,
        sheetViewportLoops.GetGraphicsPathLines(),
        transformSheetBbToForm );

      // Iterate over the views and display the 
      // elements for each one appropriately 
      // scaled and translated to fit.

      List<ViewData> views = modelCollections
        .ViewsInSheet[sheetId];

      Dictionary<ElementId, GeomData> geometryLookup 
        = modelCollections.Symbols;

      Matrix transformBimToViewport;
      JtBoundingBox2dInt bbTo;
      JtLoop loop;

      foreach( ViewData view in views )
      {
        ElementId vid = view.Id;

        if( !modelCollections.BimelsInViews
          .ContainsKey( vid ) )
        {
          // This is not a floor plan view, so
          // we have nothing to display in it.

          continue;
        }

        // Determine transform from model space in mm
        // to the viewport associated with this view.

        bbFrom = view.BimBoundingBox;
        bbTo = view.ViewportBoundingBox;

        Debug.Print( view.ToString() );

        // Adjust target rectangle height to the 
        // displayee loop height.

        //height = (int) ( width * bbFrom.AspectRatio + 0.5 );

        // Specify transformation target rectangle 
        // including a margin, and center the target 
        // rectangle vertically.

        top = bbTo.Min.Y + _margin2;
        left = bbTo.Min.X + _margin2;
        bottom = bbTo.Max.Y - _margin2;
        width = bbTo.Width - (_margin2 + _margin2);

        parallelogramPoints = new Point[] {
          new Point( left, top ), // upper left
          new Point( left + width, top ), // upper right
          new Point( left, bottom ) // lower left
        };

        // Transform from native loop coordinate system
        // (sheet) to target display coordinates form).

        transformBimToViewport = new Matrix(
          bbFrom.Rectangle, parallelogramPoints );

        // Retrieve the list of BIM elements  
        // displayed in this view.

        List<ObjData> bimels = modelCollections
          .BimelsInViews[vid];

        List<Point[]> loops = new List<Point[]>( 1 );
        loops.Add( new Point[] { } );

        Matrix placement = new Matrix();

        foreach( ObjData bimel in bimels )
        {
          placement.Reset();

          InstanceData inst = bimel as InstanceData;

          if( null != inst )
          {
            loop = geometryLookup[inst.Symbol].Loop;
            Point2dInt v = inst.Placement.Translation;
            placement.Rotate( inst.Placement.Rotation );
            placement.Translate( v.X, v.Y, MatrixOrder.Append );
          }
          else
          {
            Debug.Assert( bimel is GeomData, "expected part with geometry" );

            loop = ((GeomData) bimel).Loop;
          }
          loops[0] = loop.GetGraphicsPathLines();

          placement.Multiply( transformBimToViewport, MatrixOrder.Append );
          placement.Multiply( transformSheetBbToForm, MatrixOrder.Append );

          DrawLoopsOnGraphics( graphics, loops, placement );
        }
      }
      return bmp;
    }
 public static bool TrySetUserString(this GeometryBase geometry, string key, Autodesk.Revit.DB.ElementId value, Autodesk.Revit.DB.ElementId def) =>
 geometry.TrySetUserString(key, value.IntegerValue, def.IntegerValue);
示例#14
0
        /// <summary>
        /// Display sheet, the views it contains, the BIM
        /// parts and  family instances they display in a
        /// temporary form generated on the fly.
        /// </summary>
        /// <param name="owner">Owner window</param>
        /// <param name="caption">Form caption</param>
        /// <param name="modal">Modal versus modeless</param>
        /// <param name="roomLoops">Sheet and viewport boundary loops</param>
        /// <param name="geometryLoopss">Family symbol and part geometry</param>
        /// <param name="familyInstances">Family instances</param>
        public static Bitmap DisplaySheet(
            ElementId sheetId,
            JtLoops sheetViewportLoops,
            SheetModelCollections modelCollections)
        {
            // Source rectangle.

            JtBoundingBox2dInt bbFrom = sheetViewportLoops
                                        .BoundingBox;

            // Adjust target rectangle height to the
            // displayee loop height.

            int width  = _form_width;
            int height = (int)(width * bbFrom.AspectRatio + 0.5);

            // Specify transformation target rectangle
            // including a margin.

            int top    = 0;
            int left   = 0;
            int bottom = height - (_margin + _margin);

            Point[] parallelogramPoints = new Point[] {
                new Point(left + _margin, bottom),         // upper left
                new Point(left + width - _margin, bottom), // upper right
                new Point(left + _margin, top + _margin)   // lower left
            };

            // Transform from native loop coordinate system
            // (sheet) to target display coordinates form).

            Matrix transformSheetBbToForm = new Matrix(
                bbFrom.Rectangle, parallelogramPoints);

            Bitmap   bmp      = new Bitmap(width, height);
            Graphics graphics = Graphics.FromImage(bmp);

            graphics.Clear(System.Drawing.Color.White);

            // Display sheet and viewport rectangles.

            DrawLoopsOnGraphics(graphics,
                                sheetViewportLoops.GetGraphicsPathLines(),
                                transformSheetBbToForm);

            // Iterate over the views and display the
            // elements for each one appropriately
            // scaled and translated to fit.

            List <ViewData> views = modelCollections
                                    .ViewsInSheet[sheetId];

            Dictionary <ElementId, GeomData> geometryLookup
                = modelCollections.Symbols;

            Matrix             transformBimToViewport;
            JtBoundingBox2dInt bbTo;
            JtLoop             loop;

            foreach (ViewData view in views)
            {
                ElementId vid = view.Id;

                if (!modelCollections.BimelsInViews
                    .ContainsKey(vid))
                {
                    // This is not a floor plan view, so
                    // we have nothing to display in it.

                    continue;
                }

                // Determine transform from model space in mm
                // to the viewport associated with this view.

                bbFrom = view.BimBoundingBox;
                bbTo   = view.ViewportBoundingBox;

                Debug.Print(view.ToString());

                // Adjust target rectangle height to the
                // displayee loop height.

                //height = (int) ( width * bbFrom.AspectRatio + 0.5 );

                // Specify transformation target rectangle
                // including a margin, and center the target
                // rectangle vertically.

                top    = bbTo.Min.Y + _margin2;
                left   = bbTo.Min.X + _margin2;
                bottom = bbTo.Max.Y - _margin2;
                width  = bbTo.Width - (_margin2 + _margin2);

                parallelogramPoints = new Point[] {
                    new Point(left, top),         // upper left
                    new Point(left + width, top), // upper right
                    new Point(left, bottom)       // lower left
                };

                // Transform from native loop coordinate system
                // (sheet) to target display coordinates form).

                transformBimToViewport = new Matrix(
                    bbFrom.Rectangle, parallelogramPoints);

                // Retrieve the list of BIM elements
                // displayed in this view.

                List <ObjData> bimels = modelCollections
                                        .BimelsInViews[vid];

                List <Point[]> loops = new List <Point[]>(1);
                loops.Add(new Point[] { });

                Matrix placement = new Matrix();

                foreach (ObjData bimel in bimels)
                {
                    placement.Reset();

                    InstanceData inst = bimel as InstanceData;

                    if (null != inst)
                    {
                        loop = geometryLookup[inst.Symbol].Loop;
                        Point2dInt v = inst.Placement.Translation;
                        placement.Rotate(inst.Placement.Rotation);
                        placement.Translate(v.X, v.Y, MatrixOrder.Append);
                    }
                    else
                    {
                        Debug.Assert(bimel is GeomData, "expected part with geometry");

                        loop = ((GeomData)bimel).Loop;
                    }
                    loops[0] = loop.GetGraphicsPathLines();

                    placement.Multiply(transformBimToViewport, MatrixOrder.Append);
                    placement.Multiply(transformSheetBbToForm, MatrixOrder.Append);

                    DrawLoopsOnGraphics(graphics, loops, placement);
                }
            }
            return(bmp);
        }
示例#15
0
 private ImageInstances(Autodesk.Revit.DB.View view, Autodesk.Revit.DB.ElementId typeId, Autodesk.Revit.DB.ImagePlacementOptions options)
 {
     SafeInit(() => InitImageInstance(view, typeId, options));
 }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="dataAccess">
        /// The DA object is used to retrieve from inputs and store in outputs.
        /// </param>
        protected override void SolveInstance(IGH_DataAccess dataAccess)
        {
            List <GH_ObjectWrapper> objectWrapperList;

            objectWrapperList = new List <GH_ObjectWrapper>();

            if (!dataAccess.GetDataList(0, objectWrapperList) || objectWrapperList == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                dataAccess.SetData(1, false);
                return;
            }

            List <SAMObject> sAMObjects = new List <SAMObject>();

            foreach (GH_ObjectWrapper objectWrapper in objectWrapperList)
            {
                if (objectWrapper == null || objectWrapper.Value == null)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Null SAMObject");
                    continue;
                }

                SAMObject sAMObject = null;
                if (objectWrapper.Value is SAMObject)
                {
                    sAMObject = objectWrapper.Value as SAMObject;
                }
                else if (objectWrapper.Value is IGH_Goo)
                {
                    sAMObject = (objectWrapper.Value as dynamic).Value as SAMObject;
                }

                if (sAMObject == null)
                {
                    continue;
                }

                sAMObjects.Add(sAMObject);
            }

            objectWrapperList = new List <GH_ObjectWrapper>();

            if (!dataAccess.GetDataList(1, objectWrapperList) || objectWrapperList == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data");
                dataAccess.SetData(1, false);
                return;
            }

            HashSet <Autodesk.Revit.DB.ElementId> elementIds = new HashSet <Autodesk.Revit.DB.ElementId>();

            foreach (GH_ObjectWrapper objectWrapper in objectWrapperList)
            {
                if (objectWrapper == null || objectWrapper.Value == null)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Null ElementId");
                    continue;
                }

                if (objectWrapper.Value is int)
                {
                    elementIds.Add(new Autodesk.Revit.DB.ElementId((int)objectWrapper.Value));
                }
                else if (objectWrapper.Value is GH_Integer)
                {
                    elementIds.Add(new Autodesk.Revit.DB.ElementId(((GH_Integer)objectWrapper.Value).Value));
                }
                else if (objectWrapper.Value is string)
                {
                    int value;
                    if (int.TryParse((string)objectWrapper.Value, out value))
                    {
                        elementIds.Add(new Autodesk.Revit.DB.ElementId(value));
                    }
                }
                else if (objectWrapper.Value is GH_Number)
                {
                    elementIds.Add(new Autodesk.Revit.DB.ElementId((int)((GH_Number)objectWrapper.Value).Value));
                }
                else if (objectWrapper.Value is GH_String)
                {
                    int value;
                    if (int.TryParse(((GH_String)objectWrapper.Value).Value, out value))
                    {
                        elementIds.Add(new Autodesk.Revit.DB.ElementId(value));
                    }
                }
            }

            List <SAMObject> result_in  = new List <SAMObject>();
            List <SAMObject> result_out = new List <SAMObject>();

            foreach (SAMObject sAMObject in sAMObjects)
            {
                Autodesk.Revit.DB.ElementId elementId = Core.Revit.Query.ElementId(sAMObject);
                if (elementIds.Contains(elementId))
                {
                    result_in.Add(sAMObject);
                }
                else
                {
                    result_out.Add(sAMObject);
                }
            }

            dataAccess.SetDataList(0, result_in);
            dataAccess.SetDataList(1, result_out);
        }
示例#17
0
 /// <summary>
 /// Implements the interface method.
 /// </summary>
 public void CreateLanding(Autodesk.Revit.DB.Document document, Autodesk.Revit.DB.ElementId stairsElementId, int landingIndex)
 {
     m_landingConfigurations[landingIndex].CreateLanding(document, stairsElementId);
 }
示例#18
0
 /// <summary>
 /// Implements the interface method.
 /// </summary>
 public void CreateStairsRun(Autodesk.Revit.DB.Document document, Autodesk.Revit.DB.ElementId stairsElementId, int runIndex)
 {
     m_runConfigurations[runIndex].CreateStairsRun(document, stairsElementId);
 }
示例#19
0
        public override object NewElement(object parent)
        {
            FamilyComponent component = null;

            System.Windows.Forms.OpenFileDialog dialogue = new System.Windows.Forms.OpenFileDialog();
            dialogue.Filter           = "Revit Families (*.rfa)|*.rfa|All files (*.*)|*.*";
            dialogue.RestoreDirectory = true;
            if (dialogue.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                FileInfo file = new FileInfo(dialogue.FileName);
                Autodesk.Revit.DB.Document doc = ((Autodesk.Revit.ApplicationServices.Application)ADSKApplciation).OpenDocumentFile(file.FullName);

                component              = FamilyComponent.NewFamilyComponent(SQLiteConnection, ComponentDataView, ActiveUser, ADSKApplciation, FamilyComponentTypeItems.InternalCollection[0]);
                component.FileName     = file.Name;
                component.FileSize     = file.Length;
                component.DateCreated  = DateTime.Now;
                component.DateModified = DateTime.Now;
                component.IsReleased   = false;
                component.State        = EntityStates.Enabled;

                byte[] image = Utils.ThumbnailFromView(doc, "Thumbnail");
                if (image == null)
                {
                    component.Thumbnail = new byte[byte.MaxValue];
                }
                else
                {
                    component.Thumbnail = image;
                }

                if (doc.OwnerFamily.FamilyCategory != null)
                {
                    component.FamilyCategory = doc.OwnerFamily.FamilyCategory.Name;
                }
                else
                {
                    component.FamilyCategory = "None";
                }

                Autodesk.Revit.DB.ElementId alwaysVerticalId            = new Autodesk.Revit.DB.ElementId(Autodesk.Revit.DB.BuiltInParameter.FAMILY_ALWAYS_VERTICAL);
                Autodesk.Revit.DB.ElementId canHostRebarlId             = new Autodesk.Revit.DB.ElementId(Autodesk.Revit.DB.BuiltInParameter.FAMILY_CAN_HOST_REBAR);
                Autodesk.Revit.DB.ElementId cutsWalllId                 = new Autodesk.Revit.DB.ElementId(Autodesk.Revit.DB.BuiltInParameter.FAMILY_ALLOW_CUT_WITH_VOIDS);
                Autodesk.Revit.DB.ElementId sharedId                    = new Autodesk.Revit.DB.ElementId(Autodesk.Revit.DB.BuiltInParameter.FAMILY_SHARED);
                Autodesk.Revit.DB.ElementId OmniClassCodeId             = new Autodesk.Revit.DB.ElementId(Autodesk.Revit.DB.BuiltInParameter.OMNICLASS_CODE);
                Autodesk.Revit.DB.ElementId omniClassNameId             = new Autodesk.Revit.DB.ElementId(Autodesk.Revit.DB.BuiltInParameter.OMNICLASS_DESCRIPTION);
                Autodesk.Revit.DB.ElementId parttypeId                  = new Autodesk.Revit.DB.ElementId(Autodesk.Revit.DB.BuiltInParameter.FAMILY_CONTENT_PART_TYPE);
                Autodesk.Revit.DB.ElementId roomCalculationpointId      = new Autodesk.Revit.DB.ElementId(Autodesk.Revit.DB.BuiltInParameter.ROOM_CALCULATION_POINT);
                Autodesk.Revit.DB.ElementId roundCOnnectorDescriptionId = new Autodesk.Revit.DB.ElementId(Autodesk.Revit.DB.BuiltInParameter.FAMILY_ROUNDCONNECTOR_DIMENSIONTYPE);
                Autodesk.Revit.DB.ElementId workPlaneBasedId            = new Autodesk.Revit.DB.ElementId(Autodesk.Revit.DB.BuiltInParameter.FAMILY_WORK_PLANE_BASED);

                foreach (Autodesk.Revit.DB.Parameter parameter in doc.OwnerFamily.Parameters)
                {
                    if (parameter.Id == alwaysVerticalId)
                    {
                        component.AlwaysVertical = Convert.ToBoolean(parameter.AsInteger());
                    }

                    if (parameter.Id == canHostRebarlId)
                    {
                        component.CanHostRebar = Convert.ToBoolean(parameter.AsInteger());
                    }

                    if (parameter.Id == cutsWalllId)
                    {
                        component.CutsWithVoidWhenLoaded = Convert.ToBoolean(parameter.AsInteger());
                    }

                    if (parameter.Id == sharedId)
                    {
                        component.IsShared = Convert.ToBoolean(parameter.AsInteger());
                    }

                    if (parameter.Id == omniClassNameId)
                    {
                        component.OmniClassTitle = parameter.AsString();
                    }

                    if (parameter.Id == OmniClassCodeId)
                    {
                        component.OmnoClassNumber = parameter.AsString();
                    }

                    if (parameter.Id == parttypeId)
                    {
                        component.PartType = parameter.AsValueString();
                    }

                    if (parameter.Id == roomCalculationpointId)
                    {
                        component.RoomCalculationPoint = Convert.ToBoolean(parameter.AsInteger());
                    }

                    if (parameter.Id == roundCOnnectorDescriptionId)
                    {
                        component.RoundConnectorDimension = parameter.AsValueString();
                    }

                    if (parameter.Id == workPlaneBasedId)
                    {
                        component.WorkPlaneBased = Convert.ToBoolean(parameter.AsInteger());
                    }
                }

                if (component.PartType == string.Empty)
                {
                    component.PartType = "N/A";
                }

                if (component.RoundConnectorDimension == string.Empty)
                {
                    component.PartType = "N/A";
                }

                component.EndEdit();

                if (doc.OwnerFamily.FamilyCategory != null)
                {
                    component.FamilyCategory = doc.OwnerFamily.FamilyCategory.Name;
                }
                else
                {
                    component.FamilyCategory = "None";
                }

                component.EndEdit();

                Utils.GetFamilyComponentFeatures(component, doc, ActiveUser);
                Utils.GetFamilyComponentParameters(component, doc, ActiveUser);
                Utils.GetFamilyComponentReferencePlanes(component, doc, ActiveUser);

                doc.Close(false);

                component.FamilyFile = Utils.FileToByteArray(file.FullName);
                SelectedElement      = component;
                RefreshCollections();
            }
            return(component);
        }
 public static bool GetUserElementId(this GeometryBase geometry, string key, out Autodesk.Revit.DB.ElementId value) =>
 GetUserElementId(geometry, key, out value, Autodesk.Revit.DB.ElementId.InvalidElementId);
        public static Autodesk.Revit.DB.Wall ToRevit(Wall source, Autodesk.Revit.DB.Document doc = null, Autodesk.Revit.DB.ElementId levelId = null)
        {
            if (doc == null || levelId == null)
            {
                throw new ArgumentNullException();
            }

            return(Autodesk.Revit.DB.Wall.Create(
                       doc,
                       LineInterop.ToRevit(source.BaseLine),
                       levelId,
                       false
                       ));
        }