Beispiel #1
0
        copySectionStyle()
        {
            Document acDocTar = BaseObjs._acadDoc;                                                              // target - Active Document
            Database dbTar    = acDocTar.Database;                                                              // target database

            Document acDocSrc = BaseObjs.openDwg("R:\\TSet\\Template\\CIVIL3D2010\\EW.dwt");                    // source - Active Document

            Application.DocumentManager.MdiActiveDocument = acDocSrc;
            CivilDocument civDocSrc = BaseObjs._civDoc;

            SectionStyleCollection objSectionStyles = civDocSrc.Styles.SectionStyles;                           //source Section Styles

            using (Transaction tr = BaseObjs.startTransactionDb()) {
                foreach (ObjectId idStyle in objSectionStyles)
                {
                    SectionStyle style = (SectionStyle)tr.GetObject(idStyle, OpenMode.ForRead);
                    if (style.Name != "Standard")
                    {
                        style.ExportTo(dbTar, Autodesk.Civil.StyleConflictResolverType.Override);                                       //export from source to target db
                    }
                }
                tr.Commit();
            }

            Application.DocumentManager.MdiActiveDocument = acDocTar;
            acDocSrc.CloseAndDiscard();
        }