Is it possible to capture the last succsessfull plot settings using objectdbx in vb dotnet?
You'd have to use com interop as dbx is not exposed in the managed api yet. -- Mike ___________________________ Mike Tuersley CADalyst's CAD Clinic Rand IMAGINiT Technologies ___________________________ the trick is to realize that there is no spoon...
Here's the framework. Add the connecting to AutoCAD somewhere: Imports System.Runtime.InteropServices Imports Autodesk.AutoCAD.Interop Imports System.Runtime.InteropServices.Marshal ' Private WithEvents m_AcadApp As AcadApplication ' 'connect to AutoCAD Try m_AcadApp = GetActiveObject("AutoCAD.Application.16.1") Catch m_AcadApp = New AcadApplicationClass Finally m_AcadApp.Visible = True End Try 'declare endplot handler Private Sub PlotTrace(ByVal cmdName As String) Handles m_AcadApp.EndPlot 'do whatever you want here End Sub -- Mike ___________________________ Mike Tuersley CADalyst's CAD Clinic Rand IMAGINiT Technologies ___________________________ the trick is to realize that there is no spoon...
Thanks a bunch. That does seem to work, but how does one get the canonicalmedia information and other plot information. I have added a reference to AutoCAD 2005 Type Library. Is this the wrong Library?
I'm not sure I follow??? The end plot event is not going to give you anything other than notification a plot has just ended. You'd have too write the code necessary to do that. And, yes, you have attached the proper library. Look in the help file and follow the vba example code. All you'll need to do is tweak the vba to .net. -- Mike ___________________________ Mike Tuersley CADalyst's CAD Clinic Rand IMAGINiT Technologies ___________________________ the trick is to realize that there is no spoon...
I am trying to write a plot tracking routine in dotnet because I have found vba less than reliable from version to version. Using the info you gave, the event fired, but not able to get the properties of the previous plot. Any help is GREATLY appreciated.
VBA not reliable ? Why are you saying that ? I have happy customers running some quite complex DVB for years, with R14, 2000 and 2004. As you probably know, plot configurations are objects you have access to in VBA. You can access the saved page setup. The last settings are saved under the name <Previous Plot>. Have you tried to access this configuration ? Gilles found vba less than reliable from version to version. Using the info you gave, the event fired, but not able to get the properties of the previous plot. Any help is GREATLY appreciated.
"Previous Plot" is not actually a PlotConfiguration. Its saved in the registry, eg. : HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R15.0\ACAD-2:409\Profiles\PlainA cad\Previous plot settings There are subkeys for Model and Layout.
Ouch, <Previous Plot> is not the last configuration for the current drawing, but the last configuration used, whatever drawing it was. Too fast on the trigger. But we all know that the last configuration for the drawing is there in it somewhere. The question is: how to access it ??? Gilles
If you are referring to the Name of the active named page setup, it is not exposed to vba. I put that up on the wishlist a couple years ago. The Layout's properties are all set to the last used PlotConfiguration. The Page Setup name is only available via dxf. I do have a lisp that fetches it and can return it to vba, but it requires Frank's vlax.cls. Public Function GetCurrentPlotConfig(LayoutName As String) 'Returns the name of the current PlotConfig for the specified layout 'Must do this though lisp because vba does not expose this property. ' Dim vl As VLAX Dim strPC As String Set vl = New VLAX 'make sure lisp function (CurrentPlotConfig) is loaded vl.EvalLispExpression ("(if (null CurrentPlotConfig)(load ""CurrentPlotConfig.lsp""))") strPC = "(CurrentPlotConfig """ & LayoutName & """)" strPC = vl.EvalLispExpression(strPC) Set vl = Nothing GetCurrentPlotConfig = strPC End Function ;;; CurrentPlotConfig.lsp ;;; Ed Jobe copyright 2000 ;;; this function is used with vba. ;;; vba does not expose Page Setup Name. It is stored ;;; as the (1 . "name") of (100 . "AcDbPlotsettings") subgroup ;;; of the "ACAD_LAYOUT" named object dictionary. (defun CurrentPlotConfig (strLayout / layts layt pconfig ) (setq layts (dictsearch (namedobjdict) "acad_layout")) (setq layt (dictsearch (cdar layts) strLayout)) (setq pconfig (cdr (assoc 1 layt))) )
True. This registry key is only written when Autocad exits and therefor not usable for logging previous plots.
But if the user changes the setting and does not save them to the layout by checking the apply to layout button or save changes to layout check box, then the layout settings would not accurately represent the previous successful plot settings.
Thanks!! Thats the million dollar question.. It is in there somewhere, but how to access the <Previous Plot>.
How would you plot if autocad doesn't exist??? -- ---- Ed ---- not usable for logging previous plots.
In vba (this drawing), for the following code, the first value returned used to be the previous plot settings, but not true for R2005. A similar approach works for paper size and such.... Again does not work in 2005. Sub AcadDocument_ObjectModified(ByVal Object As Object) If TypeName(Object) = "IAcadLayout" Then MsgBox ThisDrawing.ActiveLayout.CanonicalMediaName MsgBox ThisDrawing.ActiveLayout.ConfigName End If End Sub
I havn't messed with 2005 much yet, it appears you are right. What I would suggest is watching the EndCommand event, trapping for the plot command and copying the ActiveLayout's settings to a global var that holds a PlotConfiguration object. That way you can duplcate what adesk is doing, storing the settings in memory until the program ends. -- ---- Ed ---- used to be the previous plot settings, but not true for R2005. A similar approach works for paper size and such....