Пример #1
0
        public static List <ElementId> GetPipelineElementID(Document document, IList <ElementId> elementIds, ElementId origin_elementid)
        {
            List <ElementId> lstPipelineids = new List <ElementId>();

            lstPipelineids.Add(origin_elementid);
            while (elementIds.Count > 0)
            {
                ElementId        rootId       = lstPipelineids[lstPipelineids.Count - 1];      //take the last one of pipeline
                ConnectorSet     connectorSet = UIOperation.GetConnectorSet(document, rootId); //get all the connectors of the rootid
                List <ElementId> lstOtherConnectElementIds = new List <ElementId>();
                foreach (Connector c in connectorSet)
                {
                    ElementId id = UIOperation.GetAnotherIDAtConnector(rootId, c);
                    if (elementIds.Contains(id))
                    {
                        lstOtherConnectElementIds.Add(id);
                        lstPipelineids.Add(id);
                        elementIds.Remove(id);
                        break;
                    }
                }
                if (lstOtherConnectElementIds.Count == 0)
                {
                    break;
                }
            }
            return(lstPipelineids);
        }
Пример #2
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            ////test
            //Test.test(commandData, ref message, elements);
            //return Result.Succeeded;
            ////test

            UIApplication uIApplication = commandData.Application;
            UIDocument    uIDocument    = commandData.Application.ActiveUIDocument;
            Document      document      = uIDocument.Document;
            //Basic_Funs.SetProjectUnits(document, UnitType.UT_HVAC_Airflow, DisplayUnitType.DUT_CUBIC_METERS_PER_HOUR);

            //*************传统选取元素方法
            IList <ElementId> elementIds = new List <ElementId>();

            try
            {
                elementIds = UIOperation.SelectPipeline(uIDocument, document);
            }
            catch (Exception e)
            {
                TaskDialog.Show("Prompt", e.Message);
                return(Result.Failed);
            }
            if (elementIds.Count == 0)
            {
                TaskDialog.Show("Prompt", "HVAC Hydraulic Calculation App Quit!");
                return(Result.Failed);
            }
            //*****************按顺序录入管道系统(无组图元,组内非链接键连接则系统将分成两个部分),使用连接键,不使用碰撞
            List <ElementId> lstPipelineids   = new List <ElementId>();
            ElementId        origin_elementid = elementIds[elementIds.Count - 1];

            elementIds.Remove(origin_elementid); elementIds.Remove(origin_elementid);
            try
            {
                lstPipelineids = UIOperation.GetPipelineElementID(document, elementIds, origin_elementid);
            }
            catch (Exception e)
            {
                TaskDialog.Show("Prompt", e.Message);
                return(Result.Failed);
            }
            uIDocument.Selection.SetElementIds(lstPipelineids);
            return(Result.Succeeded);
        }