Objectdbx Plot Settings

Discussion in 'AutoCAD' started by mnovendstern, Aug 25, 2004.

  1. mnovendstern

    mnovendstern Guest

    Is it possible to capture the last succsessfull plot settings using objectdbx in vb dotnet?
     
    mnovendstern, Aug 25, 2004
    #1
  2. 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...
     
    Mike Tuersley, Aug 25, 2004
    #2
  3. mnovendstern

    mnovendstern Guest

    Then Is it possible to monitor the endplot event? and how?
     
    mnovendstern, Aug 26, 2004
    #3
  4. 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...
     
    Mike Tuersley, Aug 26, 2004
    #4
  5. mnovendstern

    mnovendstern Guest

    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?
     
    mnovendstern, Sep 1, 2004
    #5
  6. 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...
     
    Mike Tuersley, Sep 1, 2004
    #6
  7. mnovendstern

    mnovendstern Guest

    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.
     
    mnovendstern, Sep 2, 2004
    #7
  8. 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.
     
    Gilles Plante, Sep 23, 2004
    #8
  9. mnovendstern

    Ed Jobe Guest

    "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.
     
    Ed Jobe, Sep 23, 2004
    #9
  10. 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
     
    Gilles Plante, Sep 23, 2004
    #10
  11. mnovendstern

    Ed Jobe Guest

    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)))
    )
     
    Ed Jobe, Sep 23, 2004
    #11
  12. mnovendstern

    mnovendstern Guest

    True. This registry key is only written when Autocad exits and therefor not usable for logging previous plots.
     
    mnovendstern, Sep 25, 2004
    #12
  13. mnovendstern

    mnovendstern Guest

    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.
     
    mnovendstern, Sep 25, 2004
    #13
  14. mnovendstern

    mnovendstern Guest

    Thanks!! Thats the million dollar question.. It is in there somewhere, but how to access the <Previous Plot>.
     
    mnovendstern, Sep 25, 2004
    #14
  15. mnovendstern

    Ed Jobe Guest

    How would you plot if autocad doesn't exist???

    --
    ----
    Ed
    ----
    not usable for logging previous plots.
     
    Ed Jobe, Sep 27, 2004
    #15
  16. EXITS
     
    Nathan Taylor, Sep 28, 2004
    #16
  17. mnovendstern

    mnovendstern Guest

    EXITS not exists. Subtle difference in spelling, but BIG difference in meaning. :)
     
    mnovendstern, Sep 29, 2004
    #17
  18. mnovendstern

    mnovendstern Guest

    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
     
    mnovendstern, Sep 29, 2004
    #18
  19. mnovendstern

    Ed Jobe Guest

    Yeah, it was Monday. :)
    --
    ----
    Ed
    ----
    meaning. :)
     
    Ed Jobe, Sep 29, 2004
    #19
  20. mnovendstern

    Ed Jobe Guest

    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....
     
    Ed Jobe, Sep 29, 2004
    #20
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.