Exemplo n.º 1
0
 protected override bool OnPostLocate(BD.HitPath path, out string cantAcceptReason)
 {
     BDE.Element ele = path.GetHeadElement();
     if (ele.ElementType != BD.MSElementType.Shape)
     {
         cantAcceptReason = Resources.PutArmorToolRejectReason;
         return(false);
     }
     BDE.ShapeElement shape            = ele as BDE.ShapeElement;
     BG.CurveVector   shapeCurveVector = shape.GetCurveVector();
     BG.DTransform3d  world2LoaclDTransform3D;
     BG.DTransform3d  loacl2WorlDTransform3D;
     BG.DRange3d      shapeRange3D;
     if (!shapeCurveVector.IsPlanar(out loacl2WorlDTransform3D, out world2LoaclDTransform3D, out shapeRange3D))
     {
         cantAcceptReason = Resources.PutArmorToolRejectReason2;
         return(false);
     }
     if (!IsRectangel(shapeCurveVector))
     {
         cantAcceptReason = Resources.PutArmorToolRejectReason3;
         return(false);
     }
     return(base.OnPostLocate(path, out cantAcceptReason));
 }
Exemplo n.º 2
0
        protected override bool OnDataButton(BD.DgnButtonEvent ev)
        {
            BD.HitPath hitPath = DoLocate(ev, true, 0);

            if (null != hitPath)
            {
                Element ele = hitPath.GetHeadElement();
                if (ele.ElementType != BD.MSElementType.Line)
                {
                    return(false);
                }
                BG.DRange3d linerange;
                if ((ele as LineElement).CalcElementRange(out linerange) != BD.StatusInt.Success)
                {
                    return(false);
                }
                TopPoint    = linerange.High;
                BottomPoint = linerange.Low;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        /*---------------------------------------------------------------------------------**//**
        * Actual modification on first data button if it lies on GroupedHole element.
        * @bsimethod                                                              Bentley Systems
        *  /*--------------+---------------+---------------+---------------+---------------+------*/
        protected override bool OnDataButton(Bentley.DgnPlatformNET.DgnButtonEvent ev)
        {
            //Locate an element.
            Bentley.DgnPlatformNET.HitPath hitPath = DoLocate(ev, true, 1);

            //If an element is located and the element is a grouped hole.
            //If element has a solid fill, remove it.
            //Else add a solid fill.
            if (null != hitPath)
            {
                int numHoles = PlaceGroupedHoleForm.GetNumberOfHoles();
                Bentley.DgnPlatformNET.Elements.Element element = hitPath.GetHeadElement();

                if (element is GroupedHoleElement)
                {
                    GroupedHoleElement groupedHoleElement = element as GroupedHoleElement;

                    uint fillColor;
                    bool alwaysFilled;
                    if (groupedHoleElement.GetSolidFill(out fillColor, out alwaysFilled))
                    {
                        groupedHoleElement.RemoveAreaFill();
                    }
                    else
                    {
                        groupedHoleElement.AddSolidFill((uint)Bentley.MstnPlatformNET.Settings.GetActiveFillColor().Index, false);
                    }

                    //Element must be replaced in model.
                    groupedHoleElement.ReplaceInModel(groupedHoleElement);
                }
            }

            return(true);
        }
Exemplo n.º 4
0
        protected override bool OnDataButton(BD.DgnButtonEvent ev)
        {
            BD.HitPath hitPath = DoLocate(ev, true, 1);
            if (null != hitPath)
            {
                BDDE.DgnECManager       manager = BDDE.DgnECManager.Manager;
                BDDE.FindInstancesScope scope   = BDDE.FindInstancesScope.CreateScope(hitPath.GetHeadElement(), new BDDE.FindInstancesScopeOption(BDDE.DgnECHostType.Element, true));
                BDEPQ.ECQuery           query   = new BDEPQ.ECQuery(Extension.Utilities.GetActiveModelAllClasses());
                query.SelectClause.SelectAllProperties = true;
                using (BDDE.DgnECInstanceCollection ecInstances = manager.FindInstances(scope, query))
                {
                    if (ecInstances == null)
                    {
                        return(false);
                    }
                    m_findinstacneOnElementViewModel.InstancesInfo.Clear();
                    //ObservableCollection<Instance> instanceCollection = new ObservableCollection<Instance>();
                    foreach (var ecin in ecInstances)
                    {
                        foreach (BES.IECProperty itemProp in ecin.ClassDefinition.Properties(false))
                        {
                            var instanceitem = new Instance();
                            instanceitem.ClassName    = ecin.ClassDefinition.DisplayLabel;
                            instanceitem.PropertyName = itemProp.Name;
                            string type = itemProp.Type.Name.ToLower();
                            instanceitem.TypeName = type;
                            BEI.IECPropertyValue propvalue = ecin.GetPropertyValue(itemProp.Name);

                            switch (type)
                            {
                            case "string":
                                instanceitem.PropertyValue = (propvalue != null) ? propvalue.StringValue : "";
                                break;

                            case "boolean":
                                instanceitem.PropertyValue = (propvalue != null) ? propvalue.StringValue : "";
                                break;

                            case "int":
                                instanceitem.PropertyValue = (propvalue != null) ? propvalue.IntValue.ToString() : "";
                                break;

                            case "double":
                                instanceitem.PropertyValue = (propvalue != null) ? propvalue.DoubleValue.ToString() : "";
                                break;
                            }
                            m_findinstacneOnElementViewModel.InstancesInfo.Add(instanceitem);
                        }
                    }
                    m_findinstacneOnElementViewModel.WindowTitle = hitPath.GetHeadElement().ElementId.ToString();
                }
            }
            return(true);
        }
Exemplo n.º 5
0
        protected override bool OnDataButton(BD.DgnButtonEvent ev)
        {
            BD.HitPath hitPath = DoLocate(ev, true, 1);
            if (null != hitPath)
            {
                InstanceToWrite instanceInfo = (WriteInstanceOnElementView.Instance.DataContext as WriteInstanceOnElementViewModel).GetInstanceToWrite();
                if (string.IsNullOrEmpty(instanceInfo.SchemaName) || string.IsNullOrEmpty(instanceInfo.ClassName) || instanceInfo.Properties.Count == 0)
                {
                    mc.StatusPrompt = "请先选择要附加的class";
                    return(false);
                }
                BDEC.FindInstancesScope scope  = BDEC.FindInstancesScope.CreateScope(Program.GetActiveDgnFile(), new BDEC.FindInstancesScopeOption());
                BES.IECSchema           schema = BDEC.DgnECManager.Manager.LocateSchemaInScope(scope, instanceInfo.SchemaName, instanceInfo.MajorVersion, instanceInfo.MinorVersion, BES.SchemaMatchType.Exact);
                BDE.Element             ele    = hitPath.GetHeadElement();

                BES.ECClass class1 = schema.GetClass(instanceInfo.ClassName) as BES.ECClass;
                BDEC.DgnECInstanceEnabler instanceEnabler = BDEC.DgnECManager.Manager.ObtainInstanceEnabler(Program.GetActiveDgnFile(), class1);
                BEI.StandaloneECDInstance instance        = instanceEnabler.SharedWipInstance;
                foreach (var pInfo in instanceInfo.Properties)
                {
                    switch (pInfo.PropertyType.ToLower())
                    {
                    case "string":
                        instance.MemoryBuffer.SetStringValue(pInfo.PropertyName, -1, pInfo.GetValueAsString());
                        break;

                    case "boolean":
                        instance.MemoryBuffer.SetBooleanValue(pInfo.PropertyName, -1, pInfo.GetValueAsBoolean());
                        break;

                    case "int":
                        instance.MemoryBuffer.SetIntegerValue(pInfo.PropertyName, -1, pInfo.GetValueAsInt());
                        break;

                    case "double":
                        instance.MemoryBuffer.SetDoubleValue(pInfo.PropertyName, -1, pInfo.GetValueAsDouble());
                        break;
                    }
                }
                instanceEnabler.CreateInstanceOnElement(ele, instance, false);
                mc.StatusPrompt  = "附加完成";
                mc.StatusMessage = $"将{instanceInfo.ClassName}附加到ID:{ele.ElementId}物体上";
            }

            return(true);
        }