public static Sheet AddToSheetSet(SheetSet sheetSet, string filename, string desc = "") { Sheet retSheet = null; if (sheetSet != null) { Database database = sheetSet.Database; try { if (Database.LockDatabase(database, true)) { // create the sheet AcSmSheet sheet = database.BaseObject.GetSheetSet().AddNewSheet(filename, desc); // add the sheet to the sheet set database.BaseObject.GetSheetSet().InsertComponent(sheet, null); retSheet = new Sheet(sheet); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } finally { Database.LockDatabase(database, false); } } return(retSheet); }
// Set/create a custom sheet or sheet set property private void SetCustomProperty(IAcSmPersist owner, string propertyName, object propertyValue, PropertyFlags sheetSetFlag) { // Create a reference to the Custom Property Bag AcSmCustomPropertyBag customPropertyBag = default(AcSmCustomPropertyBag); if (owner.GetTypeName() == "AcSmSheet") { AcSmSheet sheet = (AcSmSheet)owner; customPropertyBag = sheet.GetCustomPropertyBag(); } else { AcSmSheetSet sheetSet = (AcSmSheetSet)owner; customPropertyBag = sheetSet.GetCustomPropertyBag(); } // Create a reference to a Custom Property Value AcSmCustomPropertyValue customPropertyValue = new AcSmCustomPropertyValue(); customPropertyValue.InitNew(owner); // Set the flag for the property customPropertyValue.SetFlags(sheetSetFlag); // Set the value for the property customPropertyValue.SetValue(propertyValue); // Create the property customPropertyBag.SetProperty(propertyName, customPropertyValue); }
/// <summary> /// Import an existing sheet file to a subset before a sheet. /// </summary> /// <param name="subset">The subset to receive the new sheet.</param> /// <param name="filename">The file and path of the existing sheet.</param> /// <param name="layoutName">The paperspace layout name.</param> /// <param name="indexSheet">The sheet to insert before.</param> /// <returns></returns> /// [IsVisibleInDynamoLibrary(true)] public static Sheet ImportLayoutToSubSetBefore(SubSet subset, string filename, string layoutName, Sheet indexSheet) { Sheet retSheet = null; if (subset != null) { try { if (Database.LockDatabase(subset.Database, true)) { // create a layout reference object AcSmAcDbLayoutReference layoutReference = new AcSmAcDbLayoutReference(); // initialize the reference to the sheet set layoutReference.InitNew(subset.BaseObject); // set the layout and drawing file to the inputs layoutReference.SetFileName(filename); layoutReference.SetName(layoutName); // import the sheet into the sheet set AcSmSheet newSheet; newSheet = subset.BaseObject.ImportSheet(layoutReference); // get the base object of the index sheet AcSmSheet exSheet = indexSheet.BaseObject; subset.BaseObject.InsertComponent(newSheet, exSheet); retSheet = new Sheet(newSheet); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } finally { Database.LockDatabase(subset.Database, false); } } return(retSheet); }
public static Sheet AddToSubSetBefore(SubSet subset, string filename, Sheet indexSheet, string desc = "") { Sheet retSheet = null; if (subset != null) { Database database = subset.Database; try { if (Database.LockDatabase(database, true)) { // get the base object of the index sheet AcSmSheet exSheet = indexSheet.BaseObject; // add the new sheet to the subset AcSmSheet sheet = subset.BaseObject.AddNewSheet(filename, desc); // add the sheet to the subset subset.BaseObject.InsertComponent(sheet, exSheet); retSheet = new Sheet(sheet); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } finally { Database.LockDatabase(database, false); } } return(retSheet); }
private void IAcSmEvents_OnChanged(AcSmEvent ev, IAcSmPersist comp) { Autodesk.AutoCAD.ApplicationServices.Document activeDocument = default(Autodesk.AutoCAD.ApplicationServices.Document); activeDocument = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; AcSmSheet oSheet = default(AcSmSheet); AcSmSubset oSubset = default(AcSmSubset); if (ev == AcSmEvent.ACSM_DATABASE_OPENED) { activeDocument.Editor.WriteMessage("\n" + comp.GetDatabase().GetFileName() + " was opened."); } if (ev == AcSmEvent.ACSM_DATABASE_CHANGED) { activeDocument.Editor.WriteMessage("\n" + comp.GetDatabase().GetFileName() + " database changed."); } if (ev == AcSmEvent.SHEET_DELETED) { oSheet = (AcSmSheet)comp; activeDocument.Editor.WriteMessage("\n" + oSheet.GetName() + " was deleted."); } if (ev == AcSmEvent.SHEET_SUBSET_CREATED) { oSubset = (AcSmSubset)comp; activeDocument.Editor.WriteMessage("\n" + oSubset.GetName() + " was created."); } if (ev == AcSmEvent.SHEET_SUBSET_DELETED) { oSubset = (AcSmSubset)comp; activeDocument.Editor.WriteMessage("\n" + oSubset.GetName() + " was deleted."); } }
public SheetNode(AcSmSheet sheet, SheetSet ss) : base(ss) { this.sheet = sheet; Name = sheet.GetTitle(); Number = sheet.GetNumber(); CrossNumber = sheet.GetCustomPropertyValue(ss.options.PropCrossNumberName)?.ToString(); dynamic layout = sheet.GetLayout(); Layout = layout.GetName(); File = layout.GetFileName(); }
public IList <AMRSheet> GetSheets() { IAcSmEnumComponent sheetEnumerator = _currentSheetSet.GetSheetEnumerator(); sheetEnumerator.Reset(); IList <AMRSheet> sheets = new List <AMRSheet>(); IAcSmPersist curItem = sheetEnumerator.Next(); while (curItem != null) { if (curItem is AcSmSheet) { AcSmSheet comp = (AcSmSheet)curItem; sheets.Add(new AMRSheet(comp)); } curItem = sheetEnumerator.Next(); } curItem = null; sheetEnumerator = null; return(sheets); }
// constuctors need to be static methods in order to show up in the Create category internal Sheet(AcSmSheet rootSheetObject) { _curSheet = rootSheetObject; _curSheet2 = (IAcSmSheet2)rootSheetObject; }
public static void RemoveSheet(AcSmSheet sheet) { throw new NotImplementedException(); }
public AMRSheet(AcSmSheet sheet) { _currentSheet = sheet; }