コード例 #1
0
 internal ComboScheduleCreatorWin(RebarContainer rebars)
 {
     InitializeComponent();
     m_rebars = rebars;
     this.cb_schedule_types.ItemsSource =
         Enum.GetValues(typeof(ComboScheduleType));
     this.cb_partitions.ItemsSource =
         m_rebars.GetPartitions();
     this.cb_host_marks.ItemsSource =
         m_rebars.GetHostMarks((string)this.cb_partitions.SelectedValue);
     this.cb_assembly_marks.ItemsSource =
         m_rebars.GetAssemblies((string)this.cb_partitions.SelectedValue,
                                (string)this.cb_host_marks.SelectedValue);
 }
コード例 #2
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            // Add an EventLogTraceListener object
            System.Diagnostics.Trace.Listeners.Add(
                new System.Diagnostics.EventLogTraceListener("Application"));

            // Lay the hands on the active document
            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document   doc   = uidoc.Document;

            // Set up a timer
            Timing myTimer = new Timing();

            myTimer.StartTime();
            try {
                // Track down all partitions as well as map them
                // to host marks
                IDictionary <string, ISet <string> > partHostValues =
                    RebarsUtils.GetPartitionHostMarkDic(doc);

                RebarContainer rebarContainer = new RebarContainer();
                foreach (FamilyInstance fi in RebarsUtils.GetAllRebarsInDoc(doc))
                {
                    GeneralRebar rebar = new GeneralRebar(fi);
                    rebarContainer.Add(rebar);
                }

                // Dig up all host marks and map them
                // to assemblies
                IDictionary <string, ISet <string> > hostAssemblyValues =
                    rebarContainer.GetHostAssemblies();

                // Get hold of all partitions and
                // map them to structural types
                SortedList <string, SortedSet <string> > partsStrTypes =
                    TektaRevitPlugins.Multischedule.MultischeduleUtils.DigUpPartsStrTypes(doc);

                Schema schema =
                    ExtensibleStorageUtils.GetSchema(
                        SCHEMA_GUID, SCHEMA_NAME,
                        FN_PARTS_HOST_MARKS,
                        FN_HOST_MARKS_ASSEMBLIES,
                        FN_PARTS_STR_TYPES);

                DataStorage dataStorage =
                    ExtensibleStorageUtils.GetDataStorage(
                        doc, DATA_STORAGE_NAME);

                ExtensibleStorageUtils
                .AssignValues(schema,
                              dataStorage,
                              FN_PARTS_HOST_MARKS,
                              FN_HOST_MARKS_ASSEMBLIES,
                              FN_PARTS_STR_TYPES,
                              partHostValues,
                              hostAssemblyValues,
                              partsStrTypes);

                TaskDialog.Show("Success!", "Repository has been updated.");
                return(Result.Succeeded);
            }
            catch (Autodesk.Revit.Exceptions.OperationCanceledException) {
                return(Result.Cancelled);
            }
            catch (Exception ex) {
                TaskDialog.Show("Exception",
                                string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
                System.Diagnostics.Trace.Write(string.Format("{0}\n{1}",
                                                             ex.Message, ex.StackTrace));
                return(Result.Failed);
            }
            finally {
                myTimer.StopTime();
                System.Diagnostics.Trace
                .Write(string.Format("Time elapsed: {0}s",
                                     myTimer.Duration.TotalSeconds));
            }
        }