private void gotoSheetBtn_Click(object sender, EventArgs e)
        {
            if (dtgView.SelectedRows.Count == 0)
            {
                return;
            }
            string sid = dtgView.SelectedRows[0].Cells[id.Name].Value.ToString();
            int    i;

            if (!int.TryParse(sid, out i))
            {
                return;
            }
            ElementId elementId = new ElementId(i);

            if (elementId == ElementId.InvalidElementId)
            {
                return;
            }
            CegImportInstanceInfor importInstanceInfor =
                CegFindImportInstance.Instance.GetImportInstanceInfor(_data.InstanceList, elementId);

            _data.GotoSheet = true;
            _data.SheetId   = importInstanceInfor.SheetId;
            _data.ImportId  = elementId;
        }
Exemplo n.º 2
0
        public CegImportInstanceInfor GetImportInstanceInfor(List <CegImportInstanceInfor> importInstanceInfors,
                                                             ElementId elementId)
        {
            CegImportInstanceInfor importInstanceInfor = new CegImportInstanceInfor();

            foreach (CegImportInstanceInfor instanceInfor in importInstanceInfors)
            {
                if (instanceInfor.Id.IntegerValue == elementId.IntegerValue)
                {
                    importInstanceInfor = instanceInfor;
                }
            }
            return(importInstanceInfor);
        }
Exemplo n.º 3
0
        // Function
        public List <CegImportInstanceInfor> GetImportInsntaceInfors(Document doc)
        {
            List <CegImportInstanceInfor> importInsntaces = new List <CegImportInstanceInfor>();
            FilteredElementCollector      collector       = new FilteredElementCollector(doc);
            IList <Element> elements = collector.OfClass(typeof(ImportInstance)).ToElements();
            Dictionary <ElementId, ElementId> viewSheetDict = ViewSheetDict(doc);

            foreach (Element element in elements)
            {
                ImportInstance importInstance = element as ImportInstance;
                if (importInstance == null)
                {
                    continue;
                }
                CegImportInstanceInfor importInsntaceInfor = new CegImportInstanceInfor();
                string name = importInstance.Category.Name;
                importInsntaceInfor.Name = name;
                importInsntaceInfor.Id   = element.Id;
                View view = doc.GetElement(importInstance.OwnerViewId) as View;
                if (view == null)
                {
                    continue;
                }
                importInsntaceInfor.ViewId   = view.Id;
                importInsntaceInfor.ViewName = view.ViewName;
                if (viewSheetDict.ContainsKey(view.Id))
                {
                    ViewSheet viewSheet = doc.GetElement(viewSheetDict[view.Id]) as ViewSheet;
                    if (viewSheet != null)
                    {
                        importInsntaceInfor.SheetId     = viewSheet.Id;
                        importInsntaceInfor.SheetName   = viewSheet.Name;
                        importInsntaceInfor.SheetNumber = viewSheet.SheetNumber;
                    }
                }
                importInsntaces.Add(importInsntaceInfor);
            }
            return(importInsntaces);
        }