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

eInvaldInput error setting PlotPaperUnit.Inches

1 REPLY 1
Reply
Message 1 of 2
johntkeil
347 Views, 1 Reply

eInvaldInput error setting PlotPaperUnit.Inches

I am revising a vb.net program which inserts a standard drawing matte onto an empty paperspace layout.  The program contains a routine to check for the passed PlotSettings Object in the source drawing file and copy it to the current drawing's Layout1.  In this routine there is a line which sets the plotting units to inches and at this point the program generates an "unhandled exeception eInvalidInput...".  If I continue from this error, the program completes correctly so I am a bit puzzled as to what is causing it.  Here is the offending code:

 

            '**************** Destination Transaction Starts Here ****************             Using objTransaction As DatabaseServices.Transaction = objTransactionManager.StartTransaction()                 If SetLayoutAsCurrent(CONST_LAYOUT1, CallerName) Then                     ' The Layout Exists and is Current So Get a Reference to It Using the Layout Manager                     Dim objLayoutManager As LayoutManager = LayoutManager.Current                     Dim objLayout As Layout = objTransaction.GetObject(objLayoutManager.GetLayoutId(objLayoutManager.CurrentLayout), _                                                                                                     OpenMode.ForWrite)

                    ' '' Output the Name of the Current Layout and Its Device - Unremark for debugging                     ''objCurrentDrawing.Editor.WriteMessage(vbLf & "Current Layout: " & objLayout.LayoutName & vbLf)                     ''objCurrentDrawing.Editor.WriteMessage("Current Plot Configuration Name: " & objLayout.PlotConfigurationName & vbLf)

                    ' Reference the Destination PlotSettings Dictionary                     Dim objPlotSettingsDictionary As DBDictionary = objTransaction.GetObject(objDatabase.PlotSettingsDictionaryId, _                                                                                              OpenMode.ForWrite)

                    ' If the Passed PlotSettings Object Exists in the Current Drawing, Delete It                     If objPlotSettingsDictionary.Contains(SourceName) Then                         objPlotSettingsDictionary.Remove(SourceName)                     End If                     objPlotSettingsDictionary = Nothing

                    ' Create the Destination PlotSettings Object and Populate It from the Source PlotSettings                     Dim objDestinationPlotSettings As PlotSettings = New PlotSettings(False)                     objDestinationPlotSettings.CopyFrom(objSourcePlotSettings)

                    ' Add the Plot Settings Object to the Destination Plot Settings Dictionary                     objDestinationPlotSettings.AddToPlotSettingsDictionary(objDatabase)

                    ' Confirm that the Copied PlotSettings Object Exists in the Current Drawing's Plot Settings Dictionary                     ' and Reset the Object to Pick Up the ID After It was Added to the Database                     ' If It was Not Found or Reset, We Need to Send a Message and  Exit This Function                     If Not ResetPlotSettingsObject(objDestinationPlotSettings, objTransaction, objDatabase, CONST_PROCEDURE_NAME) Then                         Dim strMessage = "The " & SourceName & " Page Setup Did Not Copy Correctly!" & vbCrLf & vbCrLf & _                                          "You Must Rebuild the " & SourceName.ToUpper & CONST_DWG_EXTENSION & " File." & vbCrLf & _                                          CONST_ERRMSG_FILE_LOCATION_SPE & _                                          CONST_ERRMSG_INSERTMAT_CLOSING                         MsgBox(strMessage, MsgBoxStyle.ApplicationModal + MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, CallerName)                         Return False                     End If

                    ' Update the PlotSettings Object to Make It Handle the Mat Insertion                     Dim objPlotSettingsValidator As PlotSettingsValidator = PlotSettingsValidator.Current                     'objPlotSettingsValidator.RefreshLists(objDestinationPlotSettings)                     ' Set Paper Unit to Inches                     objPlotSettingsValidator.SetPlotPaperUnits(objDestinationPlotSettings, PlotPaperUnit.Inches)

                    ' Set to Use a Standard Scale Type of 1:1, but Set Custom First to Make It Refresh                     ' Debugging Try... Catch Statement.  Uncomment to use                     'Try                     Dim cstDestination As New CustomScale(1.0, 1.0)                     objPlotSettingsValidator.SetCustomPrintScale(objDestinationPlotSettings, cstDestination)                     'Catch exAbut As Autodesk.AutoCAD.Runtime.Exception                     'If exAbut.ToString = "eInvalidInput" Then                     'MsgBox("Inserting Mat", vbOK)                     'End If

                    'End Try

                    objPlotSettingsValidator.SetStdScaleType(objDestinationPlotSettings, StdScaleType.StdScale1To1)                     objPlotSettingsValidator.SetUseStandardScale(objDestinationPlotSettings, True)                     objPlotSettingsValidator.SetZoomToPaperOnUpdate(objDestinationPlotSettings, True)

                    ' Set to Scale the Lineweights                     If Not objDestinationPlotSettings.ScaleLineweights Then                         objDestinationPlotSettings.ScaleLineweights = True                     End If

                    ' Copy the PlotSettings Object Values to the Layout                     objLayout.CopyFrom(objDestinationPlotSettings)

                    objCurrentDrawing.Editor.Regen()                     objCurrentDrawing.SendStringToExecute("_.zoom _e" & vbCr, True, False, True)

                    ' '' Output the Name of the Current Layout and Its Device - Unremark for debugging                     ''objCurrentDrawing.Editor.WriteMessage(vbLf & "Current Layout: " & objLayout.LayoutName & vbLf)                     ''objCurrentDrawing.Editor.WriteMessage("Current Plot PaperSize X: " & objLayout.PlotPaperSize.X & vbLf)                     ''objCurrentDrawing.Editor.WriteMessage("Current Plot PaperSize Y: " & objLayout.PlotPaperSize.Y & vbLf)

                    ' Downgrade the Current Layout Mode Back to Read                     objLayout.DowngradeOpen()

                    ' Commit and Save the Changes to the Current Drawing                     objTransaction.Commit()

                    ' Clean Up the Destination Objects                     objPlotSettingsValidator = Nothing                     objDestinationPlotSettings = Nothing                     objLayout = Nothing                 Else                     Dim strMessage = "Layout1 could Not be Set as the Current Layout!" & vbCrLf & vbCrLf & _                                      "Please be Sure That Layout1 Exists in the '" & objCurrentDrawing.Name & "' Drawing" & vbCrLf & _                                      "and Re-run the Insert Mat Utility." & vbCrLf & vbCrLf & _                                      "The Insert Mat Utility will Now be Terminated." & vbCrLf & _                                      "Use the AutoCAD 'Undo' Button to Undo Changes Made by This Utility."                     MsgBox(strMessage, MsgBoxStyle.ApplicationModal + MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, CallerName)                     ' Abort and Abandon the Changes to the Current Document                     objTransaction.Abort()                 End If             End Using     ' Destination Transaction

            ' Clean Up the Current Drawing Transaction Objects             objTransactionManager.Dispose()             objTransactionManager = Nothing             objDatabase = Nothing             objCurrentDrawing = Nothing

            ' Abort Any Changes to the Source Drawing             objSourceTransaction.Abort()

            ' Clean Up the Source Drawing Transaction Objects             objSourcePlotSettings = Nothing             objSourcePlotSettingsDictionary = Nothing         End Using     ' Source Transaction         objSourceTransactionManager.Dispose()         objSourceTransactionManager = Nothing         objSourceDatabase.Dispose()         objSourceDatabase = Nothing

        Return True     End Function  ' CopyPageSetupFromFile

 

Any suggestions would be appreciated.

1 REPLY 1
Message 2 of 2
Balaji_Ram
in reply to: johntkeil

Hi John,

 

Sorry for the delay.

 

I have not come across any previous reports of such exception from the "SetPlotPaperUnits".

 

Can you please share a non-confidential buildable sample project for me to reproduce the exception ?

 

Thank you.



Balaji
Developer Technical Services
Autodesk Developer Network

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