Beispiel #1
0
 GetRebarsNotInAssemblyByPartitionHostMark(
     Document doc, string partition, string hostMark)
 {
     return(RebarsUtils.GetAllRebarsInDoc(doc)
            .Where(fi => (
                       (fi.LookupParameter(RebarsUtils.PARTITION).AsString() == partition) &&
                       (fi.LookupParameter(RebarsUtils.HOST_MARK).AsString() == hostMark) &&
                       (fi.LookupParameter(RebarsUtils.IS_IN_ASSEMBLY).AsInteger() == 0)))
            .ToList());
 }
Beispiel #2
0
 GetRebarsByPartitionHostMarkAssembly(
     Document doc, string partition, string hostMark, string assembly)
 {
     return(RebarsUtils.GetAllRebarsInDoc(doc)
            .Where(fi => (
                       (fi.LookupParameter(RebarsUtils.PARTITION).AsString() == partition) &&
                       (fi.LookupParameter(RebarsUtils.HOST_MARK).AsString() == hostMark) &&
                       (fi.LookupParameter(RebarsUtils.ASSEMBLY_MARK).AsString() == assembly)))
            .ToList());
 }
Beispiel #3
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));
            }
        }