.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
PlotSettin gsValidato r, SetStdScal e Error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Have a WPF form to input ploting parameters, all of which is typical to plotting in AutoCAD Select Scale (Custom or 1:1, 1:2, 2:1,1/128 - 1'-0" etc...). Have a special request for a 1:2.1 value for a non-typical output device (which works just fine in the AutoCAD plot dialog and as 0.4762 : 1 Input into Inches and Units variables). This value bombs my program with a 'Conversion from string "Error occured" to type 'Integer' is not valid' Error inside a try catch block.
Have tried several things and I'm petty sure I'm setting all 'PlotSettingsValidator' object settings correctly. So far nothing helps.
Entire procedure is included below (program bombs at: psv.SetStdScale(pltsettings, sc))
Any help you could offer would be highly valued.
CODE
Sub Plot(ByVal doc As Document, ByVal CurrLayout As Layout, _
ByVal Stamp As Boolean, ByVal StampFileName As String, _
ByVal plot2file As Boolean, Optional ByVal fname As String = Nothing)
Try
Dim tr As Transaction = _
Application.DocumentManager.MdiActiveDocument.Tr
StartTransaction
Try
If fname = "" Then fname = Nothing
Dim layoutMgr As LayoutManager = LayoutManager.Current, sc As Double
layoutMgr.CurrentLayout = CurrLayout.LayoutName
If Stamp Then
InsertBlock(doc.Database, StampFileName, "CONFIDENTIAL", False, 0, _
New Point3d(0, 0, 0))
End If
doc.SendStringToExecute("Zoom" & vbCr & "e" & vbCr, True, False, False)
Dim pltsettings As New PlotSettings(CurrLayout.ModelType)
pltsettings.CopyFrom(CurrLayout)
pltsettings.ScaleLineweights = bplot.ScaleLW.IsChecked
Dim pltinfo As New PlotInfo
pltinfo.Layout = CurrLayout.Id
Dim psv As PlotSettingsValidator = PlotSettingsValidator.Current
psv.SetPlotConfigurationName(pltsettings, bplot.PlotterCB.SelectedItem, _
bplot.SizeCB.SelectedItem.tag)
psv.SetCurrentStyleSheet(pltsettings, bplot.Penstyle_CB.SelectedItem)
psv.SetPlotPaperUnits(pltsettings, PlotPaperUnit.Inches)
psv.RefreshLists(pltsettings)
psv.SetPlotType(pltsettings, _
ConvertPlotType(bplot.TypeCB.SelectedItem.conte
psv.SetUseStandardScale(pltsettings, True)
psv.SetPlotRotation(pltsettings, _
ConvertPlotOrientation(bplot.RotationCB.Selecte
bplot.UpsideDownChk.IsChecked))
psv.SetPlotCentered(pltsettings, bplot.CenterPlot.IsChecked)
psv.SetPlotPaperUnits(pltsettings, PlotPaperUnit.Inches)
' --------------------------------------------------
'Conversion from string "NA" to type 'Double' is not Valid.
'Conversion from string "Error occured" to type 'Integer' is not valid.
If bplot.Scale2Fit.IsChecked Then
psv.SetStdScaleType(pltsettings, StdScaleType.ScaleToFit)
Else
If bplot.ScaleB.Text = "N/A" Then
MsgBox("Plot 1. . .")
sc = CDbl(bplot.ScaleA.Text)
Else
MsgBox("Plot 2. . .")
Dim inchval, unitval As Double
inchval = CDbl(bplot.ScaleA.Text)
unitval = CDbl(bplot.ScaleB.Text)
MsgBox("Scalea.text = " & inchval.ToString & " Type = " & _
inchval.GetType.ToString & vbLf & "Scaleb.text = " & _
unitval.ToString & " Type = " & unitval.GetType.ToString)
sc = (inchval / unitval)
End If
MsgBox("Plot 2a. . .sc =" & sc.ToString)
psv.SetStdScale(pltsettings, sc)
MsgBox("Plot 2b. . .")
End If
' --------------------------------------------------
pltinfo.OverrideSettings = pltsettings
Dim pltprgdlg As New PlotProgressDialog(False, 1, True)
pltprgdlg.UpperPlotProgressRange = 100
pltprgdlg.LowerPlotProgressRange = 0
Dim plteng As PlotEngine = PlotFactory.CreatePublishEngine
MsgBox("Plot 3. . .")
Try
MsgBox("Plot 4. . .")
pltprgdlg.OnBeginPlot()
pltprgdlg.IsVisible = True
plteng.BeginPlot(Nothing, Nothing)
Dim validator As New PlotInfoValidator
validator.MediaMatchingPolicy = MatchingPolicy.MatchEnabled
validator.Validate(pltinfo)
plteng.BeginDocument(pltinfo, _
Application.DocumentManager.MdiActiveDocument.D
Nothing, 1, plot2file, fname)
pltprgdlg.OnBeginSheet()
pltprgdlg.UpperSheetProgressRange = 100
pltprgdlg.LowerSheetProgressRange = 0
pltprgdlg.SheetProgressPos = 0
Dim pageinfo As New PlotPageInfo
plteng.BeginPage(pageinfo, pltinfo, True, Nothing)
plteng.BeginGenerateGraphics(Nothing)
plteng.EndGenerateGraphics(Nothing)
plteng.EndPage(Nothing)
pltprgdlg.SheetProgressPos = 100
pltprgdlg.OnEndSheet()
pltprgdlg.PlotProgressPos = 100
plteng.EndDocument(Nothing)
plteng.EndPlot(Nothing)
Catch ex As Exception
MsgBox("Error occured in function (Plot - Inner)" & vbCr & ex.Message, _
"Error occured")
End Try
pltprgdlg.Destroy()
plteng.Destroy()
tr.Commit()
Catch ex As Exception
MsgBox("Error occured in function (Plot- Middle)" & vbCr & ex.Message, _
"Error occured")
Finally
tr.Dispose()
End Try
Catch ex As SystemException
System.Windows.Forms.MessageBox.Show("Error occured in function (Plot- Outer)" & vbCr & _
"[" & ex.Message & "]", "Error occured")
Dim pname = (New StackTrace().GetFrame(1)).GetMethod.Name
Dim mname = (New StackFrame().GetMethod().Name)
LogError(ex, mname, pname)
End Try
End Sub
Re: PlotSettin gsValidato r, SetStdScal e Error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I've seen this behaviour in the editor before - eg. scaling viewports.
Try 4762 : 10000 to satisfy the integer complaint.
Re: PlotSettin gsValidato r, SetStdScal e Error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi Fieldguy --
Thanks for the input, same thing though Im afraid (4762:10000) I think it's setstdcale call th's actually throwing the error and at that point the value is back to a decimal (0.4762...); which makes the error even more enigmatic . . .where is the interger it's refering to?
Thanks though.
Re: PlotSettin gsValidato r, SetStdScal e Error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Try this maybe. I know it compiles and runs but I have not checked the scale on the output.
Dim myscale As CustomScale = NewCustomScale(4762, 10000)
psv.SetCustomPrintScale(ps, myscale)
Re: PlotSettin gsValidato r, SetStdScal e Error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Great, that pretty much got it with the following modifications to get it to work with all the possible values in my form.
Thanks so much for your help.
Dim psv AsPlotSettingsValidator = PlotSettingsValidator.Current
With psv
If bplot.Scale2Fit.IsChecked Then
.SetStdScaleType(pltsettings,StdScaleType.ScaleToFit)
.SetUseStandardScale(pltsettings,True)
ElseIf bplot.ScaleB.Text = "N/A" Then
.SetUseStandardScale(pltsettings,False)
Dim cscale AsNew Autodesk.AutoCAD.DatabaseServices.CustomScale_
(CDbl(bplot.ScaleA.Text), 1.0)
.SetCustomPrintScale(pltsettings, cscale)
Else
Dim inchval AsDouble = CDbl(bplot.ScaleA.Text)
Dim unitval AsDouble = CDbl(bplot.ScaleB.Text)
Dim myscale AsNewCustomScale(inchval, unitval)
.SetCustomPrintScale(pltsettings, myscale)
EndIf
EndIf
EndWith
Thanks Again.
Re: PlotSettin gsValidato r, SetStdScal e Error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
No problem - glad I could help.
Please mark the thread with an "Accepted Solution". I think you need to do that as the creator.
Re: PlotSettin gsValidato r, SetStdScal e Error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Be happy to but how exactly do I go about doing that? Poked around in all the options but couldn't find the place to do so?
Re: PlotSettin gsValidato r, SetStdScal e Error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
As the creator of the msg, you should see this button in all of the replies.
Re: PlotSettin gsValidato r, SetStdScal e Error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Re: PlotSettin gsValidato r, SetStdScal e Error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hum... Except I don't. There's nothing under the Reply link at all and I checked severl emails. Would totally like to give you credit though.



