Esempio di disegno esecutivo dell'API di Prefabbricati

Visualizzare una semplice implementazione dell'API del comando Disegno esecutivo.

Creazione di ShopDrawing

IShopDrawingOptions options = new ShopDrawingSampleOptions();
IShopDrawingCreator creator = ShopDrawingCreatorFactory.Get(assemblyInstance);

// use the creator to create a shop drawing.
// the creator is bound to the assembly used to get it.
ElementId createdSheetId;
creator.Create(options, out createdSheetId);

Implementazione di IShopDrawingOptions da parte dell'utente dell'API

class ShopDrawingSampleOptions : ShopDrawingDefaultOptions
   {
      public override bool GetOutlineName(out string outlineName)
      {
         outlineName = "Sample Outline";
         return true;
      }

      public override bool GetExtentsName(out string extentsName)
      {
         extentsName = "Sample Extents";
         return true;
      }
   }

Registrazione di eventi per la creazione di ShopDrawing

ShopDrawingEvents.TaggingView += OnTaggingView; // called before a view is tagged
ShopDrawingEvents.DetailedViews += OnDetailedViews; // called when the detailing for all views is finished

void OnTaggingView(object sender, ITaggingViewEventArgs eventArgs)
{
   // As an example, prevent all Precast tagging from happening
   eventArgs.Cancel = true;
}

void OnDetailedViews(object sender, IDetailedViewsEventArgs eventArgs)
{
   // After the detailing is done, create sample tagging,
   // by adding a tag to the AssemblyInstance, but only in some views
   IEnumerable<IViewportData> viewPorts = eventArgs.Viewports.Where(IsFrontOrBackView);
   foreach (IViewportData viewport in viewPorts)
   {
      // when this event handler is called, a transaction is already opened,
      // so no need to start one
      CreateExampleTagInView(eventArgs.Document, viewport);
   }
}