Пример #1
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            //
            DllActivator_eZRvt dat = new DllActivator_eZRvt();

            dat.ActivateReferences();
            //
            UIApplication uiApp = commandData.Application;
            UIDocument    uiDoc = uiApp.ActiveUIDocument;
            Document      doc   = uiApp.ActiveUIDocument.Document;

            using (Transaction transDoc = new Transaction(doc, "DebugTest"))
            {
                try
                {
                    transDoc.Start();

                    MessageBox.Show("进入调试");

                    transDoc.Commit();
                    return(Result.Succeeded);
                }
                catch (Exception ex)
                {
                    transDoc.RollBack();
                    return(Result.Failed);
                }


                return(Result.Succeeded);
            }
        }
Пример #2
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            //
            DllActivator_eZRvt dat = new DllActivator_eZRvt();

            dat.ActivateReferences();
            //

            Document massFamilyDoc = commandData.Application.ActiveUIDocument.Document;

            using (Transaction trans = new Transaction(massFamilyDoc, "d"))
            {
                try
                {
                    trans.Start();
                    // 在体量族文档中创建 拉伸 Form
                    CreateExtrusionForm(massFamilyDoc);

                    trans.Commit();
                    return(Result.Succeeded);
                }
                catch (Exception ex)
                {
                    trans.RollBack();
                    message = ex.Message;
                    return(Result.Failed);
                }
            }
        }
Пример #3
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            //
            DllActivator_eZRvt dat = new DllActivator_eZRvt();

            dat.ActivateReferences();
            //
            MpFaceOptions mpf = MpFaceOptions.UniqueObject(commandData.Application);

            mpf.Show();
            return(Result.Succeeded);
        }
Пример #4
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            //
            DllActivator_eZRvt dat = new DllActivator_eZRvt();

            dat.ActivateReferences();
            //
            UIApplication uiApp = commandData.Application;
            UIDocument    uiDoc = uiApp.ActiveUIDocument;
            Document      doc   = uiApp.ActiveUIDocument.Document;

            // 是否只根据平面来创建工作平面,而不考虑曲面
            bool planarFaceOnly = true;

            if (planarFaceOnly)
            {
                return(SetWorkPlaneFromPlanarFace(uiDoc, doc));
            }
            else
            {
                return(SetWorkPlaneFromAnyFace(uiDoc, doc));
            }
        }
Пример #5
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            //
            DllActivator_eZRvt dat = new DllActivator_eZRvt();

            dat.ActivateReferences();
            //
            UIDocument uiDoc = commandData.Application.ActiveUIDocument;
            Document   doc   = commandData.Application.ActiveUIDocument.Document;

            //
            ConduitLevelFilter clf = ConduitLevelFilter.GetUniqueConduitLevelFilter(uiDoc);
            DialogResult       res = clf.ShowDialog();

            if (res != DialogResult.OK)
            {
                return(Result.Cancelled);
            }

            //
            FilterOption filterOptions = clf.FilterOptions;


            // 过滤出来的线管与弯头对象
            var elems = uiDoc.Selection.GetElementIds();
            List <ConduitLine> lines = FilterConduits(doc, elems);

            //   uiDoc.Selection.SetElementIds(lines.Select(r => r.Line.Id).ToList());

            //
            using (Transaction transa = new Transaction(doc, "线管布线"))
            {
                try
                {
                    transa.Start();

                    bool             inRange;
                    List <ElementId> elemsInRange  = new List <ElementId>();
                    List <ElementId> elemsOutRange = new List <ElementId>();
                    foreach (ConduitLine line in lines)
                    {
                        // 检查此线管是否要被隐藏
                        if (filterOptions.CheckAllConnector) // 此线管中只要有一个 Connector 不在视图范围内,则将其隐藏
                        {
                            inRange = true;
                            foreach (Connector connector in line.ConnectorManager.Connectors)
                            {
                                if (!IsWithinElevationRange(connector.Origin.Z, filterOptions))
                                {
                                    inRange = false;
                                    continue;
                                }
                            }
                        }
                        else // 此线管中只要有一个 Connector 在视图范围内,则不将其隐藏
                        {
                            inRange = false;
                            foreach (Connector connector in line.ConnectorManager.Connectors)
                            {
                                if (IsWithinElevationRange(connector.Origin.Z, filterOptions))
                                {
                                    inRange = true;
                                    continue;
                                }
                            }
                        }

                        if (inRange)
                        {
                            elemsInRange.Add(line.Line.Id);
                        }
                        else
                        {
                            elemsOutRange.Add(line.Line.Id);
                        }
                    }

                    View v = uiDoc.ActiveView;
                    // 先解除临时隐藏模式
                    v.DisableTemporaryViewMode(TemporaryViewMode.TemporaryHideIsolate);

                    // 隐藏线管
                    if (filterOptions.ShowElementsInRange)
                    {
                        // if (elemsInRange.Count > 0) v.UnhideElements(elemsInRange);
                        //
                        if (elemsOutRange.Count > 0)
                        {
                            v.HideElementsTemporary(elemsOutRange);
                        }
                    }
                    else
                    {
                        if (elemsInRange.Count > 0)
                        {
                            v.HideElementsTemporary(elemsInRange);
                        }
                        // if (elemsOutRange.Count > 0) v.UnhideElements(elemsOutRange);
                    }

                    transa.Commit();
                    return(Result.Succeeded);

                    ;
                }
                catch (Exception ex)
                {
                    transa.RollBack();

                    message = ex.Message + "\r\n" + ex.StackTrace;
                    return(Result.Failed);

                    ;
                }
            }
        }
Пример #6
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            //
            DllActivator_eZRvt dat = new DllActivator_eZRvt();

            dat.ActivateReferences();
            //
            UIDocument uiDoc = commandData.Application.ActiveUIDocument;
            Document   doc   = uiDoc.Document;

            var t = uiDoc.ActiveView.Id.IntegerValue == uiDoc.ActiveGraphicalView.Id.IntegerValue;

            // 选择 配电箱 与 线管
            FamilyInstance cab;
            List <Conduit> conduits;

            Result selectionResult;

            selectionResult = SelectCabinet_Conduits(uiDoc, out cab, out conduits, ref message);
            if (selectionResult == Result.Succeeded)
            {
                MEPElectricalEquipment         cabinet       = new MEPElectricalEquipment(cab);
                Dictionary <ElementId, string> errorConduits = new Dictionary <ElementId, string>();
                // 将每一条线管分别连接到电气设备上
                foreach (Conduit cd in conduits)
                {
                    using (Transaction transa = new Transaction(doc, "线管布线"))
                    {
                        try
                        {
                            transa.Start();

                            ConduitFittingMEP conduitFittingMEP = new ConduitFittingMEP(cabinet, cd);

                            FamilyInstance elbow = conduitFittingMEP.Connect(transa);

                            transa.Commit();
                        }
                        catch (Exception ex)
                        {
                            errorConduits.Add(cd.Id, ex.Message);

                            string elemInfo = "    出错线管 Id : " + cd.Id.ToString();
                            transa.RollBack();

                            //
                            // Utils.ShowDebugCatch(ex, elemInfo);
                        }
                    }
                }

                //
                if (errorConduits.Count > 0)
                {
                    // 处理出错信息
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("出错的线管与出错原因:");

                    int index = 0;
                    foreach (var errorConduit in errorConduits)
                    {
                        index += 1;
                        sb.AppendLine(index.ToString() + ". " + errorConduit.Key.ToString());
                        sb.AppendLine(errorConduit.Value);
                    }

                    //
                    MessageBox.Show(sb.ToString(), "部分线管绘制出错", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    uiDoc.Selection.SetElementIds(errorConduits.Keys);
                }
                return(Result.Succeeded);
            }

            else
            {
                return(selectionResult);

                ;
            }
        }