eInvalidInput(code:5) error in SetPlotConfigurationName when printing in IJCAD 2017 VB.NET.IJCAD print commands allow PC3 files to be selected, but VB.NET does not recognize PC3 configuration files.The reason is that the pc3 file is not output when I run the program below.In some cases, any changes made in OPTIONS will result in a list of PC3 files (the OPTIONS settings will be displayed regardless of print, and if you "apply" any configuration changes will result in PC3 files will be displayed.
'Lists the available plotters (plot configuration [PC3] files)
<CommandMethod("PlotterList")>_
Public Shared SubPlotterList()
' Get the current document and database, and start a transaction
DimacDoc As Document=Application.DocumentManager.MdiActiveDocument
acDoc.Editor.WriteMessage(vbLf&"Plot devices:")
For Each plotDevice As String In PlotSettingsValidator.Current.GetPlotDeviceList()
' Output the names of the available plotter devices
acDoc.Editor.WriteMessage(vbLf&""&plotDevice)
Next
End Sub
As you answered, the PC3 file list is now displayed by keeping it up to date, but for the root cause, eInvalidInput(code:5) is still displayed in SetPlotConfigurationName.At first, I thought the device name (pc3) was strange, but it seems that the paper size (canonical media name) cannot be specified.I've tried many things, but I don't know why.I have attached the code below.
<CommandMethod("PlotterLocalMediaNameList")>_
Public Shared SubPlotterLocalMediaNameList()
' Get the current document and database, and start a transaction
DimacDoc As Document=Application.DocumentManager.MdiActiveDocument
Using plSet AsPlotSettings=NewPlotSettings (True)
DimacPlSetVdr AsPlotSettingsValidator=PlotSettingsValidator.Current
DimpStrOpts As PromptStringOptions = New PromptStringOptions(vbLf&_
"PC3 name:")
pStrOpts.AllowSpaces=True
Dim PC3 name As PromptResult=acDoc.Editor.GetString(pStrOpts)
DimpStrOpts2 As PromptStringOptions = New PromptStringOptions(vbLf&_
"CM name:")
pStrOpts2.AllowSpaces=True
DimCMname As PromptResult=acDoc.Editor.GetString(pStrOpts2)
' Set the Plotter and page size
acPlSetVdr.SetPlotConfigurationName(plSet,PC3name.StringResult,CMname.StringResult)
acDoc.Editor.WriteMessage(vbLf&"Canonical and Local media names:")
Dim cnt As Integer = 0
For Each mediaName As String InacPlSetVdr. GetCanonicalMediaNameList (plSet)
' Output the names of the available media for the specified device
acDoc.Editor.WriteMessage(vbLf&""&mediaName&"|"&_
acPlSetVdr.GetLocaleMediaName(plSet,cnt))
cnt = cnt+1
Next
End Using
End Sub
When creating this code, I wanted to print it with a PC3 file and a paper size, but there was an error in SetPlotConfigurationName, so I created a sample code to list the paper sizes as described above.I'm still looking into it, but I don't know why.
Dear tknmt, Post additional sample code Thank you.
The following error message is still displayed when you run it.
GrxCAD.Runtime.Exception: eInvalidInput (code:5)
Location GrxCAD.DatabaseServices.PlotSettingsValidator.
SetPlotConfigurationName(PlotSettingsplotSet, StringplotDeviceName, String
mediaName)
Location Class1.plot.PlotSetting()
Location: GrxCAD.ApplicationServices.GcMgdCmdClass.InvokeWorker (MethodInfomi,
Object commandObject, Boolean
bLispFunction)
Location GrxCAD.ApplicationServices.GcMgdCmdClass.
InvokeWorkerWithException (MethodInfomi, Object commandObject, Boolean)
bLispFunction)
Similar actions work fine with AutoCAD, but IJCAD fails.
.net ijcad printing
I tried to run the program described in IJCAD, but the list of PC3 files was printed without any problems.
If you make any optional changes, you may see a list of PC3 files, but you may see a list after you have updated the plot device for the layout you want to print with the PlotSettingsValidator.RefreshLists method.
<CommandMethod("RefreshList")>
Public Sub RefreshList()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
DimplSetVdr AsPlotSettingsValidator=PlotSettingsValidator.Current
Using Trans As Transaction=doc.TransactionManager.StartTransaction()
Dim curSpace As BlockTableRecord=Trans.GetObject (doc.Database.CurrentSpaceId, OpenMode.ForRead)
Dim curLayout As Layout = Trans.GetObject (curSpace.LayoutId, OpenMode.ForRead)
plSetVdr.RefreshLists (curLayout)
For EachplotDeviceInplSetVdr.GetPlotDeviceList()
doc.Editor.WriteMessage (vbLf&plotDevice)
Next
End Using
End Sub
I will add a sample code for printing the current layout in IJCAD
Public SubPlotSetting()
Dimdb=Application.DocumentManager.MdiActiveDocument.Database
Using tr As Transaction=db.TransactionManager.StartTransaction()
Dim curSpace As BlockTableRecord=tr.GetObject(db.CurrentSpaceId, OpenMode.ForRead)
Dimlayout As Layout=tr.GetObject(curSpace.LayoutId, OpenMode.ForWrite)
DimplSetVdr AsPlotSettingsValidator=PlotSettingsValidator.Current
plSetVdr.SetUseStandardScale(layout, True)
plSetVdr.SetPlotCentered(layout, True)
plSetVdr.SetPlotConfigurationName(layout, "DWG To PDF.pc3", Nothing)
For Each mediaNameAsStringInplSetVdr.GetCanonicalMediaNameList(layout)
DimlocalNameAsString=plSetVdr.GetLocaleMediaName(layout,mediaName)
If localName="ISO A4 (297.00 x 210.00 MM)" Then
plSetVdr.SetCanonicalMediaName(layout,mediaName)
Exit For
End If
Next
tr.Commit()
End Using
End Sub
To specify the paper size in IJCAD, you must obtain the actual print name from the print name for display.
If you used the actual print name, you could also configure it with the PC3 filename using the SetPlotConfigurationName method.
In this case, As you told me, I first specified Nothing as the media name and ran it, and it worked fine.By the way, I will do the following and report that it worked properly.The last time the error occurred, it seems that the list information was not up to date, so it was an error.
<CommandMethod("PlotSet")>_
Public Shared SubPlotSetting()
DimacDoc As Document=Application.DocumentManager.MdiActiveDocument
Dimdb=Application.DocumentManager.MdiActiveDocument.Database
Using tr As Transaction=db.TransactionManager.StartTransaction()
Dim curSpace As BlockTableRecord=tr.GetObject(db.CurrentSpaceId, OpenMode.ForRead)
Dimlayout As Layout=tr.GetObject(curSpace.LayoutId, OpenMode.ForWrite)
DimplSetVdr AsPlotSettingsValidator=PlotSettingsValidator.Current
plSetVdr.SetUseStandardScale(layout, True)
plSetVdr.SetPlotCentered(layout, True)
plSetVdr.SetPlotConfigurationName(layout, "PLOTPRT.pc3", Nothing)
For Each mediaNameAsStringInplSetVdr.GetCanonicalMediaNameList(layout)
DimlocalNameAsString=plSetVdr.GetLocaleMediaName(layout,mediaName)
acDoc.Editor.WriteMessage(vbLf&""&mediaName&"&localName)
If localName="ISO A4 (210.00 x 297.00 MM)" Then
plSetVdr.SetCanonicalMediaName(layout,mediaName)
Exit For
End If
Next
tr.Commit()
End Using
End Sub
This PC3 file was originally the file I wanted to specify, and I was able to get the media name.
Thank you very much for your hospitality.Thank you.
Another additional information is that if you change the PC3 file, you will get an error in the logic I mentioned earlier.(Once you restart IJCAD, it will run successfully.) This seems to have been the number one reason you couldn't.We tested the PC3 file with custom drawing size and so on, so in this case, it seems that we need to restart it.(Is it the same in other environments?)
I understand that AutoCAD works fine, but AutoCAD and IJCAD have different paper size names, so please check the IJCAD paper size names and try to specify them.
If you know the local media name that matches the paper size name, you can specify the device name and media name in the SetPlotConfigurationName method at the same time, but if you don't know the local media name, you can specify the media name as SetCanonicalMediaName.
Additional
I understand that you have added a custom paper size to your PC3 file, but the .NET API in IJCAD did not make any exceptions when you tried to set the custom paper size, but I have also confirmed that you cannot change the print settings properly.
© 2024 OneMinuteCode. All rights reserved.