Exemple #1
0
        public int Compare(object x, object y)
        {
            GeneralRebar rebar1 = (GeneralRebar)x;
            GeneralRebar rebar2 = (GeneralRebar)y;

            if (rebar1.Diameter == rebar2.Diameter &&
                rebar1.Length > rebar2.Length)
            {
                return(1);
            }
            else if (rebar1.Diameter == rebar2.Diameter &&
                     rebar1.Length < rebar2.Length)
            {
                return(-1);
            }
            else if (rebar1.Diameter == rebar2.Diameter &&
                     rebar1.Length == rebar2.Length)
            {
                return(0);
            }
            else if (rebar1.Diameter > rebar2.Diameter)
            {
                return(1);
            }
            else
            {
                return(-1);
            }
        }
Exemple #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));
            }
        }
Exemple #3
0
 public void Add(GeneralRebar rebar)
 {
     m_rebars.Add(rebar);
 }