Esempio n. 1
0
        public FamilySymbol GetSymbol(Document doc, SettingCreateGrid3d Setting)
        {
            FamilySymbol symbol = null;

            if (Setting.Projectname == doc.Title)
            {
                Element elem = doc.GetElement(Setting.Idsymbol);
                symbol = elem as FamilySymbol;
                if (symbol == null)
                {
                    Setting.Projectname = doc.Title;
                    var col = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_GenericAnnotation).OfClass(typeof(FamilySymbol)).Cast <FamilySymbol>().ToList();
                    foreach (var item in col)
                    {
                        if (item.FamilyName == "3D Grid")
                        {
                            symbol = item;
                        }
                    }
                    if (symbol != null)
                    {
                        Setting.Idsymbol = symbol.UniqueId;
                        Setting.SaveSetting();
                    }
                    else
                    {
                        Transaction tran = new Transaction(doc, "Load Family");
                        tran.Start();
                        string Path = @"C:\ProgramData\Autodesk\ApplicationPlugins\TVD\Family\3DGrid.rfa";
                        doc.LoadFamilySymbol(Path, "650mm Bubble - Single", out symbol);
                        if ((!symbol.IsActive) && (symbol != null))
                        {
                            symbol.Activate(); doc.Regenerate();
                        }
                        Setting.Idsymbol = symbol.UniqueId;
                        Setting.SaveSetting();
                        tran.Commit();
                    }
                }
            }
            else
            {
                Transaction tran = new Transaction(doc, "Load Family");
                tran.Start();
                string Path = @"C:\ProgramData\Autodesk\ApplicationPlugins\TVD\Family\3DGrid.rfa";
                doc.LoadFamilySymbol(Path, "650mm Bubble - Single", out symbol);
                // check symbol da active chua, moi lan load family moi phai regenerate lai project
                if ((!symbol.IsActive) && (symbol != null))
                {
                    symbol.Activate(); doc.Regenerate();
                }
                Setting.Idsymbol    = symbol.UniqueId;
                Setting.Projectname = doc.Title;
                Setting.SaveSetting();
                tran.Commit();
            }
            return(symbol);
        }
Esempio n. 2
0
        public SettingCreateGrid3d GetSetting()
        {
            SettingCreateGrid3d setting = SettingExtension.GetSetting <SettingCreateGrid3d>(GetFullFileName());

            if (setting == null)
            {
                setting = new SettingCreateGrid3d();
            }
            return(setting);
        }
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication application      = commandData.Application;
            UIDocument    activeUIDocument = application.ActiveUIDocument;
            Application   application2     = application.Application;
            Document      doc = activeUIDocument.Document;
            Selection     sel = activeUIDocument.Selection;

            Setting = SettingCreateGrid3d.Instance.GetSetting();
            FamilySymbol symbol = CreateGrid3dview.Instance.GetSymbol(doc, Setting);

            CreateGrid3dview.Instance.Deleteolddata(doc);
            using (Transaction tran = new Transaction(doc, "Create grid"))
            {
                tran.Start();
                CreateGrid3dview.Instance.Create3dGrid(doc, symbol);
                tran.Commit();
            }
            return(Result.Succeeded);
        }