Ejemplo de dibujo de detalles de la API de prefabricado

Vea una implementación sencilla de la API del comando Dibujo de detalles.

Creación de un dibujo de detalles

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);

Implementación de IShopDrawingOptions por el usuario de la 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;
      }
   }

Registro de eventos para la creación del dibujo de detalles

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);
   }
}