Esempio n. 1
0
 public LineWeightSettings()
 {
     ForegroundElementsSettings = new LineWeightSettingItem();
     Middle1ElementsSettings    = new LineWeightSettingItem();
     Middle2ElementsSettings    = new LineWeightSettingItem();
     Middle3ElementsSettings    = new LineWeightSettingItem();
     BackgroundElementsSettings = new LineWeightSettingItem();
 }
Esempio n. 2
0
        private bool SetLineWeight(IEnumerable <ElementId> elementIds, int elementsLocation)
        {
            try
            {
                LineWeightSettingItem lineWeightSetting = null;
                switch (elementsLocation)
                {
                case 0:
                    lineWeightSetting = _lineWeightSettings.ForegroundElementsSettings;
                    break;

                case 1:
                    lineWeightSetting = _lineWeightSettings.Middle1ElementsSettings;
                    break;

                case 2:
                    lineWeightSetting = _lineWeightSettings.Middle2ElementsSettings;
                    break;

                case 3:
                    lineWeightSetting = _lineWeightSettings.Middle3ElementsSettings;
                    break;

                case 4:
                    lineWeightSetting = _lineWeightSettings.BackgroundElementsSettings;
                    break;
                }

                foreach (var elementId in elementIds)
                {
                    var overrideGraphicSettings = _activeUIDocument.ActiveView.GetElementOverrides(elementId);
                    if (lineWeightSetting.IsProjection)
                    {
                        overrideGraphicSettings.SetProjectionLineWeight(lineWeightSetting.LineWeight);
                    }
                    else
                    {
                        overrideGraphicSettings.SetCutLineWeight(lineWeightSetting.LineWeight);
                    }

                    _activeUIDocument.ActiveView.SetElementOverrides(elementId, overrideGraphicSettings);
                }

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(false);
        }