.NET

Reply
Active Contributor
JasonSelf
Posts: 35
Registered: ‎08-30-2010
Message 1 of 2 (581 Views)

bouncing off of the plotsettingsvalidator

581 Views, 1 Replies
08-30-2010 09:47 AM

This is my first foray into .net development so please be patient with me,

I have been working on a .net application that has a plot feature.  Whenever I run my code it tells me that It tells me that I have provided an Unhandled Exception eInvalidInput with this in the details box: "at Autodesk.AutoCAD.DatabaseServices.PlotSettingsValidator.SetStdScale(PlotSettings plotSet, Double standardScale)"

 

Here is the code where I set the standard scale:

PltSetVdr.SetStdScale(PltSettings, GetOptions.cfgScale)

If I replace GetOptions.cfgScale with a double representing scale, or a direct call to the standard scale I get the same error, I also placed an alert box prior to this giving me the value of GetOptions.cfgScale and it seems to right.  I tried to comment out that line and it gave me an eInvalidInput when setting the style next.  Here is my code:

 

Public Class Plot_Services
    Public Sub PlotNow()
        Dim GetOptions As New XML_Load
        GetOptions.OptionPull(Form_Library.PlotIt_Form.cbPlotOptions.Text)

        Dim curDWG As Document = Application.DocumentManager.MdiActiveDocument
        Dim curDb As Database = curDWG.Database
        Application.SetSystemVariable("Backgroundplot", 0)
        Using Trans As Transaction = curDb.TransactionManager.StartTransaction
            Dim LayoutMgr As LayoutManager = LayoutManager.Current
            Dim Layout As Layout = Trans.GetObject(LayoutMgr.GetLayoutId(LayoutMgr.CurrentLayout), OpenMode.ForRead)
            Dim PltInfo As PlotInfo = New PlotInfo()
            PltInfo.Layout = Layout.ObjectId
            Dim PltSettings As PlotSettings = New PlotSettings(Layout.ModelType)
            PltSettings.CopyFrom(Layout)
            Dim PltSetVdr As PlotSettingsValidator = PlotSettingsValidator.Current
            PltSetVdr.RefreshLists(PltSettings)
            PltSetVdr.SetPlotType(PltSettings, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents)
            PltSetVdr.SetPlotCentered(PltSettings, True)
            PltSetVdr.SetUseStandardScale(PltSettings, True)
            'Debug Function
            'Application.ShowAlertDialog(GetOptions.cfgScale & vbCr & GetOptions.cfgStyle)
            PltSetVdr.SetStdScale(PltSettings, GetOptions.cfgScale)
            PltSetVdr.SetPlotCentered(PltSettings, True)
            PltSetVdr.SetPlotConfigurationName(PltSettings, GetOptions.cfgPlotter, GetOptions.cfgPaper)
            PltSetVdr.SetCurrentStyleSheet(PltSettings, GetOptions.cfgStyle)
            PltSetVdr.SetPlotPaperUnits(PltSettings, Autodesk.AutoCAD.DatabaseServices.PlotPaperUnit.Inches)
            PltInfo.OverrideSettings = PltSettings

            Dim PltInfoVal As PlotInfoValidator = New PlotInfoValidator()
            PltInfoVal.MediaMatchingPolicy = MatchingPolicy.MatchEnabled
            PltInfoVal.Validate(PltInfo)

            Using PltEng As PlotEngine = PlotFactory.CreatePublishEngine()
                Dim PltProgDlg As PlotProgressDialog = New PlotProgressDialog(False, 1, False)
                Using (PltProgDlg)
                    PltProgDlg.PlotMsgString(PlotMessageIndex.DialogTitle) = "Progess For This Drawing"
                    PltProgDlg.LowerPlotProgressRange = 0
                    PltProgDlg.UpperPlotProgressRange = 100
                    PltProgDlg.PlotProgressPos = 0
                    PltProgDlg.OnBeginPlot()
                    PltProgDlg.IsVisible = True

                    PltEng.BeginPlot(PltProgDlg, Nothing)
                    If GetOptions.cfgPlotToFile = "True" Then
                        Dim Dwgname As String = Application.DocumentManager.MdiActiveDocument.Name
                        PltEng.BeginDocument(PltInfo, curDWG.Name, Nothing, 1, True, "C:\pdf")
                    Else
                        PltEng.BeginDocument(PltInfo, Nothing, Nothing, 1, False, Nothing)
                    End If

                    PltEng.BeginGenerateGraphics(Nothing)
                    PltEng.EndGenerateGraphics(Nothing)

                    PltEng.EndPage(Nothing)
                    PltProgDlg.SheetProgressPos = 100
                    PltProgDlg.OnEndSheet()

                    PltEng.EndDocument(Nothing)
                    PltProgDlg.PlotProgressPos = 100
                    PltProgDlg.OnEndPlot()
                    PltEng.EndPlot(Nothing)

                End Using
            End Using
        End Using
    End Sub

 

Does anyone have any idea what I am doing wrong?

 

Thank you,

Jason Self

 

PS:  If it is of any help I am using Visual Basic in VisualStudio 2010 Express and AutoCAD 2010 but pointing my .net framework to 3.5  I realise the limitations I have with VS2010Express, but for the most part it seems to be doing the job, I hope this isn't contributing to my problem.

 

 

Valued Mentor
Jeffrey_H
Posts: 372
Registered: ‎01-20-2010
Message 2 of 2 (574 Views)

Re: bouncing off of the plotsettingsvalidator

08-30-2010 11:04 AM in reply to: JasonSelf

I beileve SetStdScale points to floating viewports but you plotting from model space the customPrintScale is always used.

If you set UseStandardScale to true then it uses the SetStdScale to calculate the customPrintScale.

I never tried plotting in model space.

Try Setting UseStandardScale to false and set it by the customscale Property

Do not know if it work I try it out later to see if it does.

 

You can also find your answers @ TheSwamp
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.