Files
2024-12-12 09:51:40 +01:00

44 lines
5.6 KiB
Plaintext

{\rtf1\fbidis\ansi\ansicpg1252\deff0\deflang1033\deflangfe2052{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}{\f1\froman\fprq2\fcharset0 Times New Roman;}}
\viewkind4\uc1\pard\ltrpar\b\f0\fs20 Application:\b0 \lang1036 AutoStamp\lang1033\line\b Revit Platform:\b0 All\line\b Revit Version:\b0 2010.0\line\b First Released For:\b0 2010.0\line\b Last Modified:\b0 04/12/2008\line\b Modified By:\b0 JJ Autodesk\line\b Programming Language:\b0 C#\line\b Skill Level:\b0 Medium\line\b Category:\b0 Basics\line\b Type:\b0 ExternalApplication\line\line\b Subject:\b0 Auto stamp when print view.\line\b Summary:\b0 \line This sample demonstrates how to subscribe ViewPrint events, create and delete TextNote element in event handler and cancel events when creation failure occurred\f1 .\par
\f0\par
\b Classes\b0 : \par
\pard\ltrpar\fi180\li180\lang1036 Autodesk.Revit.IExternalApplication \f1\par
\f0 Autodesk.Revit.Elements\par
Autodesk.Revit.Elements.TextNote\par
Autodesk.Revit.Geometry.XYZ\f1\par
\f0 Autodesk.Revit.Events.ViewPrintingEventArgs\par
Autodesk.Revit.Events.ViewPrintedEventArgs\par
\f1\par
\pard\ltrpar\lang1033\f0\par
\b Project Files\b0 : \par
Application.cs\par
\pard\ltrpar\li360\tx720 This file contains a class Application which implements IExternalApplcation interface. The OnStartUp method will register ViewPrinting, ViewPrinted events when Revit starts.\f1\par
\par
\pard\ltrpar\f0 EventsReactor.cs\par
\pard\ltrpar\li360\tx720 This file contains a class EventsReactor\f1 ,\f0 it consists of two handler methods which will be subscribed to ViewPrinting and ViewPrinted events separately; it also contains other methods which are used to dump related information to log files. The pre-event handler will create TextNote element before print start and implement the auto stamp function; the post-event handler will delete the element created in pre-event handler after view print has finished\f1 .\par
\par
\pard\ltrpar\f0\par
\b Description\b0 : \par
The sample implements IExternalApplication interface and subscribes ViewPrinting, ViewPrinted, events in OnStartUp method; the registered event handlers will create and delete TextNote element and dump print related information to log files when events are raised\f1 .\par
\pard\ltrpar\fi-360\li360\tx360\f0 -\tab Event delegates for ViewPrinting and ViewPrinted events of ControlledApplication level will be subscribed to react to the print actions\f1 .\par
\pard\ltrpar\f0 -\tab When ViewPrinting is raised, EventAgrs property View will be used as view method parameter for NewTextNote(View <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://RevitAPI:2010.0.0.0/Autodesk.Revit.Elements.View> pView, \'85) method; the handler will also reserve the Id value of newly-created TextNote for deleting it later.\f1\par
\f0 -\tab If the TextNote creation failed for some reason, this sample will cancel the print process for this view by setting the Cancel property of ViewPrinting EventAgrs to true.\f1\par
\pard\ltrpar\fi-360\li360\tx360\f0 -\tab When ViewPrinted is raised, EventArgs property Document can be used to delete element via method Document.Delete(ElementId).\f1\par
\pard\ltrpar\f0 -\tab Method Autodesk.Revit.Creation.ItemFactoryBase.NewTextNote <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://RevitAPI:2010.0.0.0/Autodesk.Revit.Creation.ItemFactoryBase/NewTextNote(Autodesk.Revit.Elements.View,Autodesk.Revit.Geometry.XYZ,Autodesk.Revit.Geometry.XYZ,Autodesk.Revit.Geometry.XYZ,Double,Autodesk.Revit.Enums.TextAlignFlags,String):Autodesk.Revit.Elements.TextNote>(View <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://RevitAPI:2010.0.0.0/Autodesk.Revit.Elements.View> pView, XYZ <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://RevitAPI:2010.0.0.0/Autodesk.Revit.Geometry.XYZ> origin, XYZ <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://RevitAPI:2010.0.0.0/Autodesk.Revit.Geometry.XYZ> baseVec, XYZ <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://RevitAPI:2010.0.0.0/Autodesk.Revit.Geometry.XYZ> upVec, double <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:2.0.0.0:b77a5c561934e089/System.Double> lineWidth, TextAlignFlags <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://RevitAPI:2010.0.0.0/Autodesk.Revit.Enums.TextAlignFlags> textAlign, string <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:2.0.0.0:b77a5c561934e089/System.String> strText) will be used to create TextNote element.\f1\par
\pard\ltrpar\fi-360\li360\tx360\f0 -\tab Printer name can be retrieved from EventAgrs property Setting by method PrintSetting.PrinterName; User name can be retrieved via System.Environment.UserName.\par
\pard\ltrpar\par
\b Instructions\b0 : \par
\pard\ltrpar\fi-360\li360\tx360 1.\tab Update your Revit.ini by following lines: \f1\par
\pard\ltrpar\li360\f0 [ExternalApplications] \par
EACount = 1 \par
EAClassName1 = Revit.SDK.Samples.AutoStamp.CS.Application\par
EAAssembly1 = \i <your path>\i0\f1\\\f0 AutoStamp.dll \par
\pard\ltrpar\fi-360\li360\tx360 2.\tab Start Revit, notice ViewPrinting and ViewPrinted events will be registered automatically\f1 .\par
\f0 3.\tab Raise print events via UI: Run print command File\\Print to print views; each printed view will be auto stamped with printer name and user name at origin position of view.\f1\par
\pard\ltrpar\par
\b\f0 Note\b0 : \par
The sample was designed to work when printing is invoked via Revit's UI. It may not work as expected if printing is invoked from inside an API call, since API commands may impose editing limitations on the current document.\f1\par
\par
\par
}