Exemplo n.º 1
0
        private void clearAppearance() //清除所有表达
        {
            Search search = new Search();

            search.Selection.SelectAll();

            //oDoc.Models.ResetAllPermanentMaterials();

            VariantData oData = VariantData.FromDisplayString("门");

            SearchCondition oSearchCondition = SearchCondition.HasPropertyByDisplayName("项目", "类型");

            oSearchCondition = oSearchCondition.EqualValue(oData);
            search.SearchConditions.Add(oSearchCondition);
            ModelItemCollection items = search.FindAll(oDoc, false);

            oDoc.Models.OverridePermanentColor(items, Autodesk.Navisworks.Api.Color.Blue);
            oDoc.Models.OverridePermanentTransparency(items, 0.5);

            Search search1 = new Search();

            search1.Selection.SelectAll();
            oData = VariantData.FromDisplayString("房间");

            oSearchCondition = SearchCondition.HasPropertyByDisplayName("项目", "类型");
            oSearchCondition = oSearchCondition.EqualValue(oData);
            search1.SearchConditions.Add(oSearchCondition);
            items = search1.FindAll(oDoc, false);
            oDoc.Models.OverridePermanentColor(items, Autodesk.Navisworks.Api.Color.White);
            oDoc.Models.OverridePermanentTransparency(items, 1);
            //oDoc.CurrentSelection.CopyFrom(items);
        }
Exemplo n.º 2
0
        private object createSearchSet(object name, object category, object property, object value)
        {
            //https://adndevblog.typepad.com/aec/2012/08/add-search-selectionset-in-net.html

            Document doc = Autodesk.Navisworks.Api.Application.ActiveDocument;

            //Create a new search object
            Search          s  = new Search();
            SearchCondition sc = SearchCondition.HasPropertyByDisplayName(category.ToString(), property.ToString());

            s.SearchConditions.Add(sc.EqualValue(VariantData.FromDisplayString(value.ToString())));


            //Set the selection which we wish to search
            s.Selection.SelectAll();
            s.Locations = SearchLocations.DescendantsAndSelf;

            //halt searching below ModelItems which match this
            s.PruneBelowMatch = true;

            //get the resulting collection by applying this search
            ModelItemCollection searchResults = s.FindAll(Autodesk.Navisworks.Api.Application.ActiveDocument, false);
            SelectionSet        selectionSet  = new SelectionSet();

            selectionSet.DisplayName = name.ToString();
            selectionSet.CopyFrom(s);
            Autodesk.Navisworks.Api.Application.ActiveDocument.SelectionSets.InsertCopy(0, selectionSet);
            var ss = Autodesk.Navisworks.Api.Application.ActiveDocument.SelectionSets.ToSavedItemCollection();


            return(ss);
        }
Exemplo n.º 3
0
        public HttpResponseMessage Put(int id, [FromBody][System.Web.Mvc.Bind(Include = "ProductId, BasePrice, Tax, InStock")] VariantModel variant)
        {
            HttpResponseMessage response;
            ModelsValidation    validation = new ModelsValidation();
            VariantData         data       = new VariantData();

            if (ModelState.IsValid)
            {
                if (validation.DoesVariantExist(id) == false)
                {
                    response = Request.CreateResponse(HttpStatusCode.NotFound, new { Message = "There is no variant with given Id parameter." });
                }
                else
                {
                    if (validation.DoesProductExist(variant.ProductId) == false)
                    {
                        response = Request.CreateResponse(HttpStatusCode.NotFound, new { Message = "There is no product with given Id parameter." });
                    }
                    else
                    {
                        data.UpdateVariantById(id, variant);
                        response = Request.CreateResponse(HttpStatusCode.NoContent);
                    }
                }
            }
            else
            {
                response = Request.CreateResponse(HttpStatusCode.NotFound, new { Message = "Model is invalid.", ModelValidation = "Product's id must be greater than 0. BasePrice, Tax and InStock must be a positive numbers." });
            }

            return(response);
        }
Exemplo n.º 4
0
        public HttpResponseMessage Delete(int id)
        {
            HttpResponseMessage response;
            ModelsValidation    validation = new ModelsValidation();
            VariantData         data       = new VariantData();

            if (validation.DoesVariantExist(id) == false)
            {
                response = Request.CreateResponse(HttpStatusCode.NotFound, new { Message = "There is no variant with given Id parameter." });
            }
            else
            {
                try
                {
                    data.DeleteVariantById(id);
                    response = Request.CreateResponse(HttpStatusCode.NoContent);
                }
                catch (SqlException sqlException)
                {
                    response = CheckSqlExceptionNumber(sqlException.Number);
                }
            }

            return(response);
        }
        private void SaveNewVariant(VariantData data)
        {
            _currentManufacturer = _manufacturers.Where(m => m.Name == data.Brand).FirstOrDefault();
            if (_currentManufacturer == null)
            {
                var manuturerName = GetAssociatedManufacturerName(data.Brand);
                _currentManufacturer = _manufacturers.Where(m => m.Name == manuturerName).FirstOrDefault();
                if (_currentManufacturer == null)
                {
                    _logger.Error("SaveVariant, missing manufacturer (" + _updaterName + "): '" + data.Brand + "'");
                    return;
                }
            }

            ProductAttributeCombination combination = _productAttributeCombinations.Where(p => p.Gtin == data.EAN).FirstOrDefault();

            if (combination == null)
            {
                // Now we have a new EAN number, lets find out if we also need to create a new product.
                Product product = _productsSKUAndName.Where(p => p.Sku == data.OrgItemNumber && p.Name == data.OriginalTitle).FirstOrDefault();
                if (product == null)
                {
                    // Only create the product if we have valid data
                    product = CreateProduct(data);
                    _newlyCreatedProducts++;
                }

                if (product != null)
                {
                    _newlyCreatePSC++;
                    throw new NotImplementedException("Mangler kode til at tilføje en ny combination (" + _updaterName + ")");
                }
            }
        }
        public static void SetSupplierProductId(this VariantData data)
        {
            string brand = data.Brand.ToLower();

            switch (brand)
            {
            case "tatonka":
            {
                if (data.SupplierProductId.Contains("-"))
                {
                    data.SupplierProductId = data.SupplierProductId.Substring(0, data.SupplierProductId.IndexOf("-"));
                }
                break;
            }

            default:
            {
                // This is to fix that STM often has itemnumbers specific for each variant, we need the actual productnumber
                // We need to check for 2 "-" as Gerber is using 1 "-" in some products not otherwise connected
                if (data.SupplierProductId.Contains("-") && data.SupplierProductId.IndexOf("-") != data.SupplierProductId.LastIndexOf("-"))
                {
                    data.SupplierProductId = data.SupplierProductId.Substring(0, data.SupplierProductId.IndexOf("-"));
                }

                break;
            }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Dump all properties from the given model item
        /// </summary>
        public static void DumpProperties(ModelItem mi)
        {
            // inspired by sample code from
            // 'Navisworks .NET API Properties' by Xiaodong Liang
            // https://adndevblog.typepad.com/aec/2012/05/navisworks-net-api-properties.html

            PropertyCategoryCollection pcs = mi.PropertyCategories;
            int n = pcs.Count <PropertyCategory>();

            Debug.Print("{0} property categories:", n);
            foreach (PropertyCategory pc in pcs)
            {
                Debug.Print("{0} ({1})", pc.DisplayName, pc.Name);

                foreach (DataProperty dp in pc.Properties)
                {
                    VariantData     v = dp.Value;
                    VariantDataType t = v.DataType;

                    Debug.Print("  {0} ({1}) = {2} ({3})",
                                dp.DisplayName, dp.Name,
                                GetPropertyValue(dp, true), t.ToString());
                }
            }
        }
Exemplo n.º 8
0
        private void OrganizeData()
        {
            if (_variantsNodeList == null || _variantsNodeList.Count == 0)
            {
                return;
            }

            VariantData data;

            _variantData = new List <VariantData>();
            foreach (XmlNode node in _variantsNodeList)
            {
                data     = new VariantData();
                data.EAN = node["BARCODE"].InnerText.Trim().Replace("-", "");
                if (string.IsNullOrEmpty(data.EAN) || data.EAN.Length < 10)
                {
                    continue;
                }

                data.OrgItemNumber = data.SupplierProductId = node["ITEMNUMBER"].InnerText;
                data.Brand         = node["BRAND"].InnerText;
                data.SetSupplierProductId();
                data.OriginalTitle = data.Title = node["ITEMNAME"].InnerText.Trim();
                data.StockCount    = Convert.ToInt32(node["INVENTORY"].InnerText.Trim());
                data.RetailPrice   = Math.Round(Convert.ToDecimal(node["SALESPRICE"].InnerText.Trim(), CultureInfo.InvariantCulture), 2);
                data.SizeStr       = (node["SIZE"].InnerText.Trim().ToLower() == "stk." || node["SIZE"].InnerText.Trim().ToLower() == "-") ? "" : node["SIZE"].InnerText.Trim();
                data.SetSizeString();
                data.ColorStr = node["COLOR"].InnerText.Trim();

                _variantData.Add(data);
            }

            _variantData = _variantData.Skip(_stmSettings.SkipNumber).Take(_takeNumber).ToList().Take(1).ToList();
        }
Exemplo n.º 9
0
        public HttpResponseMessage Post(VariantModel variant)
        {
            HttpResponseMessage response;
            ModelsValidation    validation = new ModelsValidation();
            VariantData         data       = new VariantData();

            if (ModelState.IsValid)
            {
                if (validation.DoesProductExist(variant.ProductId) == true)
                {
                    data.SaveVariant(variant);
                    response = Request.CreateResponse(HttpStatusCode.Created);
                }
                else
                {
                    response = Request.CreateResponse(HttpStatusCode.NotFound, new { Message = "There is no product with given Id parameter." });
                }
            }
            else
            {
                response = Request.CreateResponse(HttpStatusCode.NotFound, new { Message = "Model is invalid.", ModelValidation = "Product's id must be greater than 0. BasePrice, Tax and InStock must be a positive numbers." });
            }

            return(response);
        }
Exemplo n.º 10
0
        private object createSearch(object category, object property, object value, object Negate)
        {
            //https://adndevblog.typepad.com/aec/2012/08/add-search-selectionset-in-net.html

            Document doc = Autodesk.Navisworks.Api.Application.ActiveDocument;

            //Create a new search object
            Search          s      = new Search();
            SearchCondition sc     = SearchCondition.HasPropertyByDisplayName(category.ToString(), property.ToString());
            bool            negate = Negate != null?bool.Parse(Negate.ToString()) : false;

            if (negate)
            {
                sc = sc.Negate();
            }


            s.SearchConditions.Add(sc.EqualValue(VariantData.FromDisplayString(value.ToString())));


            //Set the selection which we wish to search
            s.Selection.SelectAll();
            s.Locations = SearchLocations.DescendantsAndSelf;

            //halt searching below ModelItems which match this
            s.PruneBelowMatch = true;

            return(s);
        }
 public static void SetSizeString(this VariantData data)
 {
     if (string.IsNullOrEmpty(data.SizeStr) && data.OriginalTitle.Contains("\"\""))
     {
         string tmpSize = data.OriginalTitle.Substring(data.OriginalTitle.IndexOf("\"\""));
         tmpSize      = tmpSize.Replace("\"", "").Trim();
         data.SizeStr = tmpSize;
     }
 }
Exemplo n.º 12
0
        private void OrganizeData()
        {
            return;

            _variantData = File.ReadAllLines(@"" + _destinationPath)
                           .Skip(1)
                           .Select(t => VariantData.FromCsv(t, ';'))
                           .Where(y => y != null)
                           .ToList();
        }
Exemplo n.º 13
0
        internal bool DoesVariantExist(int id)
        {
            bool exist = true;

            VariantData variantData = new VariantData();
            var         data        = variantData.GetVariantById(id);

            if (data == null)
            {
                exist = false;
            }

            return(exist);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Aula/Lesson 9
        /// </summary>
        private void btCreateSearch_MouseUp(object sender, MouseEventArgs e)
        {
            var ac = NavisworksApp.ActiveDocument;
            var cs = ac.CurrentSelection;
            var ss = ac.SelectionSets;

            var fn = "Saved Search";
            var sn = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss.fff");

            try
            {
                var s = new Search();
                s.Selection.SelectAll();
                s.Locations = SearchLocations.DescendantsAndSelf;

                var sc = SearchCondition.HasPropertyByDisplayName(tbCatName.Text, tbPropName.Text);
                s.SearchConditions.Add(sc.EqualValue(VariantData.FromDisplayString(tbValueName.Text)));

                var sSet = new SelectionSet(s)
                {
                    DisplayName = sn
                };
                ss.AddCopy(sSet);

                var fi = ss.Value.IndexOfDisplayName(fn);

                if (fi == -1)
                {
                    var sf = new FolderItem()
                    {
                        DisplayName = fn
                    };
                    ss.AddCopy(sf);
                }

                fi = ss.Value.IndexOfDisplayName(fn);
                var fo = ss.Value[fi] as FolderItem;

                var si = ss.Value.IndexOfDisplayName(sn);
                var se = ss.Value[si] as SavedItem;

                ss.Move(se.Parent, si, fo, 0);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void UpdateStock(VariantData data)
        {
            ProductAttributeCombination combination = _productAttributeCombinations.Where(p => p.Gtin == data.EAN).FirstOrDefault();

            if (combination == null)
            {
                _variantDataToBeCreated.Add(data);
                Thread.Sleep(50);
            }
            else
            {
                combination.StockQuantity = data.StockCount;
                _productAttributeService.UpdateProductAttributeCombination(combination);
                _updatedPSCs++;
            }
        }
        private Product CreateProduct(VariantData data)
        {
            var product = new Product();

            product.Name         = data.Title;
            product.Price        = data.RetailPrice;
            product.ProductCost  = data.CostPrice;
            product.Sku          = product.ManufacturerPartNumber = data.OrgItemNumber;
            product.CreatedOnUtc = DateTime.UtcNow;
            product.UpdatedOnUtc = DateTime.UtcNow;
            _productService.InsertProduct(product);

            AddManufacturerToProduct(product.Id, _currentManufacturer.Id);

            return(product);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Aula 8
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btCreateSearch_MouseUp(object sender, MouseEventArgs e)
        {
            var ac = App.ActiveDocument;
            var cs = ac.CurrentSelection;
            var se = ac.SelectionSets;

            var fn = "Search Sets";             //Nome da pasta de set selection
            var sn = Guid.NewGuid().ToString(); //Nome do set selection

            try
            {
                var fi = se.Value.IndexOfDisplayName(fn);
                if (fi == -1)
                {
                    //Cria pasta de sets de seleçao dos itens
                    se.AddCopy(new FolderItem()
                    {
                        DisplayName = fn
                    });
                }

                //Cria seleção dos itens selecionados
                var s = new Search();
                s.Locations = SearchLocations.DescendantsAndSelf;
                s.Selection.SelectAll();

                var sc = SearchCondition.HasPropertyByDisplayName(this.tbCategoryName.Text, this.tbPropertyName.Text);
                s.SearchConditions.Add(sc.EqualValue(VariantData.FromDisplayString(this.tbPropertyValue.Text)));

                var set = new SelectionSet(s)
                {
                    DisplayName = sn
                };

                //Insere set de seleção
                se.AddCopy(set);

                var fo = se.Value[se.Value.IndexOfDisplayName(fn)] as FolderItem;
                var ns = se.Value[se.Value.IndexOfDisplayName(fn)] as SavedItem;

                //Move o set para a pasta no indice novo
                se.Move(ns.Parent, se.Value.IndexOfDisplayName(fn), fo, 0);
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 18
0
        public IEnumerable <TaskVariant> GetTaskVariants(IEnumerable <TaskModule> modules)
        {
            var idCounter = 0;

            var sampleData = new VariantData <Graph>
            {
                Type  = VariantDataType.Graph,
                Value = new Graph
                {
                    Vertices = new[] { "1", "2", "3", "4", "5" },
                    Edges    = new[]
                    {
                        new Edge {
                            Source = "1", Target = "2"
                        },
                        new Edge {
                            Source = "2", Target = "3"
                        },
                        new Edge {
                            Source = "3", Target = "4"
                        },
                        new Edge {
                            Source = "4", Target = "5"
                        },
                        new Edge {
                            Source = "5", Target = "1"
                        }
                    }
                }
            };

            foreach (var taskModule in modules)
            {
                for (var i = 0; i < 3; i++)
                {
                    idCounter++;
                    yield return(new TaskVariant
                    {
                        Id = idCounter,
                        Name = $"Вариант {idCounter}",
                        TaskModule = taskModule,
                        VariantData = JsonConvert.SerializeObject(new [] { sampleData })
                    });
                }
            }
        }
Exemplo n.º 19
0
        public HttpResponseMessage Get([FromUri] VariantFilter filter)
        {
            VariantData           data     = new VariantData();
            List <VariantDBModel> variants = data.GetVariants(filter);

            HttpResponseMessage response;

            if (variants.Count() <= 0)
            {
                response = Request.CreateResponse(HttpStatusCode.NotFound, new { Message = "No data found matching given parameters values." });
            }
            else
            {
                response = Request.CreateResponse(HttpStatusCode.OK, variants);
            }

            return(response);
        }
Exemplo n.º 20
0
        public RvtProperties(ModelItem mi)
        {
            PropertyCategory pc_Item
                = mi.PropertyCategories.FindCategoryByName(
                      PropertyCategoryNames.Item);

            DataProperty dp
                = pc_Item.Properties.FindPropertyByName(
                      DataPropertyNames.ItemSourceFileName);

            if (null != dp)
            {
                string source_filename = dp.Value.ToDisplayString();

                Debug.Assert(source_filename.EndsWith(".rvt"),
                             "expected Revit source file");
            }

            PropertyCategory pc_Element
                = mi.PropertyCategories
                  .FindCategoryByDisplayName("Element");

            dp = pc_Element.Properties
                 .FindPropertyByDisplayName("Level");

            NamedConstant nc_level = dp.Value.ToNamedConstant();

            Level = nc_level.Name;

            PropertyCategory pc_ElementId
                = mi.PropertyCategories.FindCategoryByName(
                      PropertyCategoryNames.RevitElementId);

            dp = pc_ElementId.Properties.FindPropertyByName(
                DataPropertyNames.RevitElementIdValue);

            VariantData v = dp.Value;

            Debug.Assert(v.IsDisplayString,
                         "expected Revit element id as DisplayString");

            ElementId = int.Parse(
                dp.Value.ToDisplayString());
        }
Exemplo n.º 21
0
 protected void AddVariant(VariantData newItem)
 {
     foreach (var item in m_Variants)
     {
         if (item.requirement.values == newItem.requirement.values)
         {
             throw new Exception("The given requirement has been already added");
         }
         if (System.IO.Path.GetFileName(item.path) == System.IO.Path.GetFileName(path))
         {
             throw new Exception("Two items within the same set must not have the same file name");
         }
     }
     if (System.IO.Path.GetFileName(newItem.path) == "Contents.json")
     {
         throw new Exception("The file name must not be equal to Contents.json");
     }
     m_Variants.Add(newItem);
 }
Exemplo n.º 22
0
        /// <summary>
        /// Строковое отображение значения свойства без приставки типа данных
        /// TODO: Если тип данных - double, то...?
        /// ТОЛЬКО ДЛЯ ПОЛЬЗОВАТЕЛЬСКИХ АТРИБУТОВ!
        /// </summary>
        /// <param name="variantData"></param>
        /// <returns></returns>
        public static string GetDisplayValue(VariantData variantData)
        {
            string dispValue = "";

            if (variantData.IsNamedConstant)
            {
                dispValue = variantData.ToNamedConstant().DisplayName;
            }
            else
            {
                string[] strs = variantData.ToString().Split(':');
                dispValue = String.Join(":", strs, 1, strs.Length - 1);
                if (dispValue == null)
                {
                    dispValue = "";
                }
            }

            return(dispValue);
        }
        private void OrganizeData()
        {
            FileInfo fileInfo = new FileInfo(@"" + _destinationPath);

            if (fileInfo == null)
            {
                throw new IOException("No file found here: @" + _destinationPath);
            }

            if (FileHelper.IsFileLocked(fileInfo) == false)
            {
                _variantData = File.ReadAllLines(@"" + _destinationPath)
                               .Skip(1)
                               .Select(t => VariantData.FromCsv(t, ';'))
                               .Where(y => y != null)
                               .ToList();
            }
            else
            {
                _logger.Warning("File was locked, probably because its beeing written to by IntersurfScheduleFetcher. Its ok, we run later again.");
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// НЕЛЬЗЯ НАСТРОИТЬ ПОИСК ТОЛЬКО НЕСКРЫТЫХ ОБЪЕКТОВ
        /// </summary>
        /// <param name="searchForAllIDs"></param>
        public static void ConfigureSearchForAllGeometryItemsWithIds(Search searchForAllIDs, bool idNecessary = true)
        {
            if (idNecessary)
            {
                //Имеет свойство Id
                SearchCondition hasIdCondition = SearchCondition.HasPropertyByCombinedName(tabCN, idCN);
                searchForAllIDs.SearchConditions.Add(hasIdCondition);
            }

            //Является геометрией (проверяется по типу иконки узла Navis)
            NamedConstant namedConstant = new NamedConstant(8, "LcOaNodeIcon" /*, "Геометрия"*/);
            VariantData   geometryIcon  = new VariantData(namedConstant);

            searchForAllIDs.SearchConditions.Add(
                new SearchCondition(new NamedConstant("LcOaNode", "Элемент"), new NamedConstant("LcOaNodeIcon", "Значок"),
                                    SearchConditionOptions.IgnoreDisplayNames, SearchConditionComparison.Equal, geometryIcon));

            //Не скрыт. ЭТО НЕ РАБОТАЕТ!!!!
            //VariantData boolFalse = new VariantData(false);
            //searchForAllIDs.SearchConditions.Add(
            //    new SearchCondition(new NamedConstant("LcOaNode", "Элемент"), new NamedConstant("LcOaNodeHidden", "Скрытый"),
            //    SearchConditionOptions.IgnoreDisplayNames, SearchConditionComparison.Equal, boolFalse));
        }
Exemplo n.º 25
0
        public HttpResponseMessage Get(int id)
        {
            if (id <= 0)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, new { Message = "Id parameter must be greater than 0." }));
            }

            VariantData    data    = new VariantData();
            VariantDBModel variant = data.GetVariantById(id);

            HttpResponseMessage response;

            if (variant == null)
            {
                response = Request.CreateResponse(HttpStatusCode.NotFound, new { Message = "No data found matching given parameters values." });
            }
            else
            {
                response = Request.CreateResponse(HttpStatusCode.OK, variant);
            }

            return(response);
        }
Exemplo n.º 26
0
 /// <summary>
 /// Получить значение свойства, которое можно присвоить пользовательскому свойству
 /// </summary>
 /// <param name="variantData"></param>
 /// <returns></returns>
 public static object GetUserPropValue(VariantData variantData)
 {
     if (variantData.IsDisplayString)
     {
         return(variantData.ToDisplayString());
     }
     else if (variantData.IsBoolean)
     {
         return(variantData.ToBoolean());
     }
     else if (variantData.IsDouble)
     {
         return(variantData.ToDouble());
     }
     else if (variantData.IsInt32)
     {
         return(variantData.ToInt32());
     }
     else
     {
         //Если свойство имеет какой-то другой тип данных то возвращается строка
         return(GetDisplayValue(variantData));
     }
 }
Exemplo n.º 27
0
        public IResult GetEntities(string type, string dataPropertyNames)
        {
            var returnresult = new Result_Model();

            Search s = new Search();

            s.SearchConditions.Add(SearchCondition.HasCategoryByName(PropertyCategoryNames.Geometry));
            s.SearchConditions.Add(SearchCondition.HasPropertyByName(PropertyCategoryNames.Item, DataPropertyNames.ItemHidden).EqualValue(VariantData.FromBoolean(false)));
            s.SearchConditions.Add(SearchCondition.HasPropertyByName(PropertyCategoryNames.Item, dataPropertyNames).EqualValue(VariantData.FromDisplayString(type)));
            s.Selection.SelectAll();
            s.Locations = SearchLocations.DescendantsAndSelf;

            var result = s.FindAll(Application.ActiveDocument, false);

            result.ToList().ForEach(model => returnresult.Payload.Add(model));

            return(returnresult);
        }
Exemplo n.º 28
0
        private void ButSelect_Click(object sender, EventArgs e)
        {
            Document oDoc = Autodesk.Navisworks.Api.Application.ActiveDocument;

            Search search = new Search();

            search.Selection.SelectAll();
            //元素ID是int32类型,所以Displaystring找不到
            search.SearchConditions.Add(SearchCondition.HasPropertyByDisplayName("元素", "Id").EqualValue(VariantData.FromInt32(1243755)));

            ModelItemCollection items = search.FindAll(oDoc, true);

            if (items.Count == 0)
            {
                MessageBox.Show("未找到目标!");
                return;
            }
            oDoc.CurrentSelection.CopyFrom(items);
        }
Exemplo n.º 29
0
        private void ButFocus_Click(object sender, EventArgs e)//在NW中选择当前选择记录的
        {
            Document Doc        = Autodesk.Navisworks.Api.Application.ActiveDocument;
            TabPage  curTabPage = this.TCL1OfQF.SelectedTab;//获取当前选择的tab页面
            string   strId      = "";

            foreach (Control control in curTabPage.Controls) //遍历控件
            {
                if (control is DataGridView)                 //如果是datagridview,则在视图中选择元素
                {
                    DataGridView dgv = (DataGridView)control;
                    if (dgv.SelectedRows.Count == 0)
                    {
                        MessageBox.Show("未选中行!");
                        return;
                    }
                    for (int i = 0; i < dgv.SelectedRows.Count; i++)
                    {
                        strId = dgv.SelectedRows[i].Cells[0].Value.ToString();
                    }
                    Search search = new Search();
                    search.Selection.SelectAll();
                    //元素ID是int32类型,所以Displaystring找不到
                    search.SearchConditions.Add(SearchCondition.HasPropertyByDisplayName("元素", "Id").EqualValue(VariantData.FromInt32(Int32.Parse(strId))));

                    ModelItemCollection items = search.FindAll(Doc, true);
                    Doc.CurrentSelection.Clear();
                    Doc.CurrentSelection.CopyFrom(items);
                    if (items.Count > 0)
                    {
                        MessageBox.Show("已在视图中选中该元素!", "提示");
                    }
                }
            }
        }
Exemplo n.º 30
0
        public static object GetPropertyValue(
            DataProperty dp,
            bool return_string)
        {
            VariantData     v = dp.Value;
            VariantDataType t = v.DataType;
            object          o = null;

            switch (t)
            {
            // Empty. No data stored.
            case VariantDataType.None:
                o = return_string ? "<null>" : null;
                break;

            // Unitless double value
            case VariantDataType.Double:
                o = return_string
            ? (object)Util.RealString(v.ToDouble())
            : v.ToDouble();
                break;

            // Unitless 32 bit integer value
            case VariantDataType.Int32:
                o = return_string
            ? (object)v.ToInt32().ToString()
            : v.ToInt32();
                break;

            // Boolean (true/false) value
            case VariantDataType.Boolean:
                o = return_string
            ? (object)(v.ToBoolean() ? "true" : "false")
            : v.ToBoolean();
                break;

            // String intended for display to the end user (normally localized)
            case VariantDataType.DisplayString:
                o = v.ToDisplayString();
                break;

            // A specific date and time (usually UTC)
            case VariantDataType.DateTime:
                o = return_string
            ? (object)v.ToDateTime().ToShortTimeString()
            : v.ToDateTime();
                break;

            // A double that represents a length (specific units depend on context)
            case VariantDataType.DoubleLength:
                o = return_string
            ? (object)Util.RealString(v.ToDoubleLength())
            : v.ToDoubleLength();
                break;

            // A double that represents an angle in radians
            case VariantDataType.DoubleAngle:
                o = return_string
            ? (object)Util.RealString(v.ToDoubleAngle())
            : v.ToDoubleAngle();
                break;

            // A named constant
            case VariantDataType.NamedConstant:
                o = return_string
            ? (object)v.ToNamedConstant().ToString()
            : v.ToNamedConstant();
                break;

            // String intended to be used as a programmatic identifier. 7-bit ASCII characters
            // only.
            case VariantDataType.IdentifierString:
                o = v.ToIdentifierString();
                break;

            // A double that species an area (specific units depend on context)
            case VariantDataType.DoubleArea:
                o = return_string
            ? (object)Util.RealString(v.ToDoubleArea())
            : v.ToDoubleArea();
                break;

            // A double that species a volume (specific units depend on context)
            case VariantDataType.DoubleVolume:
                o = return_string
            ? (object)Util.RealString(v.ToDoubleVolume())
            : v.ToDoubleVolume();
                break;

            // A 3D point value
            case VariantDataType.Point3D:
                o = return_string
            ? (object)Util.PointString(v.ToPoint3D())
            : v.ToPoint3D();
                break;

            // A 2D point value
            case VariantDataType.Point2D:
                o = return_string
            ? (object)Util.PointString(v.ToPoint2D())
            : v.ToPoint2D();
                break;
            }
            return(o);
        }