コード例 #1
0
ファイル: MassFactory.cs プロジェクト: dangwalsh/ExcelProgram
        public void Make()
        {
            try
            {
                Document familyDoc = _ProjectDoc.Application.NewFamilyDocument(_TemplateFileName);
                if (null == familyDoc)
                {
                    throw new Exception("Failed to open the family document");
                }
                CreateFamily(familyDoc);

                if (!familyDoc.SaveAs(_TempLocation + @"\" + _Name + @".rfa"))
                {
                    throw new Exception("Failed to save family document!");
                }

                FamilySymbolSetIterator symbolItor = null;
                Transaction             transLoad  = new Transaction(familyDoc, "Load Family");
                if (transLoad.Start() == TransactionStatus.Started)
                {
                    FamilyLoadOpt flo    = new FamilyLoadOpt();
                    Family        family = familyDoc.LoadFamily(_ProjectDoc, flo);
                    symbolItor = family.Symbols.ForwardIterator();
                    transLoad.Commit();
                }

                Transaction transPlace = new Transaction(_ProjectDoc, "PlaceFamily");
                if (transPlace.Start() == TransactionStatus.Started)
                {
                    double y = 0.0;

                    symbolItor.MoveNext();
                    while (_Count > 0)
                    {
                        FamilySymbol   symbol   = symbolItor.Current as FamilySymbol;
                        XYZ            location = new XYZ(_X, y, 0.0);
                        FamilyInstance instance = _ProjectDoc.Create.NewFamilyInstance(location, symbol, StructuralType.NonStructural);
                        y += _Y;
                        --_Count;
                    }
                    transPlace.Commit();
                }
                familyDoc.Close(false);

                //File.Delete(_TempLocation + @"\" + _Name + @".rfa");

                _X += _Side + FormFile.xPad;
            }

            catch (Exception ex)
            {
                TaskDialog.Show("Load Error", ex.Message);
            }
        }
コード例 #2
0
ファイル: MassFactory.cs プロジェクト: dangwalsh/ExcelProgram
        public void Make()
        {
            try
            {
                Document familyDoc = _ProjectDoc.Application.NewFamilyDocument(_TemplateFileName);
                if (null == familyDoc)
                {
                    throw new Exception("Failed to open the family document");
                }
                CreateFamily(familyDoc);

                if (!familyDoc.SaveAs(_TempLocation + @"\" + _Name + @".rfa"))
                {
                    throw new Exception("Failed to save family document!");
                }

                FamilySymbolSetIterator symbolItor = null;
                Transaction transLoad = new Transaction(familyDoc, "Load Family");
                if (transLoad.Start() == TransactionStatus.Started)
                {
                    FamilyLoadOpt flo = new FamilyLoadOpt();
                    Family family = familyDoc.LoadFamily(_ProjectDoc, flo);
                    symbolItor = family.Symbols.ForwardIterator();
                    transLoad.Commit();
                }

                Transaction transPlace = new Transaction(_ProjectDoc, "PlaceFamily");
                if (transPlace.Start() == TransactionStatus.Started)
                {
                    double y = 0.0;

                    symbolItor.MoveNext();
                    while (_Count > 0)
                    {
                        FamilySymbol symbol = symbolItor.Current as FamilySymbol;
                        XYZ location = new XYZ(_X, y, 0.0);
                        FamilyInstance instance = _ProjectDoc.Create.NewFamilyInstance(location, symbol, StructuralType.NonStructural);
                        y += _Y;
                        --_Count;
                    }
                    transPlace.Commit();
                }
                familyDoc.Close(false);

                //File.Delete(_TempLocation + @"\" + _Name + @".rfa");

                _X += _Side + FormFile.xPad;
            }

            catch (Exception ex)
            {
                TaskDialog.Show("Load Error", ex.Message);
            }
        }