示例#1
0
        public static IEnumerable <Space> ToSAM_Spaces(this RevitLinkInstance revitLinkInstance, Core.Revit.ConvertSettings convertSettings, bool fromRooms = true)
        {
            Document document_Source = revitLinkInstance.GetLinkDocument();

            BuiltInCategory builtInCategory;

            if (fromRooms)
            {
                builtInCategory = BuiltInCategory.OST_Rooms;
            }
            else
            {
                builtInCategory = BuiltInCategory.OST_MEPSpaces;
            }

            IEnumerable <SpatialElement> spatialElements = new FilteredElementCollector(document_Source).OfCategory(builtInCategory).Cast <SpatialElement>();

            List <Space> spaces = new List <Space>();

            foreach (SpatialElement spatialElement in spatialElements)
            {
                Space space = ToSAM(spatialElement, convertSettings);
                if (space != null)
                {
                    spaces.Add(space);
                }
            }
            return(spaces);
        }
示例#2
0
        private void cbx_RevitLink_SelectedIndexChanged(object sender, EventArgs e)
        {
            // gets the variable selected
            ComboBox          comboBox         = sender as ComboBox;
            String            selectedLinkName = comboBox.SelectedItem as String;
            RevitLinkInstance selectedLink     = this.LinkNamesDic[selectedLinkName];
            Document          selectedLinkDoc  = selectedLink.GetLinkDocument();

            // clears the link levels, link levels list box and link level names dic
            cbx_LinkLevel.Items.Clear();
            lb_LinkLevels.Items.Clear();
            this.LinkLevelNamesDic.Clear();

            // collects link levels
            List <Level> linkLevels = new FilteredElementCollector(selectedLinkDoc)
                                      .OfCategory(BuiltInCategory.OST_Levels)
                                      .WhereElementIsNotElementType()
                                      .ToElements()
                                      .Cast <Level>()
                                      .OrderByDescending(x => x.Elevation)
                                      .ToList();

            // populates the link levels list box and link levels name dic
            foreach (Level level in linkLevels)
            {
                cbx_LinkLevel.Items.Add(level.Name);
                this.LinkLevelNamesDic.Add(level.Name, level);
            }
        }
示例#3
0
        public static Element FindElementinLinkedDoc(this Document curDoc, string elementUNIQUEID)
        {
            Element element = null;

            #region Find the Revit Link*
            // get the revitlinks from the current document
            FilteredElementCollector collectionofRVTInst = new FilteredElementCollector(curDoc).OfCategory(BuiltInCategory.OST_RvtLinks);

            #endregion

            #region Finding the Element in the Linked Document
            // convert those objects into RevitLinkInstances?
            //IEnumerable<RevitLinkInstance> parentlinkDoc = from posslink in collectionofRVTInst
            //                                               where (posslink is RevitLinkInstance)
            //                                               select posslink as RevitLinkInstance;

            // check each of the documents to see if they contain the element
            // select appropiate link
            RevitLinkInstance rvtlink = (from posslink in collectionofRVTInst
                                         where (posslink as RevitLinkInstance).GetLinkDocument().GetElement(elementUNIQUEID).IsValidObject
                                         select posslink as RevitLinkInstance).FirstOrDefault();

            // find the host in the list by comparing the UNIQUEIDS
            element = rvtlink.GetLinkDocument().GetElement(elementUNIQUEID);
            #endregion

            return(element);
        }
示例#4
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication     uiapp    = commandData.Application;
            UIDocument        uidoc    = uiapp.ActiveUIDocument;
            Application       app      = uiapp.Application;
            Document          doc      = uidoc.Document;
            Reference         link_ref = uidoc.Selection.PickObject(ObjectType.Element, "Select a link instance first");
            IList <Reference> el_ref   = uidoc.Selection.PickObjects(ObjectType.LinkedElement,
                                                                     "Select Element In Linked");

            RevitLinkInstance link1      = doc.GetElement(link_ref.ElementId) as RevitLinkInstance;
            Document          linkDoc    = link1.GetLinkDocument();
            List <ElementId>  elementIds = new List <ElementId>();
            StringBuilder     sb         = new StringBuilder();

            foreach (var r1 in el_ref)
            {
                ElementId elementId = r1.LinkedElementId;
                elementIds.Add(elementId);
            }

            foreach (ElementId id in elementIds)
            {
                Element element = linkDoc.GetElement(id);
                sb.AppendLine($"{element.Name}-{element.Id}");
            }
            MessageBox.Show($"{sb}", "Information", MessageBoxButtons.OK);
            return(Result.Succeeded);
        }
示例#5
0
        public void Load_Form(UIApplication uiapp, Document doc)
        {
            try
            {
                data_revit_link item = (data_revit_link)link_file.SelectedItem;
                doc.Delete(item.type.Id);

                ModelPath        mp  = ModelPathUtils.ConvertUserVisiblePathToModelPath(path);
                RevitLinkOptions rlo = new RevitLinkOptions(false);
                var linkType         = RevitLinkType.Create(doc, mp, rlo);
                var instance         = RevitLinkInstance.Create(doc, linkType.ElementId);

                List <Document> docs = new List <Document>();
                foreach (Document d in uiapp.Application.Documents)
                {
                    docs.Add(d);
                }
                item.document = docs.First(y => y.Title + ".rvt" == item.name);
                item.type     = doc.GetElement(linkType.ElementId) as RevitLinkType;
                link_file.Items.Refresh();
                MessageBox.Show(item.document.PathName);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                link_file.SelectedItem = null;
            }
        }
示例#6
0
 public RevitLinkProperties(RevitLinkInstance instance)
 {
     m_instance = instance;
     instanceId = instance.Id;
     isLinked   = true;
     CollectLinkInstanceInfo();
 }
示例#7
0
        // zoom active view to element in linked doc
        // how to zoom elements in linked document using revit api?
        // https://forums.autodesk.com/t5/revit-api-forum/how-to-zoom-elements-in-linked-document-using-revit-api/m-p/9778123
        // use LinkElementId class?

        void ZoomToLinkedElement(
            UIDocument uidoc,
            RevitLinkInstance link,
            ElementId id)
        {
            Document doc  = uidoc.Document;
            View     view = doc.ActiveView;

            // Determine active UIView to use

            UIView uiView = uidoc
                            .GetOpenUIViews()
                            .FirstOrDefault <UIView>(uv
                                                     => uv.ViewId.Equals(view.Id));

            Element        e            = doc.GetElement(id);
            LocationPoint  lp           = e.Location as LocationPoint;
            Transform      transform1   = link.GetTransform();
            XYZ            newLocation2 = transform1.OfPoint(lp.Point);
            BoundingBoxXYZ bb           = e.get_BoundingBox(doc.ActiveView);

            uiView.ZoomAndCenterRectangle(
                new XYZ(newLocation2.X - 4, newLocation2.Y - 4, newLocation2.Z - 4),
                new XYZ(newLocation2.X + 4, newLocation2.Y + 4, newLocation2.Z + 4));
        }
示例#8
0
        /// <summary>
        /// Creates an instance for the Revit file selected
        /// </summary>
        /// <param name="doc">Document to which the link should be added</param>
        /// <param name="revitFilePath">the full path of the Revit link to be added</param>
        private static void InstanceMaker(Document doc, string revitFilePath)
        {
            try
            {
                using (Transaction tr = new Transaction(doc))
                {
                    tr.Start("Revit files are being linked...");

                    // Cycle through the list
                    // Set the standard options and behavior for the links
                    FilePath         fp  = new FilePath(revitFilePath);
                    RevitLinkOptions rlo = new RevitLinkOptions(false);

                    // Create new revit link and store the path to the file as either absolute or relative
                    RevitLinkLoadResult result = RevitLinkType.Create(doc, fp, rlo);
                    ElementId           linkId = result.ElementId;

                    // Create the Revit Link Instance (this also automatically sets the link Origin-to-Origin)
                    // Pin the Revit link as well
                    RevitLinkInstance linkInstance = RevitLinkInstance.Create(doc, linkId);
                    linkInstance.Pinned = true;

                    tr.Commit();
                }
            }

            catch (Exception)
            {
                // not sure what exceptions may occur
                // make sure that whatever happens is logged for future troubleshooting
            }
        }
示例#9
0
        /// <summary>
        /// Does this work yet?
        /// </summary>
        /// <param name="curdoc"></param>
        /// <param name="faminstance"></param>
        /// <returns></returns>
        public static Element FindHost(this Document curdoc, FamilyInstance faminstance)
        {
            Element host = null;

            #region Find the Revit Link*
            // get the revitlinkinstances from the current document
            FilteredElementCollector collectionofRVTInst = new FilteredElementCollector(curdoc).OfCategory(BuiltInCategory.OST_RvtLinks);

            // selects the link which matches the instance's host's document's path
            RevitLinkInstance parentlinkDoc = (from posslink in collectionofRVTInst
                                               where (posslink as RevitLinkInstance).GetLinkDocument().PathName.ToString().Equals(faminstance.Host.Document.PathName.ToString())
                                               select(posslink as RevitLinkInstance)).Single();
            #endregion

            #region Finding the Host in the Linked Document
            // for face based elements
            // make a list of elements in the linked document which match the host's type
            // in this test case, these should return walls
            FilteredElementCollector linkdocfec = new FilteredElementCollector(faminstance.Host.Document);
            linkdocfec.OfClass(faminstance.Host.GetType());

            // find the host in the list by comparing the UNIQUEIDS
            host = (from posshost in linkdocfec
                    where posshost.UniqueId.ToString().Equals(faminstance.Host.UniqueId.ToString())
                    select posshost).First();
            #endregion

            return(host);
        }
        public bool AllowReference(Reference reference, XYZ position)
        {
            if (reference.ElementId == null || reference.ElementId == ElementId.InvalidElementId)
            {
                return(false);
            }

            if (reference.LinkedElementId == null || reference.LinkedElementId == ElementId.InvalidElementId)
            {
                return(false);
            }

            RevitLinkInstance revitLinkInstance = this.document.GetElement(reference.ElementId) as RevitLinkInstance;

            if (revitLinkInstance == null)
            {
                return(false);
            }

            Document document = revitLinkInstance.GetLinkDocument();

            if (document == null)
            {
                return(false);
            }

            Element element = document.GetElement(reference.LinkedElementId);

            if (element == null)
            {
                return(false);
            }

            return(element.Category.Id.IntegerValue == (int)builtInCategory);
        }
示例#11
0
        public static double GetIntersectedSolidArea(
            Document host,
            Solid hostElement,
            RevitLinkInstance rins,
            Solid linkedElement)
        {
            // Step 1 "Determine the transformation T from the linked document Q coordinates to P's."

            Transform transForm = rins.GetTransform();

            // Step 2 "Open the linked project Q and retrieve the solid Sb of B."

            // linkedElement is Solid of linked Link

            // Step 3 "Transform it to P's coordinate space: T * Sb."

            Solid tmp = SolidUtils.CreateTransformed(linkedElement, transForm);

            // Step 4 "Retrieve the solid Sa of A"
            // hostElement is hostElementSolid

            Solid result = BooleanOperationsUtils.ExecuteBooleanOperation(
                hostElement, tmp, BooleanOperationsType.Intersect);


            return(result.SurfaceArea);
        }
示例#12
0
        public static Element Element(this Document document, string uniqueId, string linkUniqueId = null)
        {
            if (document == null)
            {
                return(null);
            }

            Document revitDocument = null;

            if (!string.IsNullOrEmpty(linkUniqueId))
            {
                RevitLinkInstance revitLinkInstance = document.GetElement(linkUniqueId) as RevitLinkInstance;
                if (revitLinkInstance != null)
                {
                    revitDocument = revitLinkInstance.GetLinkDocument();
                }
            }
            else
            {
                revitDocument = document;
            }

            if (revitDocument == null)
            {
                return(null);
            }

            return(revitDocument.GetElement(uniqueId));
        }
示例#13
0
        /// <summary>
        ///     Creates a revit link.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="linkPath"></param>
        /// <returns></returns>
        public static void AddRevitLink(this Document doc, string linkPath)
        {
            if (doc == null)
            {
                throw new ArgumentNullException(nameof(doc));
            }

            if (linkPath == null)
            {
                throw new ArgumentNullException(nameof(linkPath));
            }

            var filePathl  = new FilePath(linkPath);
            var linkOption = new RevitLinkOptions(false);

            doc.AutoTransaction(() =>
            {
                var result   = RevitLinkType.Create(doc, filePathl, linkOption);
                var instance = RevitLinkInstance.Create(doc, result.ElementId);

                if (!(doc.GetElement(instance.GetTypeId()) is RevitLinkType type))
                {
                    return;
                }

                type.AttachmentType = AttachmentType.Attachment;
                type.PathType       = PathType.Relative;
            });
        }
示例#14
0
        public static IEnumerable <Core.SAMObject> ToSAM(this RevitLinkInstance revitLinkInstance, System.Type type, Core.Revit.ConvertSettings convertSettings)
        {
            Document document = null;

            try
            {
                document = revitLinkInstance.GetLinkDocument();
            }
            catch
            {
                return(null);
            }

            if (document == null)
            {
                return(null);
            }

            Transform transform = revitLinkInstance.GetTotalTransform();

            if (transform == null)
            {
                transform = Transform.Identity;
            }

            if (!transform.IsIdentity)
            {
                transform = transform.Inverse;
            }

            return(ToSAM(document, type, convertSettings, transform));
        }
示例#15
0
        internal static List <Document> GetHostAndLinkDocuments(Document revitDoc)
        {
            List <Document> docList = new List <Document>();

            docList.Add(revitDoc);

            // Find RevitLinkInstance documents
            FilteredElementCollector elemCollector = new FilteredElementCollector(revitDoc);

            elemCollector.OfClass(typeof(RevitLinkInstance));
            foreach (Element curElem in elemCollector)
            {
                RevitLinkInstance revitLinkInstance = curElem as RevitLinkInstance;
                if (null == revitLinkInstance)
                {
                    continue;
                }

                Document curDoc = revitLinkInstance.GetLinkDocument();
                if (null == curDoc)                 // Link is unloaded.
                {
                    continue;
                }

                // When one linked document has more than one RevitLinkInstance in the
                // host document, then 'docList' will contain the linked document multiple times.

                docList.Add(curDoc);
            }

            return(docList);
        }
 public LinkedInstanceProperties(RevitLinkInstance instance)
 {
     Instance       = instance;
     InstanceId     = instance.Id.IntegerValue;
     LinkedDocument = instance.GetLinkDocument();
     DocumentTitle  = LinkedDocument.Title;
     TransformValue = instance.GetTotalTransform();
 }
示例#17
0
        /// <summary>
        /// This node will obtain the selected link's document.
        /// </summary>
        /// <param name="linkInstance">The link to get document from.</param>
        /// <returns name="Document">The document.</returns>
        /// <search>
        ///  rhythm
        /// </search>
        public static Autodesk.Revit.DB.Document GetDocument(global::Revit.Elements.Element linkInstance)
        {
            RevitLinkInstance internalLink = (RevitLinkInstance)linkInstance.InternalElement;

            Autodesk.Revit.DB.Document linkDoc = internalLink.GetLinkDocument();

            return(linkDoc);
        }
示例#18
0
 public void CreateLinkInstances(Document doc, ElementId linkTypeId)
 {
     // Create revit link instance at origin
     //RevitLinkInstance.Create(doc, linkTypeId);
     RevitLinkInstance instance2 = RevitLinkInstance.Create(doc, linkTypeId);
     // Offset second instance by 100 feet
     //Location location = instance2.Location;
     //location.Move(new XYZ(0, -100, 0));
 }
示例#19
0
        /// <summary>
        /// 根据链接文件名称的关键词,获取对应链接Revit文件
        /// </summary>
        /// <param name="linkInstanceName"></param>
        /// <returns></returns>
        public RevitLinkInstance SellectRevitLinkInstance(string linkInstanceName)
        {
            FilteredElementCollector col   = new FilteredElementCollector(doc);
            List <RevitLinkInstance> links = col.OfCategory(BuiltInCategory.OST_RvtLinks).
                                             OfClass(typeof(RevitLinkInstance)).Cast <RevitLinkInstance>().ToList();
            RevitLinkInstance linkInstance = links.FirstOrDefault(x => x.Name.Contains(linkInstanceName));

            return(linkInstance);
        }
示例#20
0
 /// <summary>
 /// Экземпляр класса с информацией по документу связанного файла
 /// </summary>
 public DocumentData(RevitLinkInstance link)
 {
     Basename  = Regex.Match(link.Name, @"(.+)\.rvt").Groups[1].Value;
     IsLink    = true;
     _Document = link.GetLinkDocument();
     IsLoaded  = _Document != null;
     Instance  = link;
     InstanceCorrectionTransform = DocumentUtils.GetCorrectionTransform(link);
 }
        /// <summary>
        /// Determine walls in linked file intersecting pipe
        /// </summary>
        public void GetWalls(UIDocument uidoc)
        {
            Document doc = uidoc.Document;

            Reference pipeRef = uidoc.Selection.PickObject(
                ObjectType.Element);

            Element pipeElem = doc.GetElement(pipeRef);

            LocationCurve lc    = pipeElem.Location as LocationCurve;
            Curve         curve = lc.Curve;

            ReferenceComparer reference1 = new ReferenceComparer();

            ElementFilter filter = new ElementCategoryFilter(
                BuiltInCategory.OST_Walls);

            FilteredElementCollector collector
                = new FilteredElementCollector(doc);

            Func <View3D, bool> isNotTemplate = v3 => !(v3.IsTemplate);
            View3D view3D = collector
                            .OfClass(typeof(View3D))
                            .Cast <View3D>()
                            .First <View3D>(isNotTemplate);

            ReferenceIntersector refIntersector
                = new ReferenceIntersector(
                      filter, FindReferenceTarget.Element, view3D);

            refIntersector.FindReferencesInRevitLinks = true;
            IList <ReferenceWithContext> referenceWithContext
                = refIntersector.Find(
                      curve.GetEndPoint(0),
                      (curve as Line).Direction);

            IList <Reference> references
                = referenceWithContext
                  .Select(p => p.GetReference())
                  .Distinct(reference1)
                  .Where(p => p.GlobalPoint.DistanceTo(
                             curve.GetEndPoint(0)) < curve.Length)
                  .ToList();

            IList <Element> walls = new List <Element>();

            foreach (Reference reference in references)
            {
                RevitLinkInstance instance = doc.GetElement(reference)
                                             as RevitLinkInstance;
                Document linkDoc = instance.GetLinkDocument();
                Element  element = linkDoc.GetElement(reference.LinkedElementId);
                walls.Add(element);
            }
            TaskDialog.Show("Count of wall", walls.Count.ToString());
        }
示例#22
0
        public LinkedInstanceProperties(RevitLinkInstance instance)
        {
            Instance   = instance;
            InstanceId = instance.Id.IntegerValue;

            if (null != instance.GetTotalTransform())
            {
                TransformValue = instance.GetTotalTransform();
            }
        }
示例#23
0
            // If the calling document is needed then we'll use this to pass it to this class.
            //Document doc = null;
            //public CeilingSelectionFilter(Document document)
            //{
            //    doc = document;
            //}

            public bool AllowElement(Element e)
            {
                if (e.GetType() == typeof(Ceiling))
                {
                    return(true);
                }
                // Accept any link instance, and save the handle for use in AllowReference()
                thisInstance = e as RevitLinkInstance;
                return(thisInstance != null);
            }
示例#24
0
        public List <IntersectionMepCurve> GetIntersections()
        {
            linkedDocInstance = DocumentUtils.ChooseLinkedDoc(doc);
            if (linkedDocInstance == null)
            {
                return(new List <IntersectionMepCurve>());
            }
            else
            {
                var       progress = new UI.ProgressBar("Поиск пересечений...", hosts.Count());
                Transform tr       = DocumentUtils.GetCorrectionTransform(linkedDocInstance);
                List <IntersectionMepCurve> intersectionList = new List <IntersectionMepCurve>();
                foreach (HostObject host in hosts)
                {
                    List <Face> hostFaces = GeometryUtils.GetFaces(host);
                    if (hostFaces.Count > 0)
                    {
                        BoundingBoxXYZ bb                  = host.get_BoundingBox(null);
                        Outline        outline             = new Outline(tr.OfPoint(bb.Min), tr.OfPoint(bb.Max));
                        BoundingBoxIntersectsFilter filter = new BoundingBoxIntersectsFilter(outline);

                        List <MEPCurve> meps = new FilteredElementCollector(linkedDoc)
                                               .OfClass(typeof(MEPCurve))
                                               .WherePasses(filter)
                                               .Cast <MEPCurve>()
                                               .ToList();

                        foreach (MEPCurve m in meps)
                        {
                            Curve mepCurve = GeometryUtils.FindDuctCurve(m.ConnectorManager);
                            if (mepCurve != null)
                            {
                                XYZ[] interPts = (from wallFace in hostFaces select FindFaceIntersection(mepCurve, wallFace)).ToArray();
                                if (interPts.Any(x => x != null))
                                {
                                    XYZ pt = interPts.First(x => x != null);
                                    try
                                    {
                                        IntersectionMepCurve i = new IntersectionMepCurve(host, m, pt, linkedDocInstance);
                                        intersectionList.Add(i);
                                    }
                                    catch (NotImplementedException)
                                    {
                                    }
                                }
                            }
                        }
                    }
                    progress.StepUp();
                }
                progress.Close();
                return(intersectionList);
            }
        }
 /// <summary>
 ///    Geef een gelinked document terug op basis van naam
 /// </summary>
 /// <param name="rli">RevitLinkInstance</param>
 /// <param name="app">UIApplication</param>
 /// <returns></returns>
 public static Document GetLinkDocument(this RevitLinkInstance rli, UIApplication app)
 {
     string[] totaalnaam = rli.Name.Split(':');
     return
         (app.Application.Documents.Cast <Document>()
          .FirstOrDefault(d =>
     {
         string fileName = Path.GetFileName(d.PathName);
         return fileName != null && fileName.Equals(totaalnaam[totaalnaam.Length - 3].Trim());
     }));
 }
示例#26
0
 internal RemoteLink(Document doc, RevitLinkInstance linkinstance)
 {
     Document     = linkinstance.GetLinkDocument();
     Type         = doc.GetElement(linkinstance.GetTypeId()) as RevitLinkType;
     Title        = Document.Title;
     DocumentPath = Document.PathName;
     IsWorkShared = Document.IsWorkshared;
     IsLoaded     = RevitLinkType.IsLoaded(doc, Type.Id);
     TempPath     = Path.GetTempPath() + "RemoteParameters\\";
     OpenDocument = null;
 }
示例#27
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;

            IList <Reference> linkModelRefs = uidoc.Selection.PickObjects(ObjectType.LinkedElement, "Select Elements");

            //group selected elements by rvt link
            var refGroupByLinkModel = linkModelRefs.GroupBy(item => doc.GetElement(item).Id).Select(refs => refs.ToList());

            using (Transaction t = new Transaction(doc, "Copy Linked Elements"))
            {
                t.Start();

                try
                {
                    CopyPasteOptions copyPasteOption = new CopyPasteOptions();
                    copyPasteOption.SetDuplicateTypeNamesHandler(new CustomCopyHandler());

                    foreach (List <Reference> linkedModelRef in refGroupByLinkModel)
                    {
                        ICollection <ElementId> eleToCopy = new List <ElementId>();

                        Element           e             = doc.GetElement(linkedModelRef.First().ElementId);
                        RevitLinkInstance revitLinkInst = e as RevitLinkInstance;
                        Document          linkRvtDoc    = (e as RevitLinkInstance).GetLinkDocument();
                        Transform         transf        = revitLinkInst.GetTransform();

                        foreach (Reference elementRef in linkedModelRef)
                        {
                            Element eLinked = linkRvtDoc.GetElement(elementRef.LinkedElementId);
                            eleToCopy.Add(eLinked.Id);
                        }

                        ElementTransformUtils.CopyElements(linkRvtDoc, eleToCopy, doc, transf, copyPasteOption);

                        TaskDialog.Show("elements to copy", String.Format("{0} elements have been copied from model {1}", eleToCopy.Count, revitLinkInst.Name));
                    }
                }
                catch (Exception ex)
                {
                    TaskDialog.Show("e", ex.Message);
                }

                t.Commit();
            }

            return(Result.Succeeded);
        }//close Execute
 /// <summary>
 /// Return a `StableRepresentation` for a linked wall's exterior face.
 /// </summary>
 public string GetFaceRefRepresentation( 
   Wall wall, 
   Document doc, 
   RevitLinkInstance instance )
 {
   Reference faceRef = HostObjectUtils.GetSideFaces( 
     wall, ShellLayerType.Exterior ).FirstOrDefault();
   Reference stRef = faceRef.CreateLinkReference( instance );
   string stable = stRef.ConvertToStableRepresentation( doc );
   return stable;
 }
示例#29
0
        public void AddFaceBasedFamilyToLinks(Document doc)
        {
            ElementId alignedLinkId = new ElementId(125929);

            // Get symbol

            ElementId symbolId = new ElementId(126580);

            FamilySymbol fs = doc.GetElement(symbolId)
                              as FamilySymbol;

            // Aligned

            RevitLinkInstance linkInstance = doc.GetElement(
                alignedLinkId) as RevitLinkInstance;

            Document linkDocument = linkInstance
                                    .GetLinkDocument();

            FilteredElementCollector wallCollector
                = new FilteredElementCollector(linkDocument);

            wallCollector.OfClass(typeof(Wall));

            Wall targetWall = wallCollector.FirstElement()
                              as Wall;

            Reference exteriorFaceRef
                = HostObjectUtils.GetSideFaces(
                      targetWall, ShellLayerType.Exterior)
                  .First <Reference>();

            Reference linkToExteriorFaceRef
                = exteriorFaceRef.CreateLinkReference(
                      linkInstance);

            Line wallLine = (targetWall.Location
                             as LocationCurve).Curve as Line;

            XYZ wallVector = (wallLine.GetEndPoint(1)
                              - wallLine.GetEndPoint(0)).Normalize();

            using (Transaction t = new Transaction(doc))
            {
                t.Start("Add to face");

                doc.Create.NewFamilyInstance(
                    linkToExteriorFaceRef, XYZ.Zero,
                    wallVector, fs);

                t.Commit();
            }
        }
        public LinkedInstanceData(RevitLinkInstance instance)
        {
            m_instance = instance;
            instanceId = instance.Id.IntegerValue;
#if RELEASE2013
            linkedDocument = instance.Document;
#elif RELEASE2014 || RELEASE2015 || RELEASE2016
            linkedDocument = instance.GetLinkDocument();
#endif
            documentTitle  = linkedDocument.Title;
            transformValue = instance.GetTotalTransform();
        }
示例#31
0
        private void Stream( ArrayList data, RevitLinkInstance linkInst )
        {
            data.Add( new Snoop.Data.ClassSeparator( typeof( RevitLinkInstance ) ) );

              data.Add( new Snoop.Data.Object( "Link Document", linkInst.GetLinkDocument() ) );
        }