public static void LoadEvent(object sender, FamilyLoadedIntoDocumentEventArgs args)
        {
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            string subdir = dir + "\\" + args.Document.Application.VersionNumber.ToString();

            if (!Directory.Exists(subdir))
            {
                Directory.CreateDirectory(subdir);
            }
            string fam     = args.FamilyPath;
            string famfile = fam + args.FamilyName + ".rfa";

            if (!string.IsNullOrEmpty(args.FamilyName))
            {
                string fn = subdir + "\\" + args.FamilyName + ".rfa";
                //int i = CheckUse(fn);
                //if (i == 1)
                //{
                if (fn != famfile)
                {
                    if (File.Exists(fn))
                    {
                        File.Delete(fn);
                    }
                    File.Copy(famfile, fn);
                }
                //}
                //if(i == 0)
                //{
                //    File.Copy(famfile, fn);
                //}
                if (!args.Document.IsFamilyDocument)
                {
                    string FilePath = ModelPathUtils.ConvertModelPathToUserVisiblePath(args.Document.GetWorksharingCentralModelPath());
                    string dirpath  = FilePath.TrimEnd(FilePath.Split('\\').LastOrDefault().ToCharArray());
                    string fullpath = dirpath + "\\ProjectFamilies";
                    if (!Directory.Exists(fullpath))
                    {
                        Directory.CreateDirectory(fullpath);
                    }
                    string fullfile = fullpath + "\\" + args.FamilyName + ".rfa";
                    if (File.Exists(fullfile) && famfile != fullfile)
                    {
                        File.Delete(fullfile);
                    }
                    File.Copy(famfile, fullfile);
                }
            }
        }
Exemple #2
0
 private void OnFamilyLoad(object sender, FamilyLoadedIntoDocumentEventArgs e)
 {
     CreateImages(e.Document);
     CollectFamilyData(e.Document);
 }