.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Load Form when publishing from Sheet Set Manager

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
695 Views, 3 Replies

Load Form when publishing from Sheet Set Manager

I'm new to VB.net 2005 so I was wondering if someone could post a simple
example of how to display a simple form when ever the publish command is
issued from the sheet set manager?

I've gone into the acmgd.dll file and found something called
Autodesk.AutoCAD.Publishing BeginPublishingSheetEventArgs &
BeginPublishingSheetEventHandler. So I think these files are what I need to
use. But am lost as to what to do with them and where to place them in my
form? Or how to reference them I guess? If anyone has some sample code on
how this works would be great!! I'm trying to learn this stuff but getting
pretty confused.

Thanks for any help!!

Mark
3 REPLIES 3
Message 2 of 4
mark
in reply to: Anonymous

Ok I found some code that can do this, but its in C#?

If anyone can help me convert it from C# to VB.net I would be much appreciated!!

C# code:

using System;
using System.Diagnostics;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Publishing;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.PlottingServices;

[assembly: ExtensionApplication(typeof(NET.MyApp))]
namespace NET
{
public class MyApp : IExtensionApplication
{
public static PublishEvents m_PublishEvents = null;
public void Terminate()
{
if (m_PublishEvents != null)
{
//m_PublishEvents.Undo();
m_PublishEvents = null;
}
}
public void Initialize()
{
m_PublishEvents = new PublishEvents();
}
}

public class PublishEvents
{
static private Publisher m_pb = null;
private bool m_bDone;
public PublishEvents()
{
m_bDone = false;
m_pb = Autodesk.AutoCAD.ApplicationServices.Application.Publisher;
Do();
}
public void Do()
{
// Only plant it once.
if(m_bDone == false)
{
m_bDone = true;
}
else
{
return;
}

try
{
m_pb = Autodesk.AutoCAD.ApplicationServices.Application.Publisher;
m_pb.AboutToBeginBackgroundPublishing += new AboutToBeginBackgroundPublishingEventHandler (callback_AboutToBeginBackgroundPublishingEventHandler);

m_pb.AboutToBeginPublishing += new AboutToBeginPublishingEventHandler (callback_AboutToBeginPublishingEventHandler);
m_pb.AboutToEndPublishing += new AboutToEndPublishingEventHandler (callback_AboutToEndPublishingEventHandler);
m_pb.AboutToMoveFile += new AboutToMoveFileEventHandler (callback_AboutToMoveFileHandler);
m_pb.BeginAggregation += new BeginAggregationEventHandler (callback_BeginAggregationEventHandler);
m_pb.BeginEntity += new BeginEntityEventHandler(callback_BeginEntityEventHandler);
m_pb.BeginPublishingSheet += new BeginPublishingSheetEventHandler (callback_BeginPublishingSheetEventHandler);
m_pb.BeginSheet += new BeginSheetEventHandler (callback_BeginSheetEventHandler);
m_pb.CancelledOrFailedPublishing += new CancelledOrFailedPublishingEventHandler(callback_CancelledOrFailedPublishingEventHandler);

m_pb.EndEntity += new EndEntityEventHandler (callback_EndEntityEventHandler);
m_pb.EndPublish +=new EndPublishEventHandler (callback_EndPublishEventHandler);
m_pb.EndSheet +=new EndSheetEventHandler (callback_EndSheetEventHandler);
//m_pb.InitPublishOptionsDialog += new InitPublishOptionsDialogEventHandler (callback_InitPublishOptionsDialogEventHandler);
}
catch (System.Exception ex)
{
MyPrint (string.Format("\terror = {0}",ex.Message));
}
}
public void Undo()
{
if( m_pb == null || m_bDone == false)
return;

try
{
m_pb.AboutToBeginBackgroundPublishing -= new AboutToBeginBackgroundPublishingEventHandler (callback_AboutToBeginBackgroundPublishingEventHandler);

m_pb.AboutToBeginPublishing -= new AboutToBeginPublishingEventHandler (callback_AboutToBeginPublishingEventHandler);
m_pb.AboutToEndPublishing -= new AboutToEndPublishingEventHandler (callback_AboutToEndPublishingEventHandler);
m_pb.AboutToMoveFile -= new AboutToMoveFileEventHandler (callback_AboutToMoveFileHandler);
m_pb.BeginAggregation -= new BeginAggregationEventHandler (callback_BeginAggregationEventHandler);
m_pb.BeginEntity -= new BeginEntityEventHandler(callback_BeginEntityEventHandler);
m_pb.BeginPublishingSheet -= new BeginPublishingSheetEventHandler (callback_BeginPublishingSheetEventHandler);
m_pb.BeginSheet -= new BeginSheetEventHandler (callback_BeginSheetEventHandler);
m_pb.CancelledOrFailedPublishing -= new CancelledOrFailedPublishingEventHandler(callback_CancelledOrFailedPublishingEventHandler);

m_pb.EndEntity -= new EndEntityEventHandler (callback_EndEntityEventHandler);
m_pb.EndPublish -=new EndPublishEventHandler (callback_EndPublishEventHandler);
m_pb.EndSheet -=new EndSheetEventHandler (callback_EndSheetEventHandler);
//m_pb.InitPublishOptionsDialog -+ new InitPublishOptionsDialogEventHandler (callback_InitPublishOptionsDialogEventHandler);

m_pb = null;
}
catch (System.Exception ex)
{
MyPrint (string.Format("\terror = {0}",ex.Message));
}

m_bDone = false;
}
private void callback_AboutToBeginBackgroundPublishingEventHandler(object sender, AboutToBeginBackgroundPublishingEventArgs e)
{
MyPrint("AboutToBeginBackgroundPublishingEventHandler");
Autodesk.AutoCAD.PlottingServices.DsdData dsdData = e.DsdData;
MyPrint(string.Format("\tPlotStampOn = {0}", dsdData.PlotStampOn));
}

private void callback_AboutToBeginPublishingEventHandler (object sender, AboutToBeginPublishingEventArgs e)
{
MyPrint("AboutToBeginPublishingEventHandler");
MyPrint (string.Format("\tget_JobWillPublishInBackground = {0}",e.JobWillPublishInBackground));
Autodesk.AutoCAD.PlottingServices.DsdData dsdData = e.DsdData;
MyPrint (string.Format("\tPlotStampOn = {0}",dsdData.PlotStampOn));
}
private void callback_AboutToEndPublishingEventHandler(object sender, PublishEventArgs e)
{
MyPrint("AboutToEndPublishingEventHandler");
MyPrint(string.Format("\tget_DwfFileName = {0}", e.DwfFileName));
MyPrint(string.Format("\tget_IsMultiSheetDwf = {0}", e.IsMultiSheetDwf));
MyPrint(string.Format("\tget_TemporaryDwfFileName = {0}", e.TemporaryDwfFileName));
}

private void callback_AboutToMoveFileHandler(object sender, PublishEventArgs e)
{
MyPrint("AboutToMoveFileHandler");
MyPrint (string.Format("\tget_DwfFileName = {0}",e.DwfFileName));
MyPrint (string.Format("\tget_IsMultiSheetDwf = {0}",e.IsMultiSheetDwf));
MyPrint (string.Format("\tget_TemporaryDwfFileName = {0}",e.TemporaryDwfFileName));
}

private void callback_BeginAggregationEventHandler(object sender, BeginAggregationEventArgs e)
{
MyPrint("BeginAggregationEventHandler");
e.PlotLogger.LogMessage ("From my BeginAggregationEventHandler EVENT!!");
}
private void callback_BeginEntityEventHandler (object sender, PublishEntityEventArgs e)
{
MyPrint("BeginEntityEventHandler");
MyPrint (string.Format("\tget_UniqueEntityId() = {0}",e.UniqueEntityId));
}

private void callback_BeginPublishingSheetEventHandler(object sender, BeginPublishingSheetEventArgs e)
{
MyPrint("BeginPublishingSheetEventHandler");
MyPrint (string.Format("\tDwgName = {0}",e.DsdEntry.DwgName));
e.PlotLogger.LogMessage ("From my BeginPublishingSheetEventHandler EVENT!!");
}

private void callback_BeginSheetEventHandler(object sender, PublishSheetEventArgs e)
{
MyPrint("BeginSheetEventHandler");
MyPrint (string.Format("\tget_CanonicalMediaName = {0}",e.CanonicalMediaName));
MyPrint (string.Format("\tget_Configuration = {0}",e.Configuration));
MyPrint (string.Format("\tget_DrawingScale = {0}",e.DrawingScale.ToString()));
MyPrint (string.Format("\tget_PlotLayoutId = {0}",e.PlotLayoutId.ToString()));
e.PlotLogger.LogMessage ("From my BeginSheetEventHandler EVENT!!");
}
private void callback_CancelledOrFailedPublishingEventHandler(object sender, PublishEventArgs e)
{
MyPrint("CancelledOrFailedPublishingEventHandler");
MyPrint (string.Format("\tget_DwfFileName = {0}",e.DwfFileName));
MyPrint (string.Format("\tget_IsMultiSheetDwf = {0}",e.IsMultiSheetDwf));
MyPrint (string.Format("\tget_TemporaryDwfFileName = {0}",e.TemporaryDwfFileName));
}

private void callback_EndEntityEventHandler (object sender, PublishEntityEventArgs e)
{
MyPrint("EndEntityEventHandler");
MyPrint (string.Format("\tget_UniqueEntityId() = {0}",e.UniqueEntityId));
}

private void callback_EndPublishEventHandler(object sender, PublishEventArgs e)
{
MyPrint("EndPublishEventHandler");
MyPrint (string.Format("\tget_DwfFileName = {0}",e.DwfFileName));
MyPrint (string.Format("\tget_IsMultiSheetDwf = {0}",e.IsMultiSheetDwf));
MyPrint (string.Format("\tget_TemporaryDwfFileName = {0}",e.TemporaryDwfFileName));
}

private void callback_EndSheetEventHandler(object sender, PublishSheetEventArgs e)
{
MyPrint("EndSheetEventHandler");
}

private void MyPrint(String s)
{
String strLogFileName = "c:\\test.log";
System.IO.TextWriter tw= System.IO.File.AppendText(strLogFileName);
tw.WriteLine(s);
tw.Close();
}
}
}
Message 3 of 4
mark
in reply to: Anonymous

Here is the VB.code I tried converting on the Internet. But getting errors.

VB.net conversion.


Imports System
Imports System.Diagnostics
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Publishing
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.PlottingServices

< extensionapplication="">

Namespace NET
Public Class CLASS3
Implements IExtensionApplication
Public Shared m_PublishEvents As PublishEvents = Nothing
Public Sub Terminate()
If Not m_PublishEvents Is Nothing Then
'm_PublishEvents.Undo();
m_PublishEvents = Nothing
End If
End Sub
Public Sub Initialize()
m_PublishEvents = New PublishEvents()
End Sub
End Class

Public Class PublishEvents
Private Shared m_pb As Publisher = Nothing
Private m_bDone As Boolean
Public Sub New()
m_bDone = False
m_pb = Autodesk.AutoCAD.ApplicationServices.Application.Publisher
Do()
End Sub
Public Sub Do()
' Only plant it once.
If m_bDone = False Then
m_bDone = True
Else
Return
End If

Try
m_pb = Autodesk.AutoCAD.ApplicationServices.Application.Publisher
m_pb.AboutToBeginBackgroundPublishing += New AboutToBeginBackgroundPublishingEventHandler(callback_AboutToBeginBackgroundPublishingEventHandler)

m_pb.AboutToBeginPublishing += New AboutToBeginPublishingEventHandler(callback_AboutToBeginPublishingEventHandler)
m_pb.AboutToEndPublishing += New AboutToEndPublishingEventHandler(callback_AboutToEndPublishingEventHandler)
m_pb.AboutToMoveFile += New AboutToMoveFileEventHandler(callback_AboutToMoveFileHandler)
m_pb.BeginAggregation += New BeginAggregationEventHandler(callback_BeginAggregationEventHandler)
m_pb.BeginEntity += New BeginEntityEventHandler(callback_BeginEntityEventHandler)
m_pb.BeginPublishingSheet += New BeginPublishingSheetEventHandler(callback_BeginPublishingSheetEventHandler)
m_pb.BeginSheet += New BeginSheetEventHandler(callback_BeginSheetEventHandler)
m_pb.CancelledOrFailedPublishing += New CancelledOrFailedPublishingEventHandler(callback_CancelledOrFailedPublishingEventHandler)

m_pb.EndEntity += New EndEntityEventHandler(callback_EndEntityEventHandler)
m_pb.EndPublish += New EndPublishEventHandler(callback_EndPublishEventHandler)
m_pb.EndSheet += New EndSheetEventHandler(callback_EndSheetEventHandler)
'm_pb.InitPublishOptionsDialog += new InitPublishOptionsDialogEventHandler (callback_InitPublishOptionsDialogEventHandler);
Catch ex As System.Exception
MyPrint(String.Format("\terror = {0}", ex.Message))
End Try
End Sub
Public Sub Undo()
If m_pb = Nothing Or m_bDone = False Then
Return
End If

Try
Dim - As m_pb.AboutToBeginBackgroundPublishing = New AboutToBeginBackgroundPublishingEventHandler(callback_AboutToBeginBackgroundPublishingEventHandler)

Dim - As m_pb.AboutToBeginPublishing = New AboutToBeginPublishingEventHandler(callback_AboutToBeginPublishingEventHandler)
Dim - As m_pb.AboutToEndPublishing = New AboutToEndPublishingEventHandler(callback_AboutToEndPublishingEventHandler)
Dim - As m_pb.AboutToMoveFile = New AboutToMoveFileEventHandler(callback_AboutToMoveFileHandler)
Dim - As m_pb.BeginAggregation = New BeginAggregationEventHandler(callback_BeginAggregationEventHandler)
Dim - As m_pb.BeginEntity = New BeginEntityEventHandler(callback_BeginEntityEventHandler)
Dim - As m_pb.BeginPublishingSheet = New BeginPublishingSheetEventHandler(callback_BeginPublishingSheetEventHandler)
Dim - As m_pb.BeginSheet = New BeginSheetEventHandler(callback_BeginSheetEventHandler)
Dim - As m_pb.CancelledOrFailedPublishing = New CancelledOrFailedPublishingEventHandler(callback_CancelledOrFailedPublishingEventHandler)

Dim - As m_pb.EndEntity = New EndEntityEventHandler(callback_EndEntityEventHandler)
Dim - As m_pb.EndPublish = New EndPublishEventHandler(callback_EndPublishEventHandler)
Dim - As m_pb.EndSheet = New EndSheetEventHandler(callback_EndSheetEventHandler)
'm_pb.InitPublishOptionsDialog -+ new InitPublishOptionsDialogEventHandler (callback_InitPublishOptionsDialogEventHandler);

m_pb = Nothing
Catch ex As System.Exception
MyPrint(String.Format("\terror = {0}", ex.Message))
End Try

m_bDone = False
End Sub
Private Sub callback_AboutToBeginBackgroundPublishingEventHandler(ByVal sender As Object, ByVal e As AboutToBeginBackgroundPublishingEventArgs)
MyPrint("AboutToBeginBackgroundPublishingEventHandler")
Dim dsdData As Autodesk.AutoCAD.PlottingServices.DsdData = e.DsdData
MyPrint(String.Format("\tPlotStampOn = {0}", dsdData.PlotStampOn))
End Sub

Private Sub callback_AboutToBeginPublishingEventHandler(ByVal sender As Object, ByVal e As AboutToBeginPublishingEventArgs)
MyPrint("AboutToBeginPublishingEventHandler")
MyPrint(String.Format("\tget_JobWillPublishInBackground = {0}", e.JobWillPublishInBackground))
Dim dsdData As Autodesk.AutoCAD.PlottingServices.DsdData = e.DsdData
MyPrint(String.Format("\tPlotStampOn = {0}", dsdData.PlotStampOn))
End Sub
Private Sub callback_AboutToEndPublishingEventHandler(ByVal sender As Object, ByVal e As PublishEventArgs)
MyPrint("AboutToEndPublishingEventHandler")
MyPrint(String.Format("\tget_DwfFileName = {0}", e.DwfFileName))
MyPrint(String.Format("\tget_IsMultiSheetDwf = {0}", e.IsMultiSheetDwf))
MyPrint(String.Format("\tget_TemporaryDwfFileName = {0}", e.TemporaryDwfFileName))
End Sub

Private Sub callback_AboutToMoveFileHandler(ByVal sender As Object, ByVal e As PublishEventArgs)
MyPrint("AboutToMoveFileHandler")
MyPrint(String.Format("\tget_DwfFileName = {0}", e.DwfFileName))
MyPrint(String.Format("\tget_IsMultiSheetDwf = {0}", e.IsMultiSheetDwf))
MyPrint(String.Format("\tget_TemporaryDwfFileName = {0}", e.TemporaryDwfFileName))
End Sub

Private Sub callback_BeginAggregationEventHandler(ByVal sender As Object, ByVal e As BeginAggregationEventArgs)
MyPrint("BeginAggregationEventHandler")
e.PlotLogger.LogMessage("From my BeginAggregationEventHandler EVENT!!")
End Sub
Private Sub callback_BeginEntityEventHandler(ByVal sender As Object, ByVal e As PublishEntityEventArgs)
MyPrint("BeginEntityEventHandler")
MyPrint(String.Format("\tget_UniqueEntityId() = {0}", e.UniqueEntityId))
End Sub

Private Sub callback_BeginPublishingSheetEventHandler(ByVal sender As Object, ByVal e As BeginPublishingSheetEventArgs)
MyPrint("BeginPublishingSheetEventHandler")
MyPrint(String.Format("\tDwgName = {0}", e.DsdEntry.DwgName))
e.PlotLogger.LogMessage("From my BeginPublishingSheetEventHandler EVENT!!")
End Sub

Private Sub callback_BeginSheetEventHandler(ByVal sender As Object, ByVal e As PublishSheetEventArgs)
MyPrint("BeginSheetEventHandler")
MyPrint(String.Format("\tget_CanonicalMediaName = {0}", e.CanonicalMediaName))
MyPrint(String.Format("\tget_Configuration = {0}", e.Configuration))
MyPrint(String.Format("\tget_DrawingScale = {0}", e.DrawingScale.ToString()))
MyPrint(String.Format("\tget_PlotLayoutId = {0}", e.PlotLayoutId.ToString()))
e.PlotLogger.LogMessage("From my BeginSheetEventHandler EVENT!!")
End Sub
Private Sub callback_CancelledOrFailedPublishingEventHandler(ByVal sender As Object, ByVal e As PublishEventArgs)
MyPrint("CancelledOrFailedPublishingEventHandler")
MyPrint(String.Format("\tget_DwfFileName = {0}", e.DwfFileName))
MyPrint(String.Format("\tget_IsMultiSheetDwf = {0}", e.IsMultiSheetDwf))
MyPrint(String.Format("\tget_TemporaryDwfFileName = {0}", e.TemporaryDwfFileName))
End Sub

Private Sub callback_EndEntityEventHandler(ByVal sender As Object, ByVal e As PublishEntityEventArgs)
MyPrint("EndEntityEventHandler")
MyPrint(String.Format("\tget_UniqueEntityId() = {0}", e.UniqueEntityId))
End Sub

Private Sub callback_EndPublishEventHandler(ByVal sender As Object, ByVal e As PublishEventArgs)
MyPrint("EndPublishEventHandler")
MyPrint(String.Format("\tget_DwfFileName = {0}", e.DwfFileName))
MyPrint(String.Format("\tget_IsMultiSheetDwf = {0}", e.IsMultiSheetDwf))
MyPrint(String.Format("\tget_TemporaryDwfFileName = {0}", e.TemporaryDwfFileName))
End Sub

Private Sub callback_EndSheetEventHandler(ByVal sender As Object, ByVal e As PublishSheetEventArgs)
MyPrint("EndSheetEventHandler")
End Sub

Private Sub MyPrint(ByVal s As String)
Dim strLogFileName As String = "c:\\test.log"
Dim tw As System.IO.TextWriter = System.IO.File.AppendText(strLogFileName)
tw.WriteLine(s)
tw.Close()
End Sub
End Class
End Namespace
Message 4 of 4
NathTay
in reply to: Anonymous

See posting in The Swamp.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost